scala.collection.immutable

HashSet

class HashSet[A] extends Set[A] with GenericSetTemplate[A, HashSet[A][A]] with SetLike[A, HashSet[A]] with FlatHashTable[A]

This class implements immutable sets using a hash table.

It is optimized for sequential accesses where the last updated table is accessed most often. It supports with reasonable efficiency accesses to previous versions of the table by keeping a change log that's regularly compacted. It needs to synchronize most methods, so it is less suitable for highly concurrent accesses.

Inherits

  1. FlatHashTable
  2. Set
  3. Set
  4. SetLike
  5. Subtractable
  6. Addable
  7. GenericSetTemplate
  8. Function1
  9. Iterable
  10. Iterable
  11. IterableLike
  12. Equals
  13. Traversable
  14. Immutable
  15. Traversable
  16. GenericTraversableTemplate
  17. TraversableLike
  18. HasNewBuilder
  19. AnyRef
  20. Any

Type Members

  1. class WithFilter extends AnyRef

    A class supporting filtered operations

Value Members

  1. def &(that: Set[A]): HashSet[A]

    Computes the intersection between this set and another set

  2. def &~(that: Set[A]): HashSet[A]

    The difference of this set and another set

  3. def **(that: Set[A]): HashSet[A]

    This method is an alias for intersect

  4. def +(elem: A): HashSet[A]

    Creates a new set with an additional element, unless the element is already present

  5. def +(elem1: A, elem2: A, elems: A*): HashSet[A]

    Creates a new set with additional elements

  6. def ++(iter: Iterator[A]): HashSet[A]

    Creates a new set by adding all elements produced by an iterator to this set

  7. def ++(elems: Traversable[A]): HashSet[A]

    Creates a new set by adding all elements contained in another collection to this set

  8. def ++[B >: A, That](that: Iterator[B])(bf: CanBuildFrom[HashSet[A], B, That]): That

    Concatenates this set with the elements of an iterator

  9. def ++[B >: A, That](that: Traversable[B])(bf: CanBuildFrom[HashSet[A], B, That]): That

    Concatenates this set with the elements of a traversable collection

  10. def -(elem: A): HashSet[A]

    Creates a new set with a given element removed from this set

  11. def -(elem1: A, elem2: A, elems: A*): HashSet[A]

    Creates a new set from this set with some elements removed

  12. def --(iter: Iterator[A]): HashSet[A]

    Creates a new set from this set by removing all elements produced by an iterator

  13. def --(elems: Traversable[A]): HashSet[A]

    Creates a new set from this set by removing all elements of another collection

  14. def /:[B](z: B)(op: (B, A) ⇒ B): B

    Applies a binary operator to a start value and all elements of this set, going left to right

  15. def :\[B](z: B)(op: (A, B) ⇒ B): B

    Applies a binary operator to all elements of this set and a start value, going right to left

  16. def addEntry(elem: A): Boolean

    Add entry if not yet in table Return whether a new entry was added

  17. def addString(b: StringBuilder): StringBuilder

    Appends all elements of this set to a string builder

  18. def addString(b: StringBuilder, sep: String): StringBuilder

    Appends all elements of this set to a string builder using a separator string

  19. def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder

    Appends all elements of this set to a string builder using start, end, and separator strings

  20. def andThen[A](g: (Boolean) ⇒ A): (A) ⇒ A

    (f andThen g)(x) == g(f(x))

  21. def apply(elem: A): Boolean

    Tests if some element is contained in this set

  22. def canEqual(that: Any): Boolean

    Method called from equality methods, so that user-defined subclasses can refuse to be equal to other collections of the same kind

  23. def companion: GenericCompanion[HashSet[A][A]]

    The factory companion object that builds instances of class Set

  24. def compose[A](g: (A) ⇒ A): (A) ⇒ Boolean

    (f compose g)(x) == f(g(x))

  25. def contains(elem: A): Boolean

    Tests if some element is contained in this set

  26. def containsEntry(elem: A): Boolean

  27. def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit

    Copies elements of this set to an array

  28. def copyToArray[B >: A](xs: Array[B]): Unit

    Copies elements of this set to an array

  29. def copyToArray[B >: A](xs: Array[B], start: Int): Unit

    Copies elements of this set to an array

  30. def copyToBuffer[B >: A](dest: Buffer[B]): Unit

    Copies all elements of this set to a buffer

  31. def count(p: (A) ⇒ Boolean): Int

    Counts the number of elements in the set which satisfy a predicate

  32. def diff(that: Set[A]): HashSet[A]

    Computes the difference of this set and another set

  33. def drop(n: Int): HashSet[A]

    Selects all elements except first n ones

  34. def dropRight(n: Int): HashSet[A]

    Selects all elements except first n ones

  35. def dropWhile(p: (A) ⇒ Boolean): HashSet[A]

    Drops longest prefix of elements that satisfy a predicate

  36. def elements: Iterator[A]

  37. def empty: HashSet[A]

  38. def equals(that: Any): Boolean

    Compares this set with another object for equality

  39. def exists(p: (A) ⇒ Boolean): Boolean

    Tests whether a predicate holds for some of the elements of this set

  40. def filter(p: (A) ⇒ Boolean): HashSet[A]

    Selects all elements of this set which satisfy a predicate

  41. def filterNot(p: (A) ⇒ Boolean): HashSet[A]

    Selects all elements of this set which do not satisfy a predicate

  42. def find(p: (A) ⇒ Boolean): Option[A]

    Finds the first element of the set satisfying a predicate, if any

  43. def findEntry(elem: A): Option[A]

  44. def first: A

  45. def firstOption: Option[A]

    None if iterable is empty

  46. def flatMap[B, That](f: (A) ⇒ Traversable[B])(bf: CanBuildFrom[HashSet[A], B, That]): That

    Builds a new collection by applying a function to all elements of this set and concatenating the results

  47. def flatten[B](asTraversable: (A) ⇒ Traversable[B]): HashSet[B]

    Converts this set of traversable collections into a set in which all element collections are concatenated

  48. def foldLeft[B](z: B)(op: (B, A) ⇒ B): B

    Applies a binary operator to a start value and all elements of this set, going left to right

  49. def foldRight[B](z: B)(op: (A, B) ⇒ B): B

    Applies a binary operator to all elements of this set and a start value, going right to left

  50. def forall(p: (A) ⇒ Boolean): Boolean

    Tests whether a predicate holds for all elements of this set

  51. def foreach[U](f: (A) ⇒ U): Unit

    Applies a function f to all elements of this set

  52. def genericBuilder[B]: Builder[B, HashSet[B]]

    The generic builder that builds instances of Set at arbitrary element types

  53. def groupBy[K](f: (A) ⇒ K): Map[K, HashSet[A]]

    Partitions this set into a map of sets according to some discriminator function

  54. def hasDefiniteSize: Boolean

    Tests whether this set is known to have a finite size

  55. def hashCode(): Int

    Returns a hash code value for the object

  56. def head: A

    Selects the first element of this set

  57. def headOption: Option[A]

    Optionally selects the first element

  58. def init: HashSet[A]

    Selects all elements except the last

  59. def intersect(that: Set[A]): HashSet[A]

    Computes the intersection between this set and another set

  60. def isEmpty: Boolean

    Tests if this set is empty

  61. def iterator: Iterator[A]

    Creates a new iterator over all elements contained in this iterable object

  62. def last: A

    Selects the last element

  63. def lastOption: Option[A]

    Optionally selects the last element

  64. def map[B, That](f: (A) ⇒ B)(bf: CanBuildFrom[HashSet[A], B, That]): That

    Builds a new collection by applying a function to all elements of this set

  65. def max[B >: A](cmp: Ordering[B]): A

    Finds the largest element

  66. def min[B >: A](cmp: Ordering[B]): A

    Finds the smallest element

  67. def mkString: String

    Displays all elements of this set in a string

  68. def mkString(sep: String): String

    Displays all elements of this set in a string using a separator string

  69. def mkString(start: String, sep: String, end: String): String

    Displays all elements of this set in a string using start, end, and separator strings

  70. def nonEmpty: Boolean

    Tests whether the set is not empty

  71. def partialMap[B, That](pf: PartialFunction[A, B])(bf: CanBuildFrom[HashSet[A], B, That]): That

    Builds a new collection by applying a partial function to all elements of this set on which the function is defined

  72. def partition(p: (A) ⇒ Boolean): (HashSet[A], HashSet[A])

    Partitions this set in two sets according to a predicate

  73. def product[B >: A](num: Numeric[B]): B

    Multiplies up the elements of this collection

  74. def projection: IterableView[A, HashSet[A]]

    returns a projection that can be used to call non-strict filter,map, and flatMap methods that build projections of the collection

  75. def reduceLeft[B >: A](op: (B, A) ⇒ B): B

    Applies a binary operator to all elements of this set, going left to right

  76. def reduceLeftOption[B >: A](op: (B, A) ⇒ B): Option[B]

    Optionally applies a binary operator to all elements of this set, going left to right

  77. def reduceRight[B >: A](op: (A, B) ⇒ B): B

    Applies a binary operator to all elements of this set, going right to left

  78. def reduceRightOption[B >: A](op: (A, B) ⇒ B): Option[B]

    Optionally applies a binary operator to all elements of this set, going right to left

  79. def removeEntry(elem: A): Option[A]

  80. def repr: HashSet[A]

    The collection of type set underlying this TraversableLike object

  81. def sameElements[B >: A](that: Iterable[B]): Boolean

    Checks if the other iterable collection contains the same elements in the same order as this set

  82. def size: Int

    The size of this set

  83. def slice(from: Int, until: Int): HashSet[A]

    Selects an interval of elements

  84. def span(p: (A) ⇒ Boolean): (HashSet[A], HashSet[A])

    Spits this set into a prefix/suffix pair according to a predicate

  85. def splitAt(n: Int): (HashSet[A], HashSet[A])

    Splits this set into two at a given position

  86. def stringPrefix: String

    Defines the prefix of this object's toString representation

  87. def subsetOf(that: Set[A]): Boolean

    Tests whether this set is a subset of another set

  88. def sum[B >: A](num: Numeric[B]): B

    Sums up the elements of this collection

  89. def tail: HashSet[A]

    Selects all elements except the first

  90. def take(n: Int): HashSet[A]

    Selects first n elements

  91. def takeRight(n: Int): HashSet[A]

    Selects last n elements

  92. def takeWhile(p: (A) ⇒ Boolean): HashSet[A]

    Takes longest prefix of elements that satisfy a predicate

  93. def toArray[B >: A](arg0: ClassManifest[B]): Array[B]

    Converts this set to an array

  94. def toIndexedSeq[B >: A]: IndexedSeq[B]

    Converts this set to an indexed sequence

  95. def toIterable: Iterable[A]

    Converts this set to an iterable collection

  96. def toList: List[A]

    Converts this set to a list

  97. def toSeq: Seq[A]

    Converts this set to a sequence

  98. def toSet[B >: A]: Set[B]

    Converts this set to a set

  99. def toStream: Stream[A]

    Converts this set to a stream

  100. def toString(): String

    Converts this set to a string

  101. def transpose[B](asTraversable: (A) ⇒ Traversable[B]): HashSet[HashSet[B]]

    Transposes this set of traversable collections into

  102. def union(that: Set[A]): HashSet[A]

    Computes the union between of set and another set

  103. def unzip[A1, A2](asPair: (A) ⇒ (A1, A2)): (HashSet[A1], HashSet[A2])

    Converts this set of pairs into two collections of the first and second halfs of each pair

  104. def view(from: Int, until: Int): IterableView[A, HashSet[A]]

    Creates a non-strict view of a slice of this set

  105. def view: IterableView[A, HashSet[A]]

    Creates a non-strict view of this set

  106. def withFilter(p: (A) ⇒ Boolean): WithFilter

    Creates a non-strict filter of this set

  107. def zip[A1 >: A, B, That](that: Iterable[B])(bf: CanBuildFrom[HashSet[A], (A1, B), That]): That

    Returns a set formed from this set and another iterable collection by combining corresponding elements in pairs

  108. def zipAll[B, A1 >: A, That](that: Iterable[B], thisElem: A1, thatElem: B)(bf: CanBuildFrom[HashSet[A], (A1, B), That]): That

    Returns a set formed from this set and another iterable collection by combining corresponding elements in pairs

  109. def zipWithIndex[A1 >: A, That](bf: CanBuildFrom[HashSet[A], (A1, Int), That]): That

    Zips this set with its indices

  110. def |(that: Set[A]): HashSet[A]

    Computes the union between this set and another set

Instance constructors

  1. new HashSet()