Skip to content
FutureBlitz

    Install

    Import std.collections.sorted

    std.collections.sorted

    SortedMap<K, V> and SortedSet<T>: keys in order, in a B-tree. Each node holds from Order - 1 to 2 * Order - 1 keys in order, but the root, which can hold fewer, and a node that isn't a leaf has a child before, between, and after its keys, which hold the keys between them. Finding, adding, and removing a key looks at about log(Count) nodes.

    std/collections/sorted.fb

    Types

    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.

    std/collections/sorted.fb, line 43

    • Public New() constructor #

      A new, empty SortedMap.

    • Public Property Count: Int property #

      How many entries it holds.

    • @PanicsAtCaller Public Method Add(key: K, value: V) method #

      Adds an entry, or gives an existing key its new value, which leaves the tree as it is. A key that isn't equal to itself, like NaN, panics.

    • Public Method Get(key: K): V? method #

      The key's value, or Null when it isn't there.

    • Public Method Get(key: K, fallback: V): V method #

      The key's value, or fallback when it isn't there.

    • @PanicsAtCaller Operator [](key: K): V operator #

      The key's value. A key that isn't there panics.

    • @PanicsAtCaller Operator []=(key: K, value: V) operator #

      Gives the key a value, adding it when it isn't there.

    • Public Method Contains(key: K): Bool method #

      Whether key has an entry.

    • Public Method Remove(key: K): Bool method #

      Removes the key's entry, and tells whether there was one. A key that isn't there leaves the tree as it is.

    • Public Method Clear() method #

      Takes every entry out.

    • Public Method First(): (K, V)? method #

      The smallest key and its value, or Null when there's none.

    • Public Method Last(): (K, V)? method #

      The largest key and its value, or Null when there's none.

    • Public Method Floor(key: K): (K, V)? method #

      The largest key that isn't above key, and its value, or Null when there's none, as for a key that isn't equal to itself.

    • Public Method Ceiling(key: K): (K, V)? method #

      The smallest key that isn't below key, and its value, or Null when there's none, as for a key that isn't equal to itself.

    • Public Method Range(low: K, high: K): (K, V)[] method #

      The entries from low up to high, without high itself, in order, in a new array. An end that isn't equal to itself finds none.

    • Public Method Keys(): K[] method #

      The keys, in order.

    • Public Method Values(): V[] method #

      The values, in their keys' order.

    • Public Static Method DefaultValue(): SortedMap<K, V> static method #

      A new, empty SortedMap.

    • Public Method Clone(): SortedMap<K, V> method #

      A new SortedMap with the same entries.

    • Public Method Iterate(): SortedMapIterator<K, V> method #

      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.

    SortedMapIterator struct

    Public Struct SortedMapIterator<K: Comparable, V> Implements Iterator<(K, V)>

    The entries in order: the node the next one is in, or Null at the end, where it's at among the node's keys, and the nodes on the way down to it.

    std/collections/sorted.fb, line 458

    SortedSet class

    @DebugElements Public Class SortedSet<T: Comparable> Implements Iterable<T>, Cloneable, Defaultable, Equatable

    Values without repeats, in order, which a SortedMap holds as its keys.

    std/collections/sorted.fb, line 535

    • Public New() constructor #

      A new, empty SortedSet.

    • Public Property Count: Int property #

      How many values it holds.

    • @PanicsAtCaller Public Method Add(value: T): Bool method #

      Adds the value, and tells whether it's new. A value that isn't equal to itself, like NaN, panics.

    • Public Method Remove(value: T): Bool method #

      Removes the value, and tells whether it was there.

    • Public Method Contains(value: T): Bool method #

      Whether it holds value.

    • Public Method Clear() method #

      Takes every value out.

    • Public Method First(): T? method #

      The smallest value, or Null when there's none.

    • Public Method Last(): T? method #

      The largest value, or Null when there's none.

    • Public Method Floor(value: T): T? method #

      The largest value that isn't above value, or Null when there's none.

    • Public Method Ceiling(value: T): T? method #

      The smallest value that isn't below value, or Null when there's none.

    • Public Method Range(low: T, high: T): T[] method #

      The values from low up to high, without high itself, in order, in a new array.

    • Public Method ToArray(): T[] method #

      The values, in order, in a new array.

    • Public Static Method DefaultValue(): SortedSet<T> static method #

      A new, empty SortedSet.

    • Public Method Clone(): SortedSet<T> method #

      A new SortedSet with the same values.

    • Operator ==(a: SortedSet<T>, b: SortedSet<T>): Bool operator #

      Two SortedSets are equal when they have the same values.

    • Public Method Iterate(): SortedSetIterator<T> method #

      The values, in order. Adding or removing one while going over them panics.

    SortedSetIterator struct

    Public Struct SortedSetIterator<T: Comparable> Implements Iterator<T>

    The values of a SortedSet, smallest first, which For ... In goes over.

    std/collections/sorted.fb, line 615

    Extends

    SortedMap extend

    Extend SortedMap<K, V> Implements Equatable

    No doc comment.

    std/collections/sorted.fb, line 506

    SortedMap extend

    Extend SortedMap<K, V> Implements Printable

    No doc comment.

    std/collections/sorted.fb, line 521

    SortedSet extend

    Extend SortedSet<T> Implements Printable

    No doc comment.

    std/collections/sorted.fb, line 627

    Report an issue with this page or with FutureBlitz on GitHub.