Map¶
Import: import system.collections;
Read the usage guide for examples and common tasks. This reference lists the public declarations for this part of the library. See Reading API signatures for parameter and result notation.
Map¶
A generic open-addressing hash map. Slots are packed {key, value, state} records.
constructor¶
Creates an empty map, reserving space based on capacity (8 by default).
reserve¶
Reserves additional live entries, accounting for load factor and reclaiming tombstones.
length¶
Number of elements currently stored.
capacity¶
Number of elements that fit before storage must grow.
this¶
The first probe hits an empty or matching slot on the usual insert. That case stays in the caller; collisions fall through to the full probe.
contains¶
Returns whether key is present.
set_all¶
Inserts corresponding entries from keys and values; the arrays must have equal lengths.
constructor¶
Creates a map by pairing keys and values up to the shorter array length; later duplicate keys replace earlier values.
get¶
Value for key, or None when absent.
get¶
Value for the string key equal to key, without building a string.
contains¶
Returns whether key is present.
this¶
Value for key. Panics when the key is absent — this is what m[k] compiles to; use get(k) for absence-tolerant reads.
get_or_insert¶
Returns the existing value, or inserts and returns the result of factory when absent. The key is borrowed for the lookup and copied only on a miss.
merge¶
Copies entries from other, replacing values with matching keys.
entries¶
Returns a new list of key/value pairs.
remove¶
Removes key and its value; returns whether the key was present.
is_empty¶
Returns whether there are no elements.
clear¶
Removes all entries while keeping storage for reuse.
clear¶
Removes all entries while keeping storage for reuse.
keys¶
Returns a new list of the keys, in the map's iteration order.
values¶
Returns a new list of the values, in the map's iteration order.
iterator¶
Creates a cursor over the sequence. Close it when iteration ends early.
to_string¶
Returns a text representation of this value.