scala.collection.immutable

class TreeSet

[source: scala/collection/immutable/TreeSet.scala]

@serializable

@SerialVersionUID(-234066569443569402L)

class TreeSet[A](val override size : Int, t : Tree[Unit], val implicit ordering : Ordering[A])
extends RedBlack[A] with SortedSet[A] with SortedSetLike[A, TreeSet[A]]
This class implements immutable sets using a tree.
Author
Martin Odersky
Version
2.0, 02/01/2007
Since
1
Additional Constructor Summary
def this ()(implicit ordering : Ordering[A]) : TreeSet[A]
Value Summary
protected val tree : Tree[Unit]
Method Summary
def + (elem : A) : TreeSet[A]
A new TreeSet with the entry added is returned,
def - (elem : A) : TreeSet[A]
Creates a new set with given element removed from this set, unless the element is not present.
def contains (elem : A) : Boolean
Checks if this set contains element elem.
override def empty : TreeSet[A]
A factory to create empty sets of the same type of keys.
override def firstKey : A
Returns the first key of the collection.
override def foreach [U](f : (A) => U) : Unit
Apply a function f to all elements of this iterable object.
def insert (elem : A) : TreeSet[A]
A new TreeSet with the entry added is returned, assuming that elem is not in the TreeSet.
def isSmaller (x : A, y : A) : Boolean
def iterator : Iterator[A]
Creates a new iterator over all elements contained in this object.
override def lastKey : A
Returns the last key of the collection.
override def rangeImpl (from : Option[A], until : Option[A]) : TreeSet[A]
Creates a ranged projection of this collection. Any mutations in the ranged projection will update this collection and vice versa. Note: keys are not garuanteed to be consistent between this collection and the projection. This is the case for buffers where indexing is relative to the projection.
override def stringPrefix : java.lang.String
Defines the prefix of this object's toString representation.
override def toStream : Stream[A]
Returns a stream with all elements in this iterable object.
Methods inherited from SortedSetLike
keySet, from, until, range, subsetOf
Methods inherited from Sorted
compare, to, hasAll
Methods inherited from Set
companion
Methods inherited from SetLike
newBuilder, isEmpty, apply, intersect, &, **, union, |, diff, &~, toString, hashCode, equals
Methods inherited from Subtractable
-, --, --
Methods inherited from Addable
+, ++, ++
Methods inherited from Function1
compose, andThen
Methods inherited from IterableLike
thisCollection, toCollection, elements, forall, exists, find, foldRight, reduceRight, toIterable, head, take, slice, takeWhile, takeRight, dropRight, copyToArray, zip, zipAll, zipWithIndex, sameElements, canEqual, view, view, first, firstOption, projection
Methods inherited from GenericTraversableTemplate
genericBuilder, unzip, flatten, transpose
Methods inherited from TraversableLike
repr, nonEmpty, hasDefiniteSize, ++, ++, map, flatMap, filter, filterNot, partialMap, remove, partition, groupBy, count, foldLeft, /:, :\, reduceLeft, reduceLeftOption, reduceRightOption, sum, product, min, max, headOption, tail, last, lastOption, init, drop, dropWhile, span, splitAt, copyToBuffer, copyToArray, toArray, toList, toSeq, toIndexedSeq, toSet, mkString, mkString, mkString, addString, addString, addString, withFilter
Methods inherited from AnyRef
getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Additional Constructor Details
def this()(implicit ordering : Ordering[A]) : TreeSet[A]

Value Details
protected val tree : Tree[Unit]

Method Details
override def stringPrefix : java.lang.String
Defines the prefix of this object's toString representation.

def isSmaller(x : A, y : A) : Boolean
Overrides
RedBlack.isSmaller

override def empty : TreeSet[A]
A factory to create empty sets of the same type of keys.
Overrides
SortedSet.empty

def +(elem : A) : TreeSet[A]
A new TreeSet with the entry added is returned,

def insert(elem : A) : TreeSet[A]
A new TreeSet with the entry added is returned, assuming that elem is not in the TreeSet.

def -(elem : A) : TreeSet[A]
Creates a new set with given element removed from this set, unless the element is not present.
Parameters
elem - the element to be removed

def contains(elem : A) : Boolean
Checks if this set contains element elem.
Parameters
elem - the element to check for membership.
Returns
true, iff elem is contained in this set.

def iterator : Iterator[A]
Creates a new iterator over all elements contained in this object.
Returns
the new iterator

override def toStream : Stream[A]
Returns a stream with all elements in this iterable object.

override def foreach[U](f : (A) => U) : Unit
Apply a function f to all elements of this iterable object.
Parameters
f - A function that is applied for its side-effect to every element. The result (of arbitrary type U) of function `f` is discarded.
Notes
This method underlies the implementation of most other bulk operations. Implementing `foreach` with `iterator` is often suboptimal. So `foreach` should be overridden in concrete collection classes if a more efficient implementation is available.

override def rangeImpl(from : Option[A], until : Option[A]) : TreeSet[A]
Creates a ranged projection of this collection. Any mutations in the ranged projection will update this collection and vice versa. Note: keys are not garuanteed to be consistent between this collection and the projection. This is the case for buffers where indexing is relative to the projection.
Parameters
from - The lower-bound (inclusive) of the ranged projection. None if there is no lower bound.
until - The upper-bound (exclusive) of the ranged projection. None if there is no upper bound.
Overrides
SortedSetLike.rangeImpl

override def firstKey : A
Returns the first key of the collection.
Overrides
SortedSetLike.firstKey

override def lastKey : A
Returns the last key of the collection.
Overrides
SortedSetLike.lastKey