std1.0.0-beta-7 SafeC docs

std :: collections::map

Struct std::HashMap

#include <std/collections/map.h> source

generic<K, V> struct HashMap {
    ?&heap K keys;
    ?&heap V vals;
    ?&heap unsigned int hashes;
    ?&heap unsigned char states;
    unsigned long cap;
    unsigned long len;
    unsigned long tombstones;
}

Fields

§?&heap K keyssource
§?&heap V valssource
§?&heap unsigned int hashessource
§?&heap unsigned char statessource

MAP_EMPTY_ / MAP_FULL_ / MAP_TOMB_

§unsigned long capsource

0 or a power of two

§unsigned long lensource

live entries

§unsigned long tombstonessource

removed slots not yet reclaimed

Methods

§static struct HashMap<K, V> new()source · definition

empty, no allocation

§static struct HashMap<K, V> with_cap(unsigned long cap)source · definition

room for cap entries

§int insert(K key, V val)source · definition

insert or overwrite; 0 on OOM

§?&V get(K key) constsource · definition

null if missing

§int contains(K key) constsource · definition
§?V remove(K key)source · definition

the removed value, or null

§unsigned long length() constsource · definition
§int is_empty() constsource · definition
§void clear()source · definition

drop every entry, keep the table

§void foreach(fn void(const &K, &V) func)source · definition
§int reserve(unsigned long n)source · definition

room for n entries without resizing

§void drop()source · definition
§void free() consumesource · definition

= drop()