class · System

Dictionary<K, V>

public class System.Dictionary<K, V> : System.Any
Kind
class
Namespace
System
Assembly
System.Core
Access
public
Source file
Dictionary.ant

Type parameters

NameConstraints
KSystem.IHashable<K>
Vany type

Inheritance

Base classes
Any Dictionary<K, V>

Constructors

constructor Dictionary()
#

Properties

property Count: i32
#

read-only

property IsEmpty: bool
#

read-only

property Slots: i32
#

read-only

Methods

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

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

method Get(key: K) -> V
#

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

method At(key: K) -> V
#

map[key].

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

map[key] = value.

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 Keys() -> System.List<K>
#

The keys, in the table's order.

method Iterator() -> System.DictionaryIterator<K, V>
#

loop (KeyValuePair<K, V> pair in map), in the table's order.

method Holds(slot: i32) -> bool
#

The slots (for the iterator).

method KeyAt(slot: i32) -> K
#
method ValueAt(slot: i32) -> V
#

Private and internal members (12)

field keys: K[]
#

private

field values: V[]
#

private

field tags: u32[]
#

private

Per slot: 0 empty, 2 removed (probing goes on past it), else (odd) the top bits of the key's mixed hash: probing compares them before it looks at a key, and resizing places pairs without hashing their keys again.

field count: i32
#

private

field used: i32
#

private

field bits: i32
#

private

The table has 2^bits slots.

static method Tag(hash: u64) -> u32
#

private static

A key's tag: the top 32 bits of its hash × 2^64/φ (Fibonacci hashing), made odd.

method Home(tag: u32) -> i32
#

private

The first slot to look at for a tag (its top bits).

method Find(key: K) -> i32
#

private

The slot holding key, or -1.

method Free(tag: u32) -> i32
#

private

A slot for a new pair with this tag (empty or removed).

method Resize(newBits: i32) -> void
#

private

Rebuilds the table with 2^newBits slots.

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

private

Adds a pair whose key is not in the table.

Inherited members (5)

Source

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

System.Dictionary.hir
public class System.Dictionary<K, V> : System.Any
{
    field keys: K[]
    field values: V[]
    // Per slot: 0 empty, 2 removed (probing goes on past it), else (odd) the top bits of the key's mixed hash: probing
    // compares them before it looks at a key, and resizing places pairs without hashing their keys again.
    field tags: u32[]
    field count: i32
    field used: i32
    // The table has 2^bits slots.
    field bits: i32
    // A key's tag: the top 32 bits of its hash × 2^64/φ (Fibonacci hashing), made odd.
    static method Tag(hash: u64) -> u32
    // The first slot to look at for a tag (its top bits).
    method Home(tag: u32) -> i32
    // The slot holding `key`, or -1.
    method Find(key: K) -> i32
    // A slot for a new pair with this tag (empty or removed).
    method Free(tag: u32) -> i32
    // Rebuilds the table with 2^newBits slots.
    method Resize(newBits: i32) -> void
    // Adds a pair whose key is not in the table.
    method Add(key: K, value: V, tag: u32) -> void
    constructor Dictionary()
    // Gives `key` the value `value` (adding it, or replacing its value).
    method Set(key: K, value: V) -> void
    // The value of `key`; a KeyNotFoundError when there is none.
    method Get(key: K) -> V
    // `map[key]`.
    method At(key: K) -> V
    // `map[key] = value`.
    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 keys, in the table's order.
    method Keys() -> System.List<K>
    // `loop (KeyValuePair<K, V> pair in map)`, in the table's order.
    method Iterator() -> System.DictionaryIterator<K, V>
    // The slots (for the iterator).
    method Holds(slot: i32) -> bool
    method KeyAt(slot: i32) -> K
    method ValueAt(slot: i32) -> V
    property Count: i32
    property IsEmpty: bool
    property Slots: i32
}
Esc