scala.collection.mutable

HashSet

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

This class implements mutable sets using a hashtable .

A

the type of the elements contained in this set .

go to: companion
source: HashSet.scala
    version
  1. 2 . 0, 31/12/2006

    since
  1. 1

    authors:
  1. Martin Odersky

  2. ,
  3. Matthias Zenger

Inherited
  1. Hide All
  2. Show all
  1. FlatHashTable
  2. Set
  3. SetLike
  4. Cloneable
  5. Shrinkable
  6. Builder
  7. Growable
  8. Scriptable
  9. Set
  10. SetLike
  11. Subtractable
  12. Addable
  13. GenericSetTemplate
  14. Function1
  15. Iterable
  16. Iterable
  17. IterableLike
  18. Equals
  19. Traversable
  20. Mutable
  21. Traversable
  22. GenericTraversableTemplate
  23. TraversableLike
  24. TraversableOnce
  25. HasNewBuilder
  26. AnyRef
  27. Any
Visibility
  1. Public
  2. All

Instance constructors

  1. new HashSet()

Type Members

  1. type Self = HashSet[A]

    The type implementing this traversable

  2. class WithFilter extends AnyRef

    A class supporting filtered operations .

Value Members

  1. def !=(arg0: AnyRef): Boolean

  2. def !=(arg0: Any): Boolean

    o != arg0 is the same as !(o == (arg0)).

  3. def ##(): Int

  4. def $asInstanceOf[T0](): T0

  5. def $isInstanceOf[T0](): Boolean

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

    Computes the intersection between this set and another set .

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

    The difference of this set and another set .

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

    This method is an alias for intersect.

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

    Adds two or more elements to this collection and returns the collection itself .

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

    Adds a single element to this collection and returns the collection itself .

  11. def ++(xs: TraversableOnce[A]): HashSet[A]

    Adds a number of elements provided by a traversable object and returns either the collection itself .

  12. def ++(that: TraversableOnce[A]): Traversable[A]

    [use case] Concatenates this mutable hash set with the elements of a traversable collection .

  13. def ++[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[HashSet[A], B, That]): That

    Concatenates this mutable hash set with the elements of a traversable collection .

  14. def ++=(xs: TraversableOnce[A]): Growable[A]

    adds all elements produced by a TraversableOnce to this mutable hash set .

  15. def +=(elem: A): HashSet[A]

    Adds a single element to the set .

  16. def +=(elem1: A, elem2: A, elems: A*): Growable[A]

    adds two or more elements to this mutable hash set .

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

    Removes two or more elements from this collection and returns the collection itself .

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

    Removes a single element from this collection and returns the collection itself .

  19. def --(xs: TraversableOnce[A]): HashSet[A]

    Removes a number of elements provided by a Traversable object and returns the collection itself .

  20. def --=(xs: TraversableOnce[A]): Shrinkable[A]

    Removes all elements produced by an iterator from this mutable hash set .

  21. def -=(elem: A): HashSet[A]

    Removes a single element from this mutable hash set .

  22. def -=(elem1: A, elem2: A, elems: A*): Shrinkable[A]

    Removes two or more elements from this mutable hash set .

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

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

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

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

  25. def <<(cmd: Message[A]): Unit

    Send a message to this scriptable object .

  26. def ==(arg0: AnyRef): Boolean

    o == arg0 is the same as if (o eq null) arg0 eq null else o.equals(arg0).

  27. def ==(arg0: Any): Boolean

    o == arg0 is the same as o.equals(arg0).

  28. def add(elem: A): Boolean

    Adds an element to this mutable hash set .

  29. def addEntry(elem: A): Boolean

    Add entry if not yet in table .

  30. def addString(b: StringBuilder): StringBuilder

    Appends all elements of this mutable hash set to a string builder .

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

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

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

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

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

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

  34. def apply(elem: A): Boolean

    Tests if some element is contained in this set .

  35. def asInstanceOf[T0]: T0

    This method is used to cast the receiver object to be of type T0.

  36. 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 .

  37. def clear(): Unit

    Removes all elements from the set .

  38. def clearTable(): Unit

  39. def clone(): HashSet[A]

    This method creates and returns a copy of the receiver object .

  40. def collect[B](pf: PartialFunction[A, B]): Traversable[B]

    [use case] Builds a new collection by applying a partial function to all elements of this mutable hash set on which the function is defined .

  41. def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[HashSet[A], B, That]): That

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

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

    The factory companion object that builds instances of class mutable .

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

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

  44. def contains(elem: A): Boolean

    Tests if some element is contained in this set .

  45. def containsEntry(elem: A): Boolean

    Checks whether an element is contained in the hash table .

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

    [use case] Copies elements of this mutable hash set to an array .

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

    Copies elements of this mutable hash set to an array .

  48. def copyToArray(xs: Array[A]): Unit

    [use case] Copies values of this mutable hash set to an array .

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

    Copies values of this mutable hash set to an array .

  50. def copyToArray(xs: Array[A], start: Int): Unit

    [use case] Copies values of this mutable hash set to an array .

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

    Copies values of this mutable hash set to an array .

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

    Copies all elements of this mutable hash set to a buffer .

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

    Counts the number of elements in the mutable hash set which satisfy a predicate .

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

    Computes the difference of this set and another set .

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

    Selects all elements except first n ones.

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

    Selects all elements except last n ones.

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

    Drops longest prefix of elements that satisfy a predicate .

  58. def elemHashCode(elem: A): Int

  59. def elements: Iterator[A]

  60. def empty: HashSet[A]

  61. def eq(arg0: AnyRef): Boolean

    This method is used to test whether the argument (arg0) is a reference to the receiver object (this).

  62. def equals(that: Any): Boolean

    Compares this set with another object for equality .

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

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

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

    Selects all elements of this mutable hash set which satisfy a predicate .

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

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

  66. def finalize(): Unit

    This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object .

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

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

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

    Finds an entry in the hash table if such an element exists .

  69. def first: A

  70. def firstOption: Option[A]

    None if iterable is empty.

  71. def flatMap[B](f: (A) ⇒ Traversable[B]): Traversable[B]

    [use case] Builds a new collection by applying a function to all elements of this mutable hash set and concatenating the results .

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

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

  73. def flatten[B]: CC[B]

    [use case] Converts this mutable hash set of traversable collections into a mutable hash set in which all element collections are concatenated .

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

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

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

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

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

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

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

    Tests whether a predicate holds for all elements of this mutable hash set .

  78. def foreach(f: (A) ⇒ Unit): Unit

    [use case] Applies a function f to all elements of this mutable hash set.

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

    Applies a function f to all elements of this mutable hash set.

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

    The generic builder that builds instances of mutable .

  81. def getClass(): java.lang.Class[_ <: java.lang.Object]

    Returns a representation that corresponds to the dynamic class of the receiver object .

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

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

  83. def grouped(size: Int): Iterator[HashSet[A]]

    Partitions elements in fixed size mutable hash sets .

  84. def hasDefiniteSize: Boolean

    Tests whether this mutable hash set is known to have a finite size .

  85. def hashCode(): Int

    Returns a hash code value for the object .

  86. def head: A

    Selects the first element of this mutable hash set .

  87. def headOption: Option[A]

    Optionally selects the first element .

  88. def improve(hcode: Int): Int

  89. def index(hcode: Int): Int

  90. def init: HashSet[A]

    Selects all elements except the last .

  91. def initialSize: Int

    The initial size of the hash table .

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

    Computes the intersection between this set and another set .

  93. def isEmpty: Boolean

    Tests if this set is empty .

  94. def isInstanceOf[T0]: Boolean

    This method is used to test whether the dynamic type of the receiver object is T0.

  95. def isTraversableAgain: Boolean

    Tests whether this mutable hash set can be repeatedly traversed .

  96. def iterator: Iterator[A]

  97. def last: A

    Selects the last element .

  98. def lastOption: Option[A]

    Optionally selects the last element .

  99. def loadFactor: Int

    The load factor for the hash table; must be < 500 (0 .

  100. def loadFactorDenum: Int

  101. def map[B](f: (A) ⇒ B): Traversable[B]

    [use case] Builds a new collection by applying a function to all elements of this mutable hash set .

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

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

  103. def mapResult[NewTo](f: (HashSet[A]) ⇒ NewTo): Builder[A, NewTo]

    Creates a new builder by applying a transformation function to the results of this builder .

  104. def max: A

    [use case] Finds the largest element .

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

    Finds the largest element .

  106. def min: A

    [use case] Finds the smallest element .

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

    Finds the smallest element .

  108. def mkString: String

    Displays all elements of this mutable hash set in a string .

  109. def mkString(sep: String): String

    Displays all elements of this mutable hash set in a string using a separator string .

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

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

  111. def ne(arg0: AnyRef): Boolean

    o.ne(arg0) is the same as !(o.eq(arg0)).

  112. def newBuilder: Builder[A, HashSet[A]]

    A common implementation of newBuilder for all mutable sets in terms of empty.

  113. def nonEmpty: Boolean

    Tests whether the mutable hash set is not empty .

  114. def notify(): Unit

    Wakes up a single thread that is waiting on the receiver object's monitor .

  115. def notifyAll(): Unit

    Wakes up all threads that are waiting on the receiver object's monitor .

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

    Partitions this mutable hash set in two mutable hash sets according to a predicate .

  117. def product: Int

    [use case] Multiplies up the elements of this collection .

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

    Multiplies up the elements of this collection .

  119. 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.

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

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

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

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

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

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

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

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

  124. def remove(elem: A): Boolean

    Removes an element from this set .

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

    Removes an entry from the hash table, returning an option value with the element, or None if it didn't exist.

  126. def repr: HashSet[A]

    The collection of type mutable hash set underlying this TraversableLike object.

  127. def result(): HashSet[A]

    The result when this set is used as a builder

  128. def retain(p: (A) ⇒ Boolean): Unit

    Removes all elements from the set for which do not satisfy a predicate .

  129. def reversed: List[A]

  130. def sameElements(that: Iterable[A]): Boolean

    [use case] Checks if the other iterable collection contains the same elements in the same order as this mutable hash set .

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

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

  132. def scanLeft[B, That](z: B)(op: (B, A) ⇒ B)(implicit bf: CanBuildFrom[HashSet[A], B, That]): That

    Produces a collection containing cummulative results of applying the operator going left to right .

  133. def scanRight[B, That](z: B)(op: (A, B) ⇒ B)(implicit bf: CanBuildFrom[HashSet[A], B, That]): That

    Produces a collection containing cummulative results of applying the operator going right to left .

  134. def size: Int

    The size of this mutable hash set .

  135. def sizeHint(size: Int): Unit

    Gives a hint how many elements are expected to be added when the next result is called.

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

    Selects an interval of elements .

  137. def sliding[B >: A](size: Int, step: Int): Iterator[HashSet[A]]

  138. def sliding[B >: A](size: Int): Iterator[HashSet[A]]

    Groups elements in fixed size blocks by passing a "sliding window" over them (as opposed to partitioning them, as is done in grouped .

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

    Splits this mutable hash set into a prefix/suffix pair according to a predicate .

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

    Splits this mutable hash set into two at a given position .

  141. def stringPrefix: String

    Defines the prefix of this object's toString representation.

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

    Tests whether this set is a subset of another set .

  143. def sum: Int

    [use case] Sums up the elements of this collection .

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

    Sums up the elements of this collection .

  145. def synchronized[T0](arg0: T0): T0

  146. var table: Array[AnyRef]

    The actual hash table .

  147. var tableSize: Int

    The number of mappings contained in this hash table .

  148. def tail: HashSet[A]

    Selects all elements except the first .

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

    Selects first n elements.

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

    Selects last n elements.

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

    Takes longest prefix of elements that satisfy a predicate .

  152. def thisCollection: Iterable[A]

    The underlying collection seen as an instance of mutable.HashSet.

  153. var threshold: Int

    The next size value at which to resize (capacity * load factor) .

  154. def toArray: Array[A]

    [use case] Converts this mutable hash set to an array .

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

    Converts this mutable hash set to an array .

  156. def toCollection(repr: HashSet[A]): Iterable[A]

    A conversion from collections of type Repr to mutable.HashSet objects.

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

    Converts this mutable hash set to an indexed sequence .

  158. def toIterable: Iterable[A]

    Converts this mutable hash set to an iterable collection .

  159. def toIterator: Iterator[A]

    Returns an Iterator over the elements in this mutable hash set .

  160. def toList: List[A]

    Converts this mutable hash set to a list .

  161. def toMap[T, U](implicit ev: <:<[A, (T, U)]): Map[T, U]

    Converts this mutable hash set to a map .

  162. def toSeq: Seq[A]

    Converts this mutable hash set to a sequence .

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

    Converts this mutable hash set to a set .

  164. def toStream: Stream[A]

    Converts this mutable hash set to a stream .

  165. def toString(): String

    Converts this mutable hash set to a string .

  166. def toTraversable: Traversable[A]

    Converts this mutable hash set to an unspecified Traversable .

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

    Transposes this mutable hash set of traversable collections into a mutable hash set of mutable hash sets .

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

    Computes the union between of set and another set .

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

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

  170. def update(elem: A, included: Boolean): Unit

    Updates the presence of a single element in this set .

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

    Creates a non-strict view of a slice of this mutable hash set .

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

    Creates a non-strict view of this mutable hash set .

  173. def wait(): Unit

  174. def wait(arg0: Long, arg1: Int): Unit

  175. def wait(arg0: Long): Unit

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

    Creates a non-strict filter of this mutable hash set .

  177. def zip[B](that: Iterable[B]): Iterable[(A, B)]

    [use case] Returns a mutable hash set formed from this mutable hash set and another iterable collection by combining corresponding elements in pairs .

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

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

  179. def zipAll[B](that: Iterable[B], thisElem: A, thatElem: B): Iterable[(A, B)]

    [use case] Returns a mutable hash set formed from this mutable hash set and another iterable collection by combining corresponding elements in pairs .

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

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

  181. def zipWithIndex: Iterable[(A, Int)]

    [use case] Zips this mutable hash set with its indices .

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

    Zips this mutable hash set with its indices .

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

    Computes the union between this set and another set .