envzn
0.8 · beta · not released

Library / Collections / Dictionaries / StringKeyedDictionary

CLASSIMPLEMENTS Dictionary<BinaryWord, V, H>

StringKeyedDictionary

A byte-keyed dictionary: linear-probe open-addressing over a STRUCT-OF-ARRAYS with BYTE-DENSE keys held in ONE FLAT binary[] pool, a byte-FNV hash, and a memcmp confirm. The STRING FAST TIER. Pure Envzn, zero-dep.

Fields 6

uint64 prime
uint64 h_mask
int64 count
int64 tombstones
int64 cap
uint64 mask

Constructors 1

INIT()

Methods 24

MODIFY METHOD insertSlice(REFERENCE binary[] buf, int64 off, int64 len, V value) RETURNS STATUS
modifies

Insert the key slice buf[off .. off+len) → value (value MOVEd in). New keys are interned into the flat pool. Replacing an existing key leaves count unchanged.

METHOD lookupFastSlice(REFERENCE binary[] buf, int64 off, int64 len) RETURNS boolean
reads

Comma-return lookup over a slice — boolean f, V v := d->lookupFastSlice(buf,off,len). No pipe-XOR tuple on the hot path.

METHOD lookupSlice(REFERENCE binary[] buf, int64 off, int64 len) RETURNS | V
reads
METHOD containsSlice(REFERENCE binary[] buf, int64 off, int64 len) RETURNS boolean
reads
MODIFY METHOD removeSlice(REFERENCE binary[] buf, int64 off, int64 len) RETURNS boolean
modifies
MODIFY METHOD insert(REFERENCE binary[] key, V value) RETURNS STATUS
modifies
METHOD lookupFast(REFERENCE binary[] key) RETURNS boolean
reads
METHOD lookup(REFERENCE binary[] key) RETURNS | V
reads
METHOD lookupRef(REFERENCE binary[] key) RETURNS | MUTABLE REFERENCE V
reads
METHOD contains(REFERENCE binary[] key) RETURNS boolean
reads
MODIFY METHOD remove(REFERENCE binary[] key) RETURNS boolean
modifies
METHOD isEmpty() RETURNS boolean
reads
METHOD size() RETURNS int64
reads
MODIFY METHOD clear() RETURNS void
modifies
MODIFY METHOD insert(BinaryWord key, V value) RETURNS STATUS
modifies
METHOD lookupFast(REFERENCE BinaryWord key) RETURNS boolean
reads

Dictionary.lookupFast — the interface-shaped (BinaryWord-keyed) peer of the binary[] slice form above. K is BinaryWord for this class, so this is the overload that satisfies the interface; the slice form stays for the zero-copy call sites that already hold a buffer and a range.

METHOD lookup(REFERENCE BinaryWord key) RETURNS | MUTABLE REFERENCE V
reads
METHOD contains(REFERENCE BinaryWord key) RETURNS boolean
reads
MODIFY METHOD remove(REFERENCE BinaryWord key) RETURNS | BinaryWord
modifies

The removed key is returned as a word over THIS dictionary's pool, and the pool outlives the slot — a tombstone does not reclaim the bytes — so the returned word stays readable until the next rehash compacts them.

METHOD iterator() RETURNS ReferenceIterator[BinaryWord]
reads

One BinaryWord per live key, borrowed from this dictionary's pool. Valid only while the dictionary is: the words point INTO its storage, and a rehash moves that storage.

METHOD keys() RETURNS LinkedList[BinaryWord]
reads

Every live key, as borrowed words. Same lifetime caveat as iterator().

MODIFY METHOD insertCopy(REFERENCE BinaryWord key, REFERENCE V value) RETURNS STATUS
modifies
METHOD clone() RETURNS Dictionary[BinaryWord, V, H]
reads

Returns the Dictionary INTERFACE, not the concrete class — the class is HIDDEN, so its name may appear only as a CREATE target, and this is the shape ProHashDictionary.clone() already had. The copy goes in through the interface's own insert, since insertSlice is this class's and not the interface's.

METHOD equals(REFERENCE Dictionary[BinaryWord, V, H] other) RETURNS boolean
reads

for Equatable Interface Dictionary is equal if all keys between the two dictionaries are equal Two dictionaries are equal when they hold the SAME ASSOCIATIONS: the same keys, each mapping to an EQUAL VALUE.

Not merely the same KEYSET. That would rank {a:1} equal to {a:2}, so two "equal" dictionaries would answer lookup(a) differently and neither could stand in for the other — which is the whole point of an equivalence. Keys-AND-values is what C++ (map and unordered_map), Rust, Swift, Julia, Python and Java all specify. Keyset equality is a perfectly good relation, but it is equality of the DOMAIN rather than of the dictionary, and it deserves its own name (hasSameKeys) rather than this one.

Equal sizes plus a one-way walk is sufficient: with the counts already equal, other cannot carry a key this one lacks unless this one also carries a key other lacks — and the walk would have found that.