shadow:utility

Class TreeSet<V>

Parent class

shadow:standard@Object

Interfaces

shadow:utility@OrderedSet<V>

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.

See Also

Create Summary

Modifiers Return Types Method and Description
public () create()

Creates an empty TreeSet<V>.

Destroy Summary

Modifiers Return Types Method and Description
public () destroy()

Method Summary

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 String representation of the ordered set, listing all the objects in order.

public readonly (ArrayDeque<V>) values(V low, V high)

Returns a deque containing all the objects in the ordered set in the given range.

Property Summary

Modifiers Return Types Method and Description
public readonly get (int) size()

Gets the number of objects in the ordered set as an int.

public readonly get (long) sizeLong()

Gets the number of objects in the ordered set as a long.

Create Detail

create

public create() => ()

Creates an empty TreeSet<V>.

Destroy Detail

destroy

public destroy() => ()

Method Detail

add

public add(V value) => (boolean)

Adds an object to the ordered set. This operation runs in logarithmic time.

Parameters

value - object to be added

Returns

true if added to the ordered set, false if already present

ceiling

public readonly ceiling(V object) => (nullable V)

Returns the smallest object in the ordered set greater than or equal to the given object.

Parameters

object - object to compare against

Returns

smallest object in the ordered set less than or equal to object

clear

public clear() => (TreeSet<V>)

Removes all objects from the ordered set and resets the capacity to default.

Returns

ordered set after being cleared

contains

public readonly contains(V value) => (boolean)

Checks to see if the ordered set contains the specified object. This operation runs in logarithmic time.

Parameters

value - object to look for

Returns

true if object is present

copy

public readonly copy(AddressMap addresses) => (TreeSet<V>)

floor

public readonly floor(V object) => (nullable V)

Returns the largest object in the ordered set less than or equal to the given object.

Parameters

object - object to compare against

Returns

largest object in the ordered set less than or equal to object

index

public readonly index(V value) => (boolean)

Checks to see if the object is present in the ordered set. This operation runs in logarithmic time.

Parameters

value - object to search for

Returns

true if the object is present

index

public index(V value, boolean add) => ()

Adds or removes an object to or from the ordered set. This operation runs in logarithmic time.

Parameters

value - object to be added or removed

add - add object if true, remove if false

isEmpty

public readonly isEmpty() => (boolean)

Checks whether or not the ordered set is empty.

Returns

true if the ordered set is empty

iterator

public readonly iterator() => (Iterator<V>)

Creates an iterator to iterate over all the objects in the ordered set.

Returns

iterator

max

public readonly max() => (V)

Returns the largest object in the ordered set.

Returns

largest object

Throws

NoSuchElementException - if the ordered set is empty

min

public readonly min() => (V)

Returns the smallest object in the ordered set.

Returns

smallest object

Throws

NoSuchElementException - if the ordered set is empty

remove

public remove(V value) => (boolean)

Removes an object from the ordered set. This operation runs in logarithmic time.

Parameters

value - object to be removed

Returns

true if successfully removed, false if not present

toString

public readonly toString() => (String)

Produces a String representation of the ordered set, listing all the objects in order.

Returns

String representation

values

public readonly values(V low, V high) => (ArrayDeque<V>)

Returns a deque containing all the objects in the ordered set in the given range.

Parameters

low - lowest possible object in the range

high - highest possible object in the range

Returns

deque containing all objects between low (inclusive) and high (inclusive)

Property Detail

size

public readonly get size() => (int)

Gets the number of objects in the ordered set as an int.

Returns

size of ordered set

sizeLong

public readonly get sizeLong() => (long)

Gets the number of objects in the ordered set as a long.

Returns

size of ordered set