class · System

SortedDictionary<K, V>

public class System.SortedDictionary<K, V> : System.Any

A map from keys to values kept in key order: Set, Get, map[key], TryGet, ContainsKey, Remove, MinKey, MaxKey, and loop (KeyValuePair<K, V> pair in map) from the smallest key.

Kind
class
Namespace
System
Assembly
System.Core
Access
public
Source file
Sorted.ant

Type parameters

NameConstraints
KSystem.IComparable<K>
Vany type

Inheritance

Base classes
Any SortedDictionary<K, V>

Constructors

constructor SortedDictionary()
#

Properties

property Count: i32
#

read-only

property IsEmpty: bool
#

read-only

property Root: i32
#

read-only

The tree (for the iterator).

Methods

method Set(key: K, value: V) -> void
#

Gives key the value value (adding it, or replacing its value).

method Add(key: K, value: V) -> void
#

Adds key; an ArgumentError when it is there already.

method Get(key: K) -> V
#

The value of key; a KeyNotFoundError when there is none.

method At(key: K) -> V
#
method SetAt(key: K, value: V) -> void
#
method TryGet(key: K, fallback: V) -> V
#

The value of key, or fallback when there is none.

method ContainsKey(key: K) -> bool
#
method Remove(key: K) -> bool
#

Takes key out; false when it was not there.

method Clear() -> void
#
method MinKey() -> K
#

The smallest and largest keys (an InvalidOperationError when the map is empty).

method MaxKey() -> K
#
method Keys() -> System.List<K>
#

The keys and the values, in key order.

method Values() -> System.List<V>
#
method Iterator() -> System.SortedIterator<K, V>
#
method LeftOf(n: i32) -> i32
#
method RightOf(n: i32) -> i32
#
method KeyAt(n: i32) -> K
#
method ValueAt(n: i32) -> V
#

Private and internal members (25)

field keys: K[]
#

private

field values: V[]
#

private

field left: i32[]
#

private

field height: i32[]
#

private

field root: i32
#

private

field count: i32
#

private

field used: i32
#

private

The next node never used; removed nodes are reused first (a list through left).

field free: i32
#

private

field changed: bool
#

private

What the last insertion or removal did, and whether the heights above still need fixing (once a subtree keeps its height, nothing above it changes).

field reshape: bool
#

private

method Grow() -> void
#

private

method Node(key: K, value: V) -> i32
#

private

method Release(n: i32) -> void
#

private

method Fix(n: i32) -> void
#

private

method RotateRight(n: i32) -> i32
#

private

method RotateLeft(n: i32) -> i32
#

private

method Balance(n: i32) -> i32
#

private

The subtree at n with its heights fixed and, when one side grew two taller, rotated back into balance.

method Insert(n: i32, key: K, value: V, replace: bool) -> i32
#

private

Puts key → value under n (replacing a value when replace); the subtree's new root.

method Delete(n: i32, key: K) -> i32
#

private

Takes key out from under n; the subtree's new root.

method Rebalanced(n: i32) -> i32
#

private

n after a change below it: rebalanced while the change still moves heights (then nothing above moves).

method DeleteSmallest(n: i32) -> i32
#

private

method Find(key: K) -> i32
#

private

static method Missing() -> void
#

private static

static method Empty() -> void
#

private static

Inherited members (5)

Source

SortedDictionary<K, V> as Larva HIR, decompiled from its Larva HIR.

System.SortedDictionary.hir
// A map from keys to values kept in key order: Set, Get, `map[key]`, TryGet, ContainsKey, Remove, MinKey, MaxKey,
// and `loop (KeyValuePair<K, V> pair in map)` from the smallest key.
public class System.SortedDictionary<K, V> : System.Any
{
    field keys: K[]
    field values: V[]
    field left: i32[]
    field right: i32[]
    field height: i32[]
    field root: i32
    field count: i32
    // The next node never used; removed nodes are reused first (a list through `left`).
    field used: i32
    field free: i32
    // What the last insertion or removal did, and whether the heights above still need fixing (once a subtree keeps
    // its height, nothing above it changes).
    field changed: bool
    field reshape: bool
    method Grow() -> void
    method Node(key: K, value: V) -> i32
    method Release(n: i32) -> void
    method Fix(n: i32) -> void
    method RotateRight(n: i32) -> i32
    method RotateLeft(n: i32) -> i32
    // The subtree at n with its heights fixed and, when one side grew two taller, rotated back into balance.
    method Balance(n: i32) -> i32
    // Puts key → value under n (replacing a value when `replace`); the subtree's new root.
    method Insert(n: i32, key: K, value: V, replace: bool) -> i32
    // Takes key out from under n; the subtree's new root.
    method Delete(n: i32, key: K) -> i32
    // n after a change below it: rebalanced while the change still moves heights (then nothing above moves).
    method Rebalanced(n: i32) -> i32
    method DeleteSmallest(n: i32) -> i32
    method Find(key: K) -> i32
    static method Missing() -> void
    static method Empty() -> void
    constructor SortedDictionary()
    // Gives `key` the value `value` (adding it, or replacing its value).
    method Set(key: K, value: V) -> void
    // Adds `key`; an ArgumentError when it is there already.
    method Add(key: K, value: V) -> void
    // The value of `key`; a KeyNotFoundError when there is none.
    method Get(key: K) -> V
    method At(key: K) -> V
    method SetAt(key: K, value: V) -> void
    // The value of `key`, or `fallback` when there is none.
    method TryGet(key: K, fallback: V) -> V
    method ContainsKey(key: K) -> bool
    // Takes `key` out; false when it was not there.
    method Remove(key: K) -> bool
    method Clear() -> void
    // The smallest and largest keys (an InvalidOperationError when the map is empty).
    method MinKey() -> K
    method MaxKey() -> K
    // The keys and the values, in key order.
    method Keys() -> System.List<K>
    method Values() -> System.List<V>
    method Iterator() -> System.SortedIterator<K, V>
    method LeftOf(n: i32) -> i32
    method RightOf(n: i32) -> i32
    method KeyAt(n: i32) -> K
    method ValueAt(n: i32) -> V
    property Count: i32
    property IsEmpty: bool
    // The tree (for the iterator).
    property Root: i32
}
Esc