← all modules
module

stdlib::hashmap

defined in C:\Users\bye45\.glide\bin/src/stdlib/hashmap.glide

A hash map from `string` keys to `V` values.

struct struct HashMap

A hash map from string keys to V values.

Implemented with open addressing and linear probing on a power-of-two table. Resizes automatically when the load factor reaches 75%. Keys are stored by value so the caller's strings can be freed independently.

All operations except resize are amortised O(1). Resize is O(n).

glide
let m: *HashMap<int> = HashMap::new();
defer m.free();

m.insert("one", 1);
m.insert("two", 2);

if m.contains("one") {
    println!("one ->", m.get("one"));   // 1
}

m.remove("one");
println!("len:", m.len());              // 1