scala.collection.immutable

TreeSet

class TreeSet[A] extends RedBlack[A] with SortedSet[A] with SortedSetLike[A, TreeSet[A]]

This class implements immutable sets using a tree.

A

the type of the elements contained in this tree set

go to: companion
source: TreeSet.scala
    version
  1. 2.0, 02/01/2007

    since
  1. 1

    authors:
  1. Martin Odersky

Inherited
  1. Hide All
  2. Show all
  1. SortedSet
  2. SortedSet
  3. SortedSetLike
  4. Sorted
  5. Set
  6. Set
  7. SetLike
  8. Subtractable
  9. Addable
  10. GenericSetTemplate
  11. Function1
  12. Iterable
  13. Iterable
  14. IterableLike
  15. Equals
  16. Traversable
  17. Immutable
  18. Traversable
  19. GenericTraversableTemplate
  20. TraversableLike
  21. TraversableOnce
  22. HasNewBuilder
  23. RedBlack
  24. AnyRef
  25. Any
Visibility
  1. Public
  2. All

Instance constructors

  1. new TreeSet()(implicit ordering: Ordering[A])

  2. new TreeSet(size: Int, t: Tree[Unit])(implicit ordering: Ordering[A])

Type Members

  1. class BlackTree[+B](key: A, value: B, left: Tree[B], right: Tree[B]) extends NonEmpty[B] with Product

  2. class NonEmpty[+B] extends Tree[B]

  3. class RedTree[+B](key: A, value: B, left: Tree[B], right: Tree[B]) extends NonEmpty[B] with Product

  4. type Self = TreeSet[A]

    The type implementing this traversable

  5. class Tree[+B] extends AnyRef

  6. 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]): TreeSet[A]

    Computes the intersection between this set and another set.

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

    The difference of this set and another set.

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

    This method is an alias for intersect.

  9. def +(elem: A): TreeSet[A]

    Creates a new TreeSet with the entry added.

  10. def +(elem1: A, elem2: A, elems: A*): TreeSet[A]

    Creates a new immutable tree set with additional elements.

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

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

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

    [use case] Concatenates this immutable tree set with the elements of a traversable collection.

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

    Concatenates this immutable tree set with the elements of a traversable collection.

  14. def -(elem: A): TreeSet[A]

    Creates a new TreeSet with the entry removed.

  15. def -(elem1: A, elem2: A, elems: A*): TreeSet[A]

    Creates a new immutable tree set from this immutable tree set with some elements removed.

  16. def --(xs: TraversableOnce[A]): TreeSet[A]

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

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

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

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

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

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

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

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

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

  21. object Empty extends Tree[Nothing] with Product

  22. def addString(b: StringBuilder): StringBuilder

    Appends all elements of this immutable tree set to a string builder.

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

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

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

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

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

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

  26. def apply(elem: A): Boolean

    Tests if some element is contained in this set.

  27. def asInstanceOf[T0]: T0

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

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

  29. def clone(): AnyRef

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

  30. 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 immutable tree set on which the function is defined.

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

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

  32. def companion: GenericCompanion[Set[A][A]]

    The factory companion object that builds instances of class immutable.

  33. def compare(k0: A, k1: A): Int

    Comparison function that orders keys.

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

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

  35. def contains(elem: A): Boolean

    Checks if this set contains element elem.

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

    [use case] Copies elements of this immutable tree set to an array.

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

    Copies elements of this immutable tree set to an array.

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

    [use case] Copies values of this immutable tree set to an array.

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

    Copies values of this immutable tree set to an array.

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

    [use case] Copies values of this immutable tree set to an array.

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

    Copies values of this immutable tree set to an array.

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

    Copies all elements of this immutable tree set to a buffer.

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

    Counts the number of elements in the immutable tree set which satisfy a predicate.

  44. def diff(that: Set[A]): TreeSet[A]

    Computes the difference of this set and another set.

  45. def drop(n: Int): TreeSet[A]

    Selects all elements except first n ones.

  46. def dropRight(n: Int): TreeSet[A]

    Selects all elements except last n ones.

  47. def dropWhile(p: (A) ⇒ Boolean): TreeSet[A]

    Drops longest prefix of elements that satisfy a predicate.

  48. def elements: Iterator[A]

  49. def empty: TreeSet[A]

    A factory to create empty sets of the same type of keys.

  50. def eq(arg0: AnyRef): Boolean

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

  51. def equals(that: Any): Boolean

    Compares this set with another object for equality.

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

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

  53. def filter(p: (A) ⇒ Boolean): TreeSet[A]

    Selects all elements of this immutable tree set which satisfy a predicate.

  54. def filterNot(p: (A) ⇒ Boolean): TreeSet[A]

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

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

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

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

  57. def first: A

  58. def firstKey: A

    Returns the first key of the collection.

  59. def firstOption: Option[A]

    None if iterable is empty.

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

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

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

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

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

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

  63. def flatten[B](implicit asTraversable: (A) ⇒ Traversable[B]): Set[B]

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

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

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

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

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

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

    Tests whether a predicate holds for all elements of this immutable tree set.

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

    [use case] Applies a function f to all elements of this immutable tree set.

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

    Applies a function f to all elements of this immutable tree set.

  69. def from(from: A): TreeSet[A]

    Creates a ranged projection of this collection with no upper-bound.

  70. def genericBuilder[B]: Builder[B, Set[B]]

    The generic builder that builds instances of immutable.

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

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

  72. def groupBy[K](f: (A) ⇒ K): Map[K, TreeSet[A]]

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

  73. def grouped(size: Int): Iterator[TreeSet[A]]

    Partitions elements in fixed size immutable tree sets.

  74. def hasAll(j: Iterator[A]): Boolean

  75. def hasDefiniteSize: Boolean

    Tests whether this immutable tree set is known to have a finite size.

  76. def hashCode(): Int

    Returns a hash code value for the object.

  77. def head: A

    Selects the first element of this immutable tree set.

  78. def headOption: Option[A]

    Optionally selects the first element.

  79. def init: TreeSet[A]

    Selects all elements except the last.

  80. def insert(elem: A): TreeSet[A]

    A new TreeSet with the entry added is returned, assuming that elem is not in the TreeSet.

  81. def intersect(that: Set[A]): TreeSet[A]

    Computes the intersection between this set and another set.

  82. def isEmpty: Boolean

    Tests if this set is empty.

  83. def isInstanceOf[T0]: Boolean

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

  84. def isSmaller(x: A, y: A): Boolean

  85. def isTraversableAgain: Boolean

    Tests whether this immutable tree set can be repeatedly traversed.

  86. def iterator: Iterator[A]

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

  87. def keySet: TreeSet[A]

    return as a projection the set of keys in this collection

  88. def last: A

    Selects the last element.

  89. def lastKey: A

    Returns the last key of the collection.

  90. def lastOption: Option[A]

    Optionally selects the last element.

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

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

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

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

  93. def max: A

    [use case] Finds the largest element.

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

    Finds the largest element.

  95. def min: A

    [use case] Finds the smallest element.

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

    Finds the smallest element.

  97. def mkString: String

    Displays all elements of this immutable tree set in a string.

  98. def mkString(sep: String): String

    Displays all elements of this immutable tree set in a string using a separator string.

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

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

  100. def ne(arg0: AnyRef): Boolean

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

  101. def newBuilder: Builder[A, TreeSet[A]]

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

  102. def nonEmpty: Boolean

    Tests whether the immutable tree set is not empty.

  103. def notify(): Unit

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

  104. def notifyAll(): Unit

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

  105. implicit val ordering: Ordering[A]

  106. def partition(p: (A) ⇒ Boolean): (TreeSet[A], TreeSet[A])

    Partitions this immutable tree set in two immutable tree sets according to a predicate.

  107. def product: Int

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

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

    Multiplies up the elements of this collection.

  109. def projection: IterableView[A, TreeSet[A]]

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

  110. def range(from: A, until: A): TreeSet[A]

    Creates a ranged projection of this collection with both a lower-bound and an upper-bound.

  111. def rangeImpl(from: Option[A], until: Option[A]): TreeSet[A]

    Creates a ranged projection of this collection.

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

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

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

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

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

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

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

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

  116. def repr: TreeSet[A]

    The collection of type immutable tree set underlying this TraversableLike object.

  117. def reversed: List[A]

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

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

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

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

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

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

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

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

  122. val size: Int

    The size of this immutable tree set.

  123. def slice(from: Int, until: Int): TreeSet[A]

    Selects an interval of elements.

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

  125. def sliding[B >: A](size: Int): Iterator[TreeSet[A]]

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

  126. def span(p: (A) ⇒ Boolean): (TreeSet[A], TreeSet[A])

    Splits this immutable tree set into a prefix/suffix pair according to a predicate.

  127. def splitAt(n: Int): (TreeSet[A], TreeSet[A])

    Splits this immutable tree set into two at a given position.

  128. def stringPrefix: String

    Defines the prefix of this object's toString representation.

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

    Tests whether this set is a subset of another set.

  130. def sum: Int

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

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

    Sums up the elements of this collection.

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

  133. def tail: TreeSet[A]

    Selects all elements except the first.

  134. def take(n: Int): TreeSet[A]

    Selects first n elements.

  135. def takeRight(n: Int): TreeSet[A]

    Selects last n elements.

  136. def takeWhile(p: (A) ⇒ Boolean): TreeSet[A]

    Takes longest prefix of elements that satisfy a predicate.

  137. def thisCollection: Iterable[A]

    The underlying collection seen as an instance of immutable.TreeSet.

  138. def to(to: A): TreeSet[A]

    Create a range projection of this collection with no lower-bound.

  139. def toArray: Array[A]

    [use case] Converts this immutable tree set to an array.

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

    Converts this immutable tree set to an array.

  141. def toBuffer[B >: A]: Buffer[B]

    Converts this immutable tree set to a mutable buffer.

  142. def toCollection(repr: TreeSet[A]): Iterable[A]

    A conversion from collections of type Repr to immutable.TreeSet objects.

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

    Converts this immutable tree set to an indexed sequence.

  144. def toIterable: Iterable[A]

    Converts this immutable tree set to an iterable collection.

  145. def toIterator: Iterator[A]

    Returns an Iterator over the elements in this immutable tree set.

  146. def toList: List[A]

    Converts this immutable tree set to a list.

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

    Converts this immutable tree set to a map.

  148. def toSeq: Seq[A]

    Converts this immutable tree set to a sequence.

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

    Converts this immutable tree set to a set.

  150. def toStream: Stream[A]

    Converts this immutable tree set to a stream.

  151. def toString(): String

    Converts this immutable tree set to a string.

  152. def toTraversable: Traversable[A]

    Converts this immutable tree set to an unspecified Traversable.

  153. def transpose[B](implicit asTraversable: (A) ⇒ Traversable[B]): Set[Set[B]]

    Transposes this immutable tree set of traversable collections into a immutable tree set of immutable tree sets.

  154. val tree: Tree[Unit]

  155. def union(that: Set[A]): TreeSet[A]

    Computes the union between of set and another set.

  156. def until(until: A): TreeSet[A]

    Creates a ranged projection of this collection with no lower-bound.

  157. def unzip[A1, A2](implicit asPair: (A) ⇒ (A1, A2)): (Set[A1], Set[A2])

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

  158. def view(from: Int, until: Int): IterableView[A, TreeSet[A]]

    Creates a non-strict view of a slice of this immutable tree set.

  159. def view: IterableView[A, TreeSet[A]]

    Creates a non-strict view of this immutable tree set.

  160. def wait(): Unit

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

  162. def wait(arg0: Long): Unit

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

    Creates a non-strict filter of this immutable tree set.

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

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

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

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

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

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

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

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

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

    [use case] Zips this immutable tree set with its indices.

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

    Zips this immutable tree set with its indices.

  170. def |(that: Set[A]): TreeSet[A]

    Computes the union between this set and another set.