class TreeSet<V is CanCompare<V>>
Class TreeSet<V>
stores an ordered set, an ordered collection of objects of type V
with no repetitions. Internally, this ordered set is implemented with a balanced binary search tree mapping objects of type V
to themselves. This implementation allows objects to be added, found, and deleted in logarithmic time. TreeSet<V>
requires that type V
has the CanCompare<V>
interface, imposing an ordering on the objects. If ordering of objects is not required, the HashSet<V>
class may provide a faster implementation of a set.
Modifiers | Return Types | Method and Description |
---|---|---|
public |
() |
create() Creates an empty |
Modifiers | Return Types | Method and Description |
---|---|---|
public |
() |
destroy() |
Modifiers | Return Types | Method and Description |
---|---|---|
public |
(boolean) |
add(V value) Adds an object to the ordered set. |
public readonly |
(nullable V) |
ceiling(V object) Returns the smallest object in the ordered set greater than or equal to the given object. |
public |
(TreeSet<V>) |
clear() Removes all objects from the ordered set and resets the capacity to default. |
public readonly |
(boolean) |
contains(V value) Checks to see if the ordered set contains the specified object. |
public readonly |
(TreeSet<V>) |
copy(AddressMap addresses) |
public readonly |
(nullable V) |
floor(V object) Returns the largest object in the ordered set less than or equal to the given object. |
public readonly |
(boolean) |
index(V value) Checks to see if the object is present in the ordered set. |
public |
() |
index(V value, boolean add) Adds or removes an object to or from the ordered set. |
public readonly |
(boolean) |
isEmpty() Checks whether or not the ordered set is empty. |
public readonly |
(Iterator<V>) |
iterator() Creates an iterator to iterate over all the objects in the ordered set. |
public readonly |
(V) |
max() Returns the largest object in the ordered set. |
public readonly |
(V) |
min() Returns the smallest object in the ordered set. |
public |
(boolean) |
remove(V value) Removes an object from the ordered set. |
public readonly |
(String) |
toString() Produces a |
public readonly |
(ArrayDeque<V>) |
values(V low, V high) Returns a deque containing all the objects in the ordered set in the given range. |
Modifiers | Return Types | Method and Description |
---|---|---|
public readonly get |
(int) |
size() Gets the number of objects in the ordered set as an |
public readonly get |
(long) |
sizeLong() Gets the number of objects in the ordered set as a |
public create() => ()
Creates an empty TreeSet<V>
.
public destroy() => ()
public add(V value) => (boolean)
Adds an object to the ordered set. This operation runs in logarithmic time.
value
- object to be added
true
if added to the ordered set, false
if already present
public readonly ceiling(V object) => (nullable V)
Returns the smallest object in the ordered set greater than or equal to the given object.
object
- object to compare against
smallest object in the ordered set less than or equal to object
public clear() => (TreeSet<V>)
Removes all objects from the ordered set and resets the capacity to default.
ordered set after being cleared
public readonly contains(V value) => (boolean)
Checks to see if the ordered set contains the specified object. This operation runs in logarithmic time.
value
- object to look for
true
if object is present
public readonly copy(AddressMap addresses) => (TreeSet<V>)
public readonly floor(V object) => (nullable V)
Returns the largest object in the ordered set less than or equal to the given object.
object
- object to compare against
largest object in the ordered set less than or equal to object
public readonly index(V value) => (boolean)
Checks to see if the object is present in the ordered set. This operation runs in logarithmic time.
value
- object to search for
true
if the object is present
public index(V value, boolean add) => ()
Adds or removes an object to or from the ordered set. This operation runs in logarithmic time.
value
- object to be added or removed
add
- add object if true
, remove if false
public readonly isEmpty() => (boolean)
Checks whether or not the ordered set is empty.
true
if the ordered set is empty
public readonly iterator() => (Iterator<V>)
Creates an iterator to iterate over all the objects in the ordered set.
iterator
public readonly max() => (V)
Returns the largest object in the ordered set.
largest object
NoSuchElementException
- if the ordered set is empty
public readonly min() => (V)
Returns the smallest object in the ordered set.
smallest object
NoSuchElementException
- if the ordered set is empty
public remove(V value) => (boolean)
Removes an object from the ordered set. This operation runs in logarithmic time.
value
- object to be removed
true
if successfully removed, false
if not present
public readonly toString() => (String)
Produces a String
representation of the ordered set, listing all the objects in order.
String
representation
public readonly values(V low, V high) => (ArrayDeque<V>)
Returns a deque containing all the objects in the ordered set in the given range.
low
- lowest possible object in the range
high
- highest possible object in the range
deque containing all objects between low
(inclusive) and high
(inclusive)