Constructors
TreeMapSource Codeshared TreeMap(Comparison compare(Key x, Key y), {<Key->Item>*} entries = ...)

Create a new TreeMap with the given comparator function and entries.

Parameters:
  • compare

    A comparator function used to sort the entries.

  • entries = {}

    The initial entries in the map.

copySource Codeshared copy(TreeMap<Key,Item> treeMap)

Create a new TreeMap with the same comparator function and entries as the given treeMap.

Attributes
firstSource Codeshared actual <Key->Item>? 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 <Key->Item>? 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.

sizeSource Codeshared actual Integer size

The number of elements returned by the iterator of this stream, if the iterator terminates. In the case of an infinite stream, this operation never terminates.

stringSource Codeshared actual String string

A developer-friendly string representing the instance. Concatenates the name of the concrete class of the instance with the hash of the instance. Subclasses are encouraged to refine this implementation to produce a more meaningful representation.

Refines Iterable.string ultimately refines Object.string
Inherited Attributes
Attributes inherited from: Object
Attributes inherited from: Collection<Element>
Attributes inherited from: Correspondence<Key,Item>
Attributes inherited from: Iterable<Element,Absent>
Attributes inherited from: Map<Key,Item>
Methods
ascendingEntriesSource Codeshared actual {<Key->Item>*} ascendingEntries(Key from, Key to)

The entries with keys 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 map.

assertInvariantsSource Codeshared void assertInvariants()
clearSource Codeshared actual void clear()

Remove every entry from this map, leaving an empty map with no entries.

cloneSource Codeshared actual TreeMap<Key,Item> 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 MutableMap.clone ultimately refines Collection.clone
containsSource Codeshared actual Boolean contains(Object entry)

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 Map.contains ultimately refines Category.contains
definesSource Codeshared actual Boolean defines(Object key)

Determines if there is a value defined for the given key.

Refines Map.defines ultimately refines Correspondence.defines
descendingEntriesSource Codeshared actual {<Key->Item>*} descendingEntries(Key from, Key to)

The entries with keys 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 map.

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
getSource Codeshared actual Item? get(Object key)

Returns the value defined for the given key, or null if there is no value defined for the given key.

Refines Map.get ultimately refines Correspondence.get
getOrDefaultSource Codeshared actual Item|Default getOrDefault<Default>(Object key, Default default)

Returns the item of the entry with the given key, or the given default if there is no entry with the given key in this map.

For maps with non-null items, the expression:

map.getOrDefault(key, def)

is equivalent to this common idiom:

map[key] else def

However, when the map has null items, getOrDefault() will preserve them.

Note that high-quality implementations of Map should refine this default implementation.

higherEntriesSource Codeshared actual {<Key->Item>*} higherEntries(Key key)

The entries with keys larger than or equal to the given key, sorted by key in ascending order.

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

iteratorSource Codeshared actual Iterator<Key->Item> iterator()

An iterator for the elements belonging to this stream.

lowerEntriesSource Codeshared actual {<Key->Item>*} lowerEntries(Key key)

The entries with keys smaller than or equal to the given key, sorted by key in descending order.

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

measureSource Codeshared actual TreeMap<Key,Item> measure(Key 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.

putSource Codeshared actual Item? put(Key key, Item item)

Add an entry to this map, overwriting any existing entry for the given key, and returning the previous value associated with the given key, if any, or null if no existing entry was overwritten.

Refines MutableMap.put ultimately refines MapMutator.put
removeSource Codeshared actual Item? remove(Key key)

Remove the entry associated with the given key, if any, from this map, returning the value no longer associated with the given key, if any, or null if there was no entry associated with the given key.

Refines MutableMap.remove ultimately refines MapMutator.remove
removeEntrySource Codeshared actual Boolean removeEntry(Key key, Item&Object item)

Remove the entry associated with the given key, if any, only if its item is equal to the given item. Return true if an entry was removed, or false otherwise.

replaceEntrySource Codeshared actual Boolean replaceEntry(Key key, Item&Object item, Item newItem)

Modify the entry associated with the given key, if any, setting its item to the given newItem, only if the its item is currently equal to the given item. Return true if the item was replaced,or false otherwise.

spanSource Codeshared actual TreeMap<Key,Item> span(Key from, Key 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 TreeMap<Key,Item> spanFrom(Key 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 TreeMap<Key,Item> spanTo(Key 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.

Inherited Methods
Methods inherited from: Object
Methods inherited from: Category<Element>
Methods inherited from: Collection<Element>
Methods inherited from: Correspondence<Key,Item>
Methods inherited from: Iterable<Element,Absent>
Methods inherited from: Map<Key,Item>
Methods inherited from: MapMutator<Key,Item>
Methods inherited from: MutableMap<Key,Item>
Methods inherited from: Ranged<Index,Element,Subrange>
Methods inherited from: SortedMap<Key,Item>