Scala中的set集合
发布日期:2021-05-14 05:34:44 浏览次数:25 分类:精选文章

本文共 1383 字,大约阅读时间需要 4 分钟。

Scala ??????

Scala???Scala??????????????????????????????????????????????????Scala?????????????????????????? scala.collection.mutable.Set ??

???????

Scala??????????????????????????????????????????? O(log n) ???????????????????????????????????????? O(n)?

?????

?????

Scala????????????????????????????????????????????var?????????????????????

????

???????????????????? scala.collection.mutable.Set ??

??????

????

  • head?????????????
  • tail?????????????????????????
  • isEmpty??????????

????

  • ++ ? .++()??????????????????????????set1 ++ set2 ???????????? set1 ? set2 ??????set1.++(set2) ???? set1 ++ set2 ???

????

  • ???????????? max ? min ????????????????????
  • ???????????? apply ??? contains ????????????????
  • ?????????????? count ?????????????????????set1.count(_ > 3) ????????3??????
  • ??????? filter ????????????????????????????set1.filter(_ > 3) ?????????????3????

????????

???????????????

?? ?????
1 def +(elem: A): Set[A]
??????????????????
2 def -(elem: A): Set[A]
????????????????????
3 def contains(elem: A): Boolean
?????????????
4 def &(that: Set[A]): Set[A]
??????????
5 def &~(that: Set[A]): Set[A]
??????????
6 def +(elem1: A, elem2: A, elems: A*): Set[A]
????????????????
7 def ++(elems: A): Set[A]
????????????????
8 def -(elem1: A, elem2: A, elems: A*): Set[A]
????????????????
9 def addString(b: StringBuilder): StringBuilder
???????????????????

?????????????????????????????????????

上一篇:Scala中 常用容器类的函数/方法
下一篇:SQL中的脏读、不可重复读、幻读

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2025年05月18日 04时42分19秒