Constructors
TreeSetSource Codeshared TreeSet(Comparison compare(Element x, Element y), {Element*} elements = ...)

Create a new TreeSet with the given comparator function and elements.

Parameters:
  • compare

    A comparator function used to sort the elements.

  • elements = {}

    The initial elements of the set.

copySource Codeshared copy(TreeSet<Element> treeSet)

Create a new TreeMap with the same comparator function and elements as the given treeSet.

Attributes
firstSource Codeshared actual Element? first

The first element returned by the iterator, if any, or null if this stream is empty. For a stream with an unstable iteration order, a different value might be produced each time first is evaluated.

hashSource Codeshared actual Integer hash

The hash value of the value, which allows the value to be an element of a hash-based set or key of a hash-based map. Implementations must respect the constraint that:

  • if x==y then x.hash==y.hash.

Therefore, a class which refines equals must also refine hash.

Because the Integer type is platform-dependent a compiler for a given platform is permitted to further manipulate the calculated hash for an object, and the resulting hash may differ between platforms.

Refines Identifiable.hash ultimately refines Object.hash
lastSource Codeshared actual Element? last

The last element returned by the iterator, if any, or null if this stream is empty. In the case of an infinite stream, this operation never terminates; furthermore, this default implementation iterates all elements, which might be very expensive.

Inherited Attributes
Attributes inherited from: Object
Attributes inherited from: Collection<Element>
Attributes inherited from: Iterable<Element,Absent>
Attributes inherited from: Set<Element>
Methods
addSource Codeshared actual Boolean add(Element element)

Add the given element to this set, returning true if the element was not already a member of this set, or false otherwise.

ascendingElementsSource Codeshared actual {Element*} ascendingElements(Element from, Element to)

The elements larger than or equal to the first given value, and smaller than or equal to the second given value, sorted in ascending order.

This is a lazy operation, returning a view of the underlying sorted set.

clearSource Codeshared actual void clear()

Remove every element from this set, leaving an empty set with no elements.

cloneSource Codeshared actual TreeSet<Element> clone()

A shallow copy of this collection, that is, a collection with identical elements which does not change if this collection changes. If this collection is immutable, it is acceptable to return a reference to this collection. If this collection is mutable, a newly instantiated collection must be returned.

Refines MutableSet.clone ultimately refines Collection.clone
complementSource Codeshared actual HashSet<Element> complement<Other>(Set<Other> set)
given Other satisfies Object

Returns a new Set containing all the elements in this set that are not contained in the given Set.

For example:

set { "hello", "world" } ~ set { 1, 2, "hello" }

Produces the set { "world" } of type Set<String>.

containsSource Codeshared actual Boolean contains(Object element)

Returns true if the given value belongs to this Category, that is, if it is an element of this Category, or false otherwise.

For most Categorys the following relationship is satisfied by every pair of elements x and y:

  • if x==y, then x in category == y in category

However, it is possible to form a useful Category consistent with some other equivalence relation, for example ===. Therefore implementations of contains() which do not satisfy this relationship are tolerated.

Refines Set.contains ultimately refines Category.contains
descendingElementsSource Codeshared actual {Element*} descendingElements(Element from, Element to)

The elements smaller than or equal to the first given value, and larger than or equal to the second given value, sorted in descending order.

This is a lazy operation, returning a view of the underlying sorted set.

equalsSource Codeshared actual Boolean equals(Object that)

Determine if two values are equal. Implementations should respect the constraints that:

  • if x===y then x==y (reflexivity),
  • if x==y then y==x (symmetry),
  • if x==y and y==z then x==z (transitivity).

Furthermore it is recommended that implementations ensure that if x==y then x and y have the same concrete class.

A class which explicitly refines equals() is said to support value equality, and the equality operator == is considered much more meaningful for such classes than for a class which simply inherits the default implementation of identity equality from Identifiable.

Refines Identifiable.equals ultimately refines Object.equals
exclusiveUnionSource Codeshared actual HashSet<Element|Other> exclusiveUnion<Other>(Set<Other> set)
given Other satisfies Object

