Import std.collections.sorted
SortedMap
class
@DebugEntries Public Class SortedMap<K: Comparable, V> Implements Iterable<(K, V)>, Cloneable, Defaultable
A Map that keeps its keys in order, smallest first, for ranges and the nearest key to another.
Examples
Local grades = SortedMap<Int, String>()
grades.Add(90, "A")
grades.Add(70, "C")
grades.Add(80, "B")
Expect(grades.Keys() == [70, 80, 90])
Expect(grades.Floor(85) == (80, "B"))
Expect(grades.Ceiling(85) == (90, "A"))
Expect(grades.Range(70, 90) == [(70, "C"), (80, "B")])std/collections/sorted.fb, line 58
-
A new, empty SortedMap.
-
How many entries it holds.
-
Adds an entry, or gives an existing
keyits new value, which leaves the tree as it is. A key that isn't equal to itself, like NaN, panics. -
The
key's value, or Null when it isn't there. -
The
key's value, orfallbackwhen it isn't there. -
The key's value. A key that isn't there panics.
-
Gives the key a value, adding it when it isn't there.
-
Whether
keyhas an entry. -
Removes the
key's entry, and tells whether there was one. A key that isn't there leaves the tree as it is. -
Takes every entry out.
-
The smallest key and its value, or Null when there's none.
-
The largest key and its value, or Null when there's none.
-
The largest
keythat isn't abovekey, and its value, or Null when there's none, as for akeythat isn't equal to itself. -
The smallest
keythat isn't belowkey, and its value, or Null when there's none, as for akeythat isn't equal to itself. -
The entries from
lowup tohigh, withouthighitself, in order, in a new array. An end that isn't equal to itself finds none. -
The keys, in order.
-
The values, in their keys' order.
-
A new, empty SortedMap.
-
A new SortedMap with the same entries.
-
Each key and its value, in order, for 'For key, value In map'. Giving a key a new value while going over them is fine, but adding or removing one panics.
Report an issue with this page or with FutureBlitz on GitHub.