Library / Collections / Dictionaries / StringKeyedDictionary
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 primeuint64 h_maskint64 countint64 tombstonesint64 capuint64 maskConstructors 1
INIT()Methods 24
MODIFY METHOD insertSlice(REFERENCE binary[] buf, int64 off, int64 len, V value) RETURNS STATUSmodifies
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 booleanreads
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 | Vreads
METHOD containsSlice(REFERENCE binary[] buf, int64 off, int64 len) RETURNS booleanreads
MODIFY METHOD removeSlice(REFERENCE binary[] buf, int64 off, int64 len) RETURNS booleanmodifies
MODIFY METHOD insert(REFERENCE binary[] key, V value) RETURNS STATUSmodifies
METHOD lookupFast(REFERENCE binary[] key) RETURNS booleanreads
METHOD lookup(REFERENCE binary[] key) RETURNS | Vreads
METHOD lookupRef(REFERENCE binary[] key) RETURNS | MUTABLE REFERENCE Vreads
METHOD contains(REFERENCE binary[] key) RETURNS booleanreads
MODIFY METHOD remove(REFERENCE binary[] key) RETURNS booleanmodifies
METHOD isEmpty() RETURNS booleanreads
METHOD size() RETURNS int64reads
MODIFY METHOD clear() RETURNS voidmodifies
MODIFY METHOD insert(BinaryWord key, V value) RETURNS STATUSmodifies
METHOD lookupFast(REFERENCE BinaryWord key) RETURNS booleanreads
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 Vreads
METHOD contains(REFERENCE BinaryWord key) RETURNS booleanreads
MODIFY METHOD remove(REFERENCE BinaryWord key) RETURNS | BinaryWordmodifies
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 STATUSmodifies
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 booleanreads
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.