Map Library (Map)
Linked to the map type. Maps stay ordered by key, which is why first/last/at are meaningful, not just get/insert.
Query
Map.len(this: map) -> int
map-len.stof
#[main]
fn main() {
const m = {"a": 1, "b": 2};
pln(m.len());
}Output
Map.empty(this: map) -> bool
map-empty.stof
#[main]
fn main() {
const m = map();
pln(m.empty());
}Output
Map.any(this: map) -> bool
map-any.stof
#[main]
fn main() {
const m = map();
pln(m.any());
}Output
Map.contains(this: map, key: unknown) -> bool
map-contains.stof
#[main]
fn main() {
const m = {"a": 1};
pln(m.contains("a"));
}Output
Map.keys(this: map) -> set
map-keys.stof
#[main]
fn main() {
const m = {"a": 1, "b": 2};
pln(str(m.keys()));
}Output
Map.values(this: map) -> list
map-values.stof
#[main]
fn main() {
const m = {"a": 1, "b": 2};
pln(m.values());
}Output
Access
Map.get(this: map, key: unknown) -> unknown
map-get.stof
#[main]
fn main() {
const m = {"a": 1};
pln(m.get("a"));
}Output
Map.at(this: map, index: int) -> (unknown, unknown)
The (key, value) pair at a position in sorted order — not a lookup by key.
map-at.stof
#[main]
fn main() {
const m = {"a": 1, "b": 2};
pln(m.at(1));
}Output
Map.first(this: map) -> (unknown, unknown)
map-first.stof
#[main]
fn main() {
const m = {"a": 1};
pln(m.first());
}Output
Map.last(this: map) -> (unknown, unknown)
map-last.stof
#[main]
fn main() {
const m = {"a": 1, "b": 3};
pln(m.last());
}Output
Modify
Map.insert(this: map, key: unknown, value: unknown) -> unknown
Returns the old value if the key already existed, null otherwise.
map-insert.stof
#[main]
fn main() {
const m = {"a": 1};
pln(m.insert("a", 3), str(m));
}Output
Map.remove(this: map, key: unknown) -> unknown
map-remove.stof
#[main]
fn main() {
const m = {"a": 1, "b": 2};
pln(m.remove("b"), str(m));
}Output
Map.pop_first(this: map) -> (unknown, unknown)
map-pop-first.stof
#[main]
fn main() {
const m = {"a": 1, "b": 2};
pln(m.pop_first(), str(m));
}Output
Map.pop_last(this: map) -> (unknown, unknown)
map-pop-last.stof
#[main]
fn main() {
const m = {"a": 1, "b": 2};
pln(m.pop_last(), str(m));
}Output
Map.append(this: map, other: map) -> void
map-append.stof
#[main]
fn main() {
const m = {"a": 1};
m.append({"b": 2});
pln(str(m));
}Output
Map.clear(this: map) -> void
map-clear.stof
#[main]
fn main() {
const m = {"a": 1};
m.clear();
pln(m.empty());
}Output