Returns a new Set containing only the elements contained in either this set or the given Set, but no element contained in both sets.

higherElementsSource Codeshared actual {Element*} higherElements(Element element)

The elements larger than or equal to the given value, sorted in ascending order.

This is a lazy operation, returning a view of the underlying sorted set.

intersectionSource Codeshared actual HashSet<Element&Other> intersection<Other>(Set<Other> set)
given Other satisfies Object

Returns a new Set containing only the elements that are present in both this set and the given Set and that are instances of the intersection Element&Other of the element types of the two sets.

For example:

set { "hello", "world" } & set { 1, 2, "hello" }

Produces the set { "hello" } of type Set<String>.

Note that, according to this definition, and even though 1==1.0 evaluates to true (Integer.equals), the expression

set { 1 } & set { 1.0 }

produces the empty set {}.

iteratorSource Codeshared actual Iterator<Element> iterator()

An iterator for the elements belonging to this stream.

lowerElementsSource Codeshared actual {Element*} lowerElements(Element element)

The elements smaller than or equal to the given value, sorted in descending order.

This is a lazy operation, returning a view of the underlying sorted set.

measureSource Codeshared actual TreeSet<Element> measure(Element from, Integer length)

Obtain a measure containing the mapped values starting from the given starting index (from), with the given length. If length<=0, the resulting measure is empty.

The measure should contain the given number (length) of elements of this stream, starting from the element at the given starting index (from), in the same order as they are produced by the iterator of the stream. In the case where the iterator would be exhausted before length elements are produced, the resulting measure contains only those elements which were produced before the iterator was exhausted, and the length of the measure is less then the given length.

When the given index does not belong to this ranged object, the behavior is implementation dependent.

removeSource Codeshared actual Boolean remove(Element element)

Remove an element from this set, returning true if the element was previously a member of the set.

spanSource Codeshared actual TreeSet<Element> span(Element from, Element to)

Obtain a span containing the elements between the two given indices.

The span should contain elements of this stream, starting from the element at the given starting index (from), and ending with the element at the given ending index (to), in the same order as they are produced by the iterator of the stream, except when the ending index occurs earlier than the starting index, in which case they occur in the opposite order.

When one or both of the given indices does not belong to this ranged stream, the behavior is implementation dependent.

Refines Ranged.span
spanFromSource Codeshared actual TreeSet<Element> spanFrom(Element from)

Obtain a span containing the elements between the given starting index (from) and the last index of this ranged object.

The span should contain elements of this stream, starting from the element at the given starting index (from), in the same order as they are produced by the iterator of the stream.

When the given index does not belong to this ranged stream, the behavior is implementation dependent.

spanToSource Codeshared actual TreeSet<Element> spanTo(Element to)

Obtain a span containing the elements between the first index of this ranged stream and given end index (to).

The span should contain elements of this stream, up to the element at the given ending index (to), in the same order as they are produced by the iterator of the stream.

When the given index does not belong to this ranged stream, the behavior is implementation dependent.

unionSource Codeshared actual HashSet<Element|Other> union<Other>(Set<Other> set)
given Other satisfies Object

Returns a new Set containing all the elements of this set and all the elements of the given Set.

For example:

set { "hello", "world" } | set { 1, 2, "hello" }

Produces the set { "hello", "world", 1, 2 } of type Set<String|Integer>.

Note that it is possible for two sets of disjoint element type to be considered to have elements in common. For example, since 1==1.0 evaluates to true (Integer.equals), the expression

set { 1 } | set { 1.0 }

produces the set { 1 }.

Refines Set.union
Inherited Methods
Methods inherited from: Object
Methods inherited from: Category<Element>
Methods inherited from: Collection<Element>
Methods inherited from: Iterable<Element,Absent>
Methods inherited from: MutableSet<Element>
Methods inherited from: Ranged<Index,Element,Subrange>
Methods inherited from: Set<Element>
Methods inherited from: SetMutator<Element>
Methods inherited from: SortedSet<Element>