StringMap API Reference

Hash table with string keys and i64 values (content-based comparison)

Import

U std/stringmap

Struct

S StringMap { buckets: i64, size: i64, cap: i64 }

Methods

MethodSignatureDescription
with_capacityF with_capacity(capacity: i64) -> StringMapCreate with capacity
lenF len(&self) -> i64Number of entries
capacityF capacity(&self) -> i64Get capacity
is_emptyF is_empty(&self) -> i64Check if empty
getF get(&self, key: i64) -> i64Get value by string key
get_optF get_opt(&self, key: i64) -> Option<i64>Get as Option
containsF contains(&self, key: i64) -> i64Check if key exists
setF set(&self, key: i64, value: i64) -> i64Insert/update
removeF remove(&self, key: i64) -> i64Remove key
clearF clear(&self) -> i64Remove all entries
dropF drop(&self) -> i64Free all memory

Overview

Unlike HashMap which uses integer key comparison, StringMap compares keys by string content using byte-by-byte comparison. Keys are duplicated on insert. Uses DJB2 hash from std/hash.

Usage

U std/stringmap

F main() -> i64 {
    m := StringMap.with_capacity(16)
    m.set("name", 42)
    val := m.get("name")  # 42
    m.drop()
    0
}