A Set of objects that can be ordered relative to each other.
A Set of objects that can be ordered relative to each other.
The set is based on a self-balancing binary tree. It allows most operations in amortized logarithmic time.
Elements of the set are compared using the compare
function passed in
the constructor, both for ordering and for equality.
If the set contains only an object a
, then set.contains(b)
will return true
if and only if compare(a, b) == 0
,
and the value of a == b
is not even checked.
If the compare function is omitted, the objects are assumed to be
Comparable, and are compared using their Comparable.compareTo method.
Non-comparable objects (including null
) will not work as an element
in that case.