Java Reference
In-Depth Information
however, iteration only requires a time propertional to the size, regard-
less of capacity.
21.5.3.
treeSet
If you need a
SortedSet
, you can use
treeSet
, which stores its contents in
a tree structure that is kept balanced. This means that the time required
to modify or search the tree is .
treeSet
has four constructors:
public
treeSet()
Creates a new
treeSet
that is sorted according to the natural
order of the element types. All elements added to this set
must implement the
Comparable
interface and be mutually
comparable.
public
treeSet(Collection<? extends E> coll)
Equivalent to using
TReeSet()
and then adding the elements of
coll
.
public
treeSet(Comparator<? super E> comp)
Creates a new
treeSet
that is sorted according to the order
imposed by
comp
.
public
treeSet(SortedSet<E> set)
Creates a new
treeSet
whose initial contents will be the same
as those in
set
and that is sorted in the same way as
set
.