Map
Source: std/map.mw.
LinearMap scans linearly and is meant for tiny maps; HashMap is a chained hash map.
LinearMapEntry
Section titled “LinearMapEntry”struct LinearMapEntry { key: *String; value: rawptr;}LinearMap
Section titled “LinearMap”struct LinearMap { entries: *VecPtr; // Stocke des *LinearMapEntry}HashNode
Section titled “HashNode”struct HashNode { key: *String; value: rawptr; hash: i64; next: *HashNode;}HashMap
Section titled “HashMap”struct HashMap { buckets: *VecPtr; capacity: i64; count: i64;}Functions
Section titled “Functions”linear_map_new
Section titled “linear_map_new”fn linear_map_new(initial_cap: i64) -> ^LinearMaplinear_map_put
Section titled “linear_map_put”fn linear_map_put(map: *LinearMap, key: *String, value: rawptr)linear_map_get
Section titled “linear_map_get”fn linear_map_get(map: *LinearMap, key: *String) -> rawptrlinear_map_free
Section titled “linear_map_free”fn linear_map_free(map: ^LinearMap)fn linear_map_destroy(map: *LinearMap)The map owns its entries: a ^LinearMap frees them when dropped. Keys and values are left to the caller.
hash_djb2
Section titled “hash_djb2”fn hash_djb2(s: *String) -> i64hash_map_new
Section titled “hash_map_new”fn hash_map_new(capacity: i64) -> ^HashMaphash_map_grow
Section titled “hash_map_grow”fn hash_map_grow(map: *HashMap)Doubles the number of buckets and relinks every node.
hash_map_put
Section titled “hash_map_put”fn hash_map_put(map: *HashMap, key: *String, value: rawptr)hash_map_get
Section titled “hash_map_get”fn hash_map_get(map: *HashMap, key: *String) -> rawptrhash_map_contains
Section titled “hash_map_contains”fn hash_map_contains(map: *HashMap, key: *String) -> boolhash_map_len
Section titled “hash_map_len”fn hash_map_len(map: *HashMap) -> i64hash_map_remove
Section titled “hash_map_remove”fn hash_map_remove(map: *HashMap, key: *String) -> rawptrRemoves key and returns its value (0 when absent). The key string itself is not freed.
hash_map_keys
Section titled “hash_map_keys”fn hash_map_keys(map: *HashMap) -> *VecPtrKeys as a vector of *String (the keys are shared, not copied).
hash_map_free
Section titled “hash_map_free”fn hash_map_free(map: ^HashMap)fn hash_map_destroy(map: *HashMap)Frees the map and its nodes; keys and values are left to the caller. A ^HashMap does it by itself when it goes out of scope; hash_map_destroy is for a map held by a plain pointer.