Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

lib/typed-map.x

Typed Maps generated from shared storage.

Primary API

FunctionSummary
Map.mapintintPacks entries into a fresh typed map in the current Scope.
Map.maplongdoublePacks entries into a fresh typed map in the current Scope.
Map.mapstringintPacks entries into a fresh typed map in the current Scope.
Map.mapstringstringPacks entries into a fresh typed map in the current Scope.
MapIntInt.compareCompares typed Maps by size and then sorted native key/value contents.
MapIntInt.containsReturns one when key is present, or zero for a null map.
MapIntInt.copyReturns a fresh shallow copy in the current Scope.
MapIntInt.delRemoves key and returns its value.
MapIntInt.enumerateInitializes dest to yield canonical (key value) Lists in bucket order.
MapIntInt.equalReports key/value equality independent of bucket and insertion order.
MapIntInt.getReturns the value for key.
MapIntInt.getdefaultReturns the value for key, or defval without inserting it.
MapIntInt.getindexReturns the value selected by bracket indexing.
MapIntInt.iterInitializes dest as a single-pass iterator over boxed values.
MapIntInt.keysInitializes dest as a single-pass iterator over boxed keys.
MapIntInt.lenReturns the number of entries, or zero for a null map.
MapIntInt.mapReturns a fresh ordinary Map containing boxed keys and values.
MapIntInt.mergeCopies every entry of other into map and returns the destination.
MapIntInt.newReturns a fresh empty map owned by the current Scope.
MapIntInt.new_capacityReturns a fresh empty map with exactly capacity buckets.
MapIntInt.postfixindexApplies postfix ++ or -- and returns the previous value.
MapIntInt.reprReturns the readable typed-Map representation.
MapIntInt.setCopies key and val into the table, replacing an existing value.
MapIntInt.setdefaultReturns the value for key, inserting defval when absent.
MapIntInt.setindexStores val under key and returns val.
MapIntInt.strReturns the typed-Map display String.
MapIntInt.truthReturns one when map contains an entry.
MapIntInt.try_delRemoves key, writes its value to out, and returns one when present.
MapIntInt.try_getWrites the value for key to out and returns one when present.
MapIntInt.try_nextWrites the next bucket’s key and value, advances cursor, and returns one.
MapIntInt.updateindexApplies op to the value for key and returns the stored result.
MapIntInt.varBoxes map with its registered typed-map tag without copying it.
MapIntInt.write_reprAppends the readable typed-Map representation in bucket order.
MapIntInt.write_strAppends the typed-Map display text in bucket order.
MapLongDouble.compareCompares typed Maps by size and then sorted native key/value contents.
MapLongDouble.containsReturns one when key is present, or zero for a null map.
MapLongDouble.copyReturns a fresh shallow copy in the current Scope.
MapLongDouble.delRemoves key and returns its value.
MapLongDouble.enumerateInitializes dest to yield canonical (key value) Lists in bucket order.
MapLongDouble.equalReports key/value equality independent of bucket and insertion order.
MapLongDouble.getReturns the value for key.
MapLongDouble.getdefaultReturns the value for key, or defval without inserting it.
MapLongDouble.getindexReturns the value selected by bracket indexing.
MapLongDouble.iterInitializes dest as a single-pass iterator over boxed values.
MapLongDouble.keysInitializes dest as a single-pass iterator over boxed keys.
MapLongDouble.lenReturns the number of entries, or zero for a null map.
MapLongDouble.mapReturns a fresh ordinary Map containing boxed keys and values.
MapLongDouble.mergeCopies every entry of other into map and returns the destination.
MapLongDouble.newReturns a fresh empty map owned by the current Scope.
MapLongDouble.new_capacityReturns a fresh empty map with exactly capacity buckets.
MapLongDouble.postfixindexApplies postfix ++ or -- and returns the previous value.
MapLongDouble.reprReturns the readable typed-Map representation.
MapLongDouble.setCopies key and val into the table, replacing an existing value.
MapLongDouble.setdefaultReturns the value for key, inserting defval when absent.
MapLongDouble.setindexStores val under key and returns val.
MapLongDouble.strReturns the typed-Map display String.
MapLongDouble.truthReturns one when map contains an entry.
MapLongDouble.try_delRemoves key, writes its value to out, and returns one when present.
MapLongDouble.try_getWrites the value for key to out and returns one when present.
MapLongDouble.try_nextWrites the next bucket’s key and value, advances cursor, and returns one.
MapLongDouble.updateindexApplies op to the value for key and returns the stored result.
MapLongDouble.varBoxes map with its registered typed-map tag without copying it.
MapLongDouble.write_reprAppends the readable typed-Map representation in bucket order.
MapLongDouble.write_strAppends the typed-Map display text in bucket order.
MapStringInt.compareCompares typed Maps by size and then sorted native key/value contents.
MapStringInt.containsReturns one when key is present, or zero for a null map.
MapStringInt.copyReturns a fresh shallow copy in the current Scope.
MapStringInt.delRemoves key and returns its value.
MapStringInt.enumerateInitializes dest to yield canonical (key value) Lists in bucket order.
MapStringInt.equalReports key/value equality independent of bucket and insertion order.
MapStringInt.getReturns the value for key.
MapStringInt.getdefaultReturns the value for key, or defval without inserting it.
MapStringInt.getindexReturns the value selected by bracket indexing.
MapStringInt.iterInitializes dest as a single-pass iterator over boxed values.
MapStringInt.keysInitializes dest as a single-pass iterator over boxed keys.
MapStringInt.lenReturns the number of entries, or zero for a null map.
MapStringInt.mapReturns a fresh ordinary Map containing boxed keys and values.
MapStringInt.mergeCopies every entry of other into map and returns the destination.
MapStringInt.newReturns a fresh empty map owned by the current Scope.
MapStringInt.new_capacityReturns a fresh empty map with exactly capacity buckets.
MapStringInt.postfixindexApplies postfix ++ or -- and returns the previous value.
MapStringInt.reprReturns the readable typed-Map representation.
MapStringInt.setCopies key and val into the table, replacing an existing value.
MapStringInt.setdefaultReturns the value for key, inserting defval when absent.
MapStringInt.setindexStores val under key and returns val.
MapStringInt.strReturns the typed-Map display String.
MapStringInt.truthReturns one when map contains an entry.
MapStringInt.try_delRemoves key, writes its value to out, and returns one when present.
MapStringInt.try_getWrites the value for key to out and returns one when present.
MapStringInt.try_nextWrites the next bucket’s key and value, advances cursor, and returns one.
MapStringInt.updateindexApplies op to the value for key and returns the stored result.
MapStringInt.varBoxes map with its registered typed-map tag without copying it.
MapStringInt.write_reprAppends the readable typed-Map representation in bucket order.
MapStringInt.write_strAppends the typed-Map display text in bucket order.
MapStringString.compareCompares typed Maps by size and then sorted native key/value contents.
MapStringString.containsReturns one when key is present, or zero for a null map.
MapStringString.copyReturns a fresh shallow copy in the current Scope.
MapStringString.delRemoves key and returns its value.
MapStringString.enumerateInitializes dest to yield canonical (key value) Lists in bucket order.
MapStringString.equalReports key/value equality independent of bucket and insertion order.
MapStringString.getReturns the value for key.
MapStringString.getdefaultReturns the value for key, or defval without inserting it.
MapStringString.getindexReturns the value selected by bracket indexing.
MapStringString.iterInitializes dest as a single-pass iterator over boxed values.
MapStringString.keysInitializes dest as a single-pass iterator over boxed keys.
MapStringString.lenReturns the number of entries, or zero for a null map.
MapStringString.mapReturns a fresh ordinary Map containing boxed keys and values.
MapStringString.mergeCopies every entry of other into map and returns the destination.
MapStringString.newReturns a fresh empty map owned by the current Scope.
MapStringString.new_capacityReturns a fresh empty map with exactly capacity buckets.
MapStringString.postfixindexApplies postfix ++ or -- and returns the previous value.
MapStringString.reprReturns the readable typed-Map representation.
MapStringString.setCopies key and val into the table, replacing an existing value.
MapStringString.setdefaultReturns the value for key, inserting defval when absent.
MapStringString.setindexStores val under key and returns val.
MapStringString.strReturns the typed-Map display String.
MapStringString.truthReturns one when map contains an entry.
MapStringString.try_delRemoves key, writes its value to out, and returns one when present.
MapStringString.try_getWrites the value for key to out and returns one when present.
MapStringString.try_nextWrites the next bucket’s key and value, advances cursor, and returns one.
MapStringString.updateindexApplies op to the value for key and returns the stored result.
MapStringString.varBoxes map with its registered typed-map tag without copying it.
MapStringString.write_reprAppends the readable typed-Map representation in bucket order.
MapStringString.write_strAppends the typed-Map display text in bucket order.
Var.mapintintReturns the typed-map pointer carried by value.
Var.maplongdoubleReturns the typed-map pointer carried by value.
Var.mapstringintReturns the typed-map pointer carried by value.
Var.mapstringstringReturns the typed-map pointer carried by value.

Map

Map.mapintint

MapIntInt Map.mapintint(Map entries)

Packs entries into a fresh typed map in the current Scope. A null input returns NULL. Each key and value goes through its Var conversion, and later entries in bucket order replace earlier equal keys. The input Map is unchanged.

Raises: any conversion cause, or <alloc-fail>, <size-limit>, or <invariant> while inserting.

Source: lib/typed-map.x:302

Map.maplongdouble

MapLongDouble Map.maplongdouble(Map entries)

Packs entries into a fresh typed map in the current Scope. A null input returns NULL. Each key and value goes through its Var conversion, and later entries in bucket order replace earlier equal keys. The input Map is unchanged.

Raises: any conversion cause, or <alloc-fail>, <size-limit>, or <invariant> while inserting.

Source: lib/typed-map.x:322

Map.mapstringint

MapStringInt Map.mapstringint(Map entries)

Packs entries into a fresh typed map in the current Scope. A null input returns NULL. Each key and value goes through its Var conversion, and later entries in bucket order replace earlier equal keys. The input Map is unchanged.

Raises: any conversion cause, or <alloc-fail>, <size-limit>, or <invariant> while inserting.

Source: lib/typed-map.x:380

Map.mapstringstring

MapStringString Map.mapstringstring(Map entries)

Packs entries into a fresh typed map in the current Scope. A null input returns NULL. Each key and value goes through its Var conversion, and later entries in bucket order replace earlier equal keys. The input Map is unchanged.

Raises: any conversion cause, or <alloc-fail>, <size-limit>, or <invariant> while inserting.

Source: lib/typed-map.x:343

MapIntInt

MapIntInt.compare

int MapIntInt.compare(MapIntInt a, MapIntInt b)

Compares typed Maps by size and then sorted native key/value contents. Identical handles compare equal and NULL sorts first. Neither Map is mutated. Raises: <alloc-fail> while creating temporary storage, or any cause from key or value comparison.

Source: lib/typed-map.x:310

MapIntInt.contains

int MapIntInt.contains(MapIntInt map, int key)

Returns one when key is present, or zero for a null map.

Source: lib/typed-map.x:302

MapIntInt.copy

MapIntInt MapIntInt.copy(MapIntInt map)

Returns a fresh shallow copy in the current Scope. The result has independent table storage but copies native key and value fields. A null input produces a fresh empty map.

Raises: an allocation, size, or invariant cause while copying.

Source: lib/typed-map.x:302

MapIntInt.del

int MapIntInt.del(MapIntInt map, int key)

Removes key and returns its value. Successful removal invalidates live cursors and iterators.

Raises: <bad-arg> for a null map or absent key.

Source: lib/typed-map.x:302

MapIntInt.enumerate

Iter MapIntInt.enumerate(MapIntInt map, Iter dest)

Initializes dest to yield canonical (key value) Lists in bucket order. The caller owns dest, and the iterator borrows map; both must remain live during traversal. A null dest returns NULL, and a null map is exhausted. Each step boxes both fields and interns two List cells. Each cell belongs to the pool owning its canonical match, which may be an ancestor pool, or to the current pool when newly allocated. Structural mutation invalidates the iterator. Each MapLongDouble pull allocates its long key as a Var in the current Scope; the yielded List and anything retaining it must not outlive that Scope.

Raises: <alloc-fail> or <size-limit> while interning the List, and for MapLongDouble, <alloc-fail> or <bad-enc> while boxing its key. Shared causes do not return from the pull.

Source: lib/typed-map.x:311

MapIntInt.equal

int MapIntInt.equal(MapIntInt a, MapIntInt b)

Reports key/value equality independent of bucket and insertion order. Two null maps compare equal; a null and a nonnull map compare unequal.

Source: lib/typed-map.x:302

MapIntInt.get

int MapIntInt.get(MapIntInt map, int key)

Returns the value for key.

Raises: <bad-arg> for a null map or absent key.

Source: lib/typed-map.x:302

MapIntInt.getdefault

int MapIntInt.getdefault(MapIntInt map, int key, int defval)

Returns the value for key, or defval without inserting it. A null map is treated as an empty one.

Source: lib/typed-map.x:302

MapIntInt.getindex

int MapIntInt.getindex(MapIntInt map, int key)

Returns the value selected by bracket indexing. This is the bracket-facing form of MapIntInt.get, with the same failure behavior.

Source: lib/typed-map.x:302

MapIntInt.iter

Iter MapIntInt.iter(MapIntInt map, Iter dest)

Initializes dest as a single-pass iterator over boxed values. The caller owns dest, and the iterator borrows map; both must remain live during traversal. A null dest returns NULL. Values follow bucket order, a null map is exhausted, and structural mutation invalidates the iterator.

Source: lib/typed-map.x:311

MapIntInt.keys

Iter MapIntInt.keys(MapIntInt map, Iter dest)

Initializes dest as a single-pass iterator over boxed keys. The caller owns dest, and the iterator borrows map; both must remain live during traversal. A null dest returns NULL. Keys follow bucket order, a null map is exhausted, and structural mutation invalidates the iterator. MapIntInt and both String-keyed families box keys without allocation. Each MapLongDouble pull allocates its long key as a Var in the current Scope; the yielded Var and anything retaining it must not outlive that Scope.

Raises: MapLongDouble iteration may raise <alloc-fail> or <bad-enc> while boxing a key.

Source: lib/typed-map.x:311

MapIntInt.len

unsigned MapIntInt.len(MapIntInt map)

Returns the number of entries, or zero for a null map.

Source: lib/typed-map.x:302

MapIntInt.map

Map MapIntInt.map(MapIntInt map)

Returns a fresh ordinary Map containing boxed keys and values. A null input returns NULL. The typed Map and its storage are unchanged.

Raises: any cause from boxing or inserting an entry.

Source: lib/typed-map.x:310

MapIntInt.merge

MapIntInt MapIntInt.merge(MapIntInt map, MapIntInt other)

Copies every entry of other into map and returns the destination. other wins conflicts. A null other is a no-op; a null destination is replaced by a fresh map. When a supplied destination fails partway, entries already copied remain; a newly created destination is discarded.

Raises: an allocation, size, or invariant cause while inserting.

Source: lib/typed-map.x:302

MapIntInt.new

MapIntInt MapIntInt.new(void)

Returns a fresh empty map owned by the current Scope. The initial table has two buckets and grows automatically.

Raises: <alloc-fail> or <size-limit> when storage cannot be created.

Source: lib/typed-map.x:302

MapIntInt.new_capacity

MapIntInt MapIntInt.new_capacity(unsigned capacity)

Returns a fresh empty map with exactly capacity buckets. The result and its backing arrays belong to the current Scope. capacity must be a power of two of at least two.

Raises: <bad-arg> for another capacity, or <alloc-fail> / <size-limit> when storage cannot be created.

Source: lib/typed-map.x:302

MapIntInt.postfixindex

int MapIntInt.postfixindex(MapIntInt map, int key, Symbol op)

Applies postfix ++ or -- and returns the previous value. The key must already exist, and only generated numeric families support these operations.

Raises: <bad-arg> for a null map or absent key, or <bad-op> for an unsupported operation. These failures leave the value unchanged.

Source: lib/typed-map.x:302

MapIntInt.repr

String MapIntInt.repr(MapIntInt map)

Returns the readable typed-Map representation.

Source: lib/typed-map.x:310

MapIntInt.set

void MapIntInt.set(MapIntInt map, int key, int val)

Copies key and val into the table, replacing an existing value. Insertion invalidates live cursors and iterators; replacement does not.

Raises: <bad-arg> for a null map, or an allocation, size, or invariant cause while inserting. Allocation and size failures leave the table unchanged.

Source: lib/typed-map.x:302

MapIntInt.setdefault

int MapIntInt.setdefault(MapIntInt map, int key, int defval)

Returns the value for key, inserting defval when absent. Insertion copies the native key and value fields and invalidates live cursors and iterators; an existing-key read does not mutate the table.

Raises: <bad-arg> for a null map, or an allocation, size, or invariant cause while inserting. Allocation and size failures leave the table unchanged.

Source: lib/typed-map.x:302

MapIntInt.setindex

int MapIntInt.setindex(MapIntInt map, int key, int val)

Stores val under key and returns val. This is the bracket-facing form of MapIntInt.set, with the same cursor invalidation and failure behavior.

Source: lib/typed-map.x:302

MapIntInt.str

String MapIntInt.str(MapIntInt map)

Returns the typed-Map display String.

Source: lib/typed-map.x:310

MapIntInt.truth

int MapIntInt.truth(MapIntInt map)

Returns one when map contains an entry.

Source: lib/typed-map.x:302

MapIntInt.try_del

int MapIntInt.try_del(MapIntInt map, int key, int *out)

Removes key, writes its value to out, and returns one when present. A null map, null out, or absent key returns zero without writing or mutation. Successful removal invalidates live cursors and iterators.

Source: lib/typed-map.x:302

MapIntInt.try_get

int MapIntInt.try_get(MapIntInt map, int key, int *out)

Writes the value for key to out and returns one when present. A null map, null out, or absent key returns zero without writing.

Source: lib/typed-map.x:302

MapIntInt.try_next

int MapIntInt.try_next(MapIntInt map, unsigned *cursor, int *key, int *val)

Writes the next bucket’s key and value, advances cursor, and returns one. Initialize the caller-owned cursor to zero. A null argument or exhaustion returns zero without changing key or val. Traversal follows bucket order, not insertion order, and structural mutation invalidates the cursor.

Source: lib/typed-map.x:302

MapIntInt.updateindex

int MapIntInt.updateindex(MapIntInt map, int key, Symbol op, int rhs)

Applies op to the value for key and returns the stored result. + inserts rhs when the key is absent; other operations require an existing key. Supported operations depend on the generated value type.

Raises: <bad-arg> for a null map or missing required key, a cause from the generated value operation, or an allocation, size, or invariant cause while inserting. Invalid operations leave an existing value unchanged. Allocation and size failures leave the table unchanged.

Source: lib/typed-map.x:302

MapIntInt.var

Var MapIntInt.var(MapIntInt map)

Boxes map with its registered typed-map tag without copying it. The typed pointer and Var share the same mutable map identity.

Source: lib/typed-map.x:311

MapIntInt.write_repr

Buffer MapIntInt.write_repr(MapIntInt map, Buffer out)

Appends the readable typed-Map representation in bucket order.

Source: lib/typed-map.x:310

MapIntInt.write_str

Buffer MapIntInt.write_str(MapIntInt map, Buffer out)

Appends the typed-Map display text in bucket order.

Source: lib/typed-map.x:310

MapLongDouble

MapLongDouble.compare

int MapLongDouble.compare(MapLongDouble a, MapLongDouble b)

Compares typed Maps by size and then sorted native key/value contents. Identical handles compare equal and NULL sorts first. Neither Map is mutated. Raises: <alloc-fail> while creating temporary storage, or any cause from key or value comparison.

Source: lib/typed-map.x:330

MapLongDouble.contains

int MapLongDouble.contains(MapLongDouble map, long key)

Returns one when key is present, or zero for a null map.

Source: lib/typed-map.x:322

MapLongDouble.copy

MapLongDouble MapLongDouble.copy(MapLongDouble map)

Returns a fresh shallow copy in the current Scope. The result has independent table storage but copies native key and value fields. A null input produces a fresh empty map.

Raises: an allocation, size, or invariant cause while copying.

Source: lib/typed-map.x:322

MapLongDouble.del

double MapLongDouble.del(MapLongDouble map, long key)

Removes key and returns its value. Successful removal invalidates live cursors and iterators.

Raises: <bad-arg> for a null map or absent key.

Source: lib/typed-map.x:322

MapLongDouble.enumerate

Iter MapLongDouble.enumerate(MapLongDouble map, Iter dest)

Initializes dest to yield canonical (key value) Lists in bucket order. The caller owns dest, and the iterator borrows map; both must remain live during traversal. A null dest returns NULL, and a null map is exhausted. Each step boxes both fields and interns two List cells. Each cell belongs to the pool owning its canonical match, which may be an ancestor pool, or to the current pool when newly allocated. Structural mutation invalidates the iterator. Each MapLongDouble pull allocates its long key as a Var in the current Scope; the yielded List and anything retaining it must not outlive that Scope.

Raises: <alloc-fail> or <size-limit> while interning the List, and for MapLongDouble, <alloc-fail> or <bad-enc> while boxing its key. Shared causes do not return from the pull.

Source: lib/typed-map.x:331

MapLongDouble.equal

int MapLongDouble.equal(MapLongDouble a, MapLongDouble b)

Reports key/value equality independent of bucket and insertion order. Two null maps compare equal; a null and a nonnull map compare unequal.

Source: lib/typed-map.x:322

MapLongDouble.get

double MapLongDouble.get(MapLongDouble map, long key)

Returns the value for key.

Raises: <bad-arg> for a null map or absent key.

Source: lib/typed-map.x:322

MapLongDouble.getdefault

double MapLongDouble.getdefault(MapLongDouble map, long key, double defval)

Returns the value for key, or defval without inserting it. A null map is treated as an empty one.

Source: lib/typed-map.x:322

MapLongDouble.getindex

double MapLongDouble.getindex(MapLongDouble map, long key)

Returns the value selected by bracket indexing. This is the bracket-facing form of MapLongDouble.get, with the same failure behavior.

Source: lib/typed-map.x:322

MapLongDouble.iter

Iter MapLongDouble.iter(MapLongDouble map, Iter dest)

Initializes dest as a single-pass iterator over boxed values. The caller owns dest, and the iterator borrows map; both must remain live during traversal. A null dest returns NULL. Values follow bucket order, a null map is exhausted, and structural mutation invalidates the iterator.

Source: lib/typed-map.x:331

MapLongDouble.keys

Iter MapLongDouble.keys(MapLongDouble map, Iter dest)

Initializes dest as a single-pass iterator over boxed keys. The caller owns dest, and the iterator borrows map; both must remain live during traversal. A null dest returns NULL. Keys follow bucket order, a null map is exhausted, and structural mutation invalidates the iterator. MapIntInt and both String-keyed families box keys without allocation. Each MapLongDouble pull allocates its long key as a Var in the current Scope; the yielded Var and anything retaining it must not outlive that Scope.

Raises: MapLongDouble iteration may raise <alloc-fail> or <bad-enc> while boxing a key.

Source: lib/typed-map.x:331

MapLongDouble.len

unsigned MapLongDouble.len(MapLongDouble map)

Returns the number of entries, or zero for a null map.

Source: lib/typed-map.x:322

MapLongDouble.map

Map MapLongDouble.map(MapLongDouble map)

Returns a fresh ordinary Map containing boxed keys and values. A null input returns NULL. The typed Map and its storage are unchanged.

Raises: any cause from boxing or inserting an entry.

Source: lib/typed-map.x:330

MapLongDouble.merge

MapLongDouble MapLongDouble.merge(MapLongDouble map, MapLongDouble other)

Copies every entry of other into map and returns the destination. other wins conflicts. A null other is a no-op; a null destination is replaced by a fresh map. When a supplied destination fails partway, entries already copied remain; a newly created destination is discarded.

Raises: an allocation, size, or invariant cause while inserting.

Source: lib/typed-map.x:322

MapLongDouble.new

MapLongDouble MapLongDouble.new(void)

Returns a fresh empty map owned by the current Scope. The initial table has two buckets and grows automatically.

Raises: <alloc-fail> or <size-limit> when storage cannot be created.

Source: lib/typed-map.x:322

MapLongDouble.new_capacity

MapLongDouble MapLongDouble.new_capacity(unsigned capacity)

Returns a fresh empty map with exactly capacity buckets. The result and its backing arrays belong to the current Scope. capacity must be a power of two of at least two.

Raises: <bad-arg> for another capacity, or <alloc-fail> / <size-limit> when storage cannot be created.

Source: lib/typed-map.x:322

MapLongDouble.postfixindex

double MapLongDouble.postfixindex(MapLongDouble map, long key, Symbol op)

Applies postfix ++ or -- and returns the previous value. The key must already exist, and only generated numeric families support these operations.

Raises: <bad-arg> for a null map or absent key, or <bad-op> for an unsupported operation. These failures leave the value unchanged.

Source: lib/typed-map.x:322

MapLongDouble.repr

String MapLongDouble.repr(MapLongDouble map)

Returns the readable typed-Map representation.

Source: lib/typed-map.x:330

MapLongDouble.set

void MapLongDouble.set(MapLongDouble map, long key, double val)

Copies key and val into the table, replacing an existing value. Insertion invalidates live cursors and iterators; replacement does not.

Raises: <bad-arg> for a null map, or an allocation, size, or invariant cause while inserting. Allocation and size failures leave the table unchanged.

Source: lib/typed-map.x:322

MapLongDouble.setdefault

double MapLongDouble.setdefault(MapLongDouble map, long key, double defval)

Returns the value for key, inserting defval when absent. Insertion copies the native key and value fields and invalidates live cursors and iterators; an existing-key read does not mutate the table.

Raises: <bad-arg> for a null map, or an allocation, size, or invariant cause while inserting. Allocation and size failures leave the table unchanged.

Source: lib/typed-map.x:322

MapLongDouble.setindex

double MapLongDouble.setindex(MapLongDouble map, long key, double val)

Stores val under key and returns val. This is the bracket-facing form of MapLongDouble.set, with the same cursor invalidation and failure behavior.

Source: lib/typed-map.x:322

MapLongDouble.str

String MapLongDouble.str(MapLongDouble map)

Returns the typed-Map display String.

Source: lib/typed-map.x:330

MapLongDouble.truth

int MapLongDouble.truth(MapLongDouble map)

Returns one when map contains an entry.

Source: lib/typed-map.x:322

MapLongDouble.try_del

int MapLongDouble.try_del(MapLongDouble map, long key, double *out)

Removes key, writes its value to out, and returns one when present. A null map, null out, or absent key returns zero without writing or mutation. Successful removal invalidates live cursors and iterators.

Source: lib/typed-map.x:322

MapLongDouble.try_get

int MapLongDouble.try_get(MapLongDouble map, long key, double *out)

Writes the value for key to out and returns one when present. A null map, null out, or absent key returns zero without writing.

Source: lib/typed-map.x:322

MapLongDouble.try_next

int MapLongDouble.try_next(MapLongDouble map, unsigned *cursor, long *key, double *val)

Writes the next bucket’s key and value, advances cursor, and returns one. Initialize the caller-owned cursor to zero. A null argument or exhaustion returns zero without changing key or val. Traversal follows bucket order, not insertion order, and structural mutation invalidates the cursor.

Source: lib/typed-map.x:322

MapLongDouble.updateindex

double MapLongDouble.updateindex(MapLongDouble map, long key, Symbol op, double rhs)

Applies op to the value for key and returns the stored result. + inserts rhs when the key is absent; other operations require an existing key. Supported operations depend on the generated value type.

Raises: <bad-arg> for a null map or missing required key, a cause from the generated value operation, or an allocation, size, or invariant cause while inserting. Invalid operations leave an existing value unchanged. Allocation and size failures leave the table unchanged.

Source: lib/typed-map.x:322

MapLongDouble.var

Var MapLongDouble.var(MapLongDouble map)

Boxes map with its registered typed-map tag without copying it. The typed pointer and Var share the same mutable map identity.

Source: lib/typed-map.x:331

MapLongDouble.write_repr

Buffer MapLongDouble.write_repr(MapLongDouble map, Buffer out)

Appends the readable typed-Map representation in bucket order.

Source: lib/typed-map.x:330

MapLongDouble.write_str

Buffer MapLongDouble.write_str(MapLongDouble map, Buffer out)

Appends the typed-Map display text in bucket order.

Source: lib/typed-map.x:330

MapStringInt

MapStringInt.compare

int MapStringInt.compare(MapStringInt a, MapStringInt b)

Compares typed Maps by size and then sorted native key/value contents. Identical handles compare equal and NULL sorts first. Neither Map is mutated. Raises: <alloc-fail> while creating temporary storage, or any cause from key or value comparison.

Source: lib/typed-map.x:388

MapStringInt.contains

int MapStringInt.contains(MapStringInt map, String key)

Returns one when key is present, or zero for a null map.

Source: lib/typed-map.x:380

MapStringInt.copy

MapStringInt MapStringInt.copy(MapStringInt map)

Returns a fresh shallow copy in the current Scope. The result has independent table storage but copies native key and value fields. A null input produces a fresh empty map.

Raises: an allocation, size, or invariant cause while copying.

Source: lib/typed-map.x:380

MapStringInt.del

int MapStringInt.del(MapStringInt map, String key)

Removes key and returns its value. Successful removal invalidates live cursors and iterators.

Raises: <bad-arg> for a null map or absent key.

Source: lib/typed-map.x:380

MapStringInt.enumerate

Iter MapStringInt.enumerate(MapStringInt map, Iter dest)

Initializes dest to yield canonical (key value) Lists in bucket order. The caller owns dest, and the iterator borrows map; both must remain live during traversal. A null dest returns NULL, and a null map is exhausted. Each step boxes both fields and interns two List cells. Each cell belongs to the pool owning its canonical match, which may be an ancestor pool, or to the current pool when newly allocated. Structural mutation invalidates the iterator. Each MapLongDouble pull allocates its long key as a Var in the current Scope; the yielded List and anything retaining it must not outlive that Scope.

Raises: <alloc-fail> or <size-limit> while interning the List, and for MapLongDouble, <alloc-fail> or <bad-enc> while boxing its key. Shared causes do not return from the pull.

Source: lib/typed-map.x:405

MapStringInt.equal

int MapStringInt.equal(MapStringInt a, MapStringInt b)

Reports key/value equality independent of bucket and insertion order. Two null maps compare equal; a null and a nonnull map compare unequal.

Source: lib/typed-map.x:380

MapStringInt.get

int MapStringInt.get(MapStringInt map, String key)

Returns the value for key.

Raises: <bad-arg> for a null map or absent key.

Source: lib/typed-map.x:380

MapStringInt.getdefault

int MapStringInt.getdefault(MapStringInt map, String key, int defval)

Returns the value for key, or defval without inserting it. A null map is treated as an empty one.

Source: lib/typed-map.x:380

MapStringInt.getindex

int MapStringInt.getindex(MapStringInt map, String key)

Returns the value selected by bracket indexing. This is the bracket-facing form of MapStringInt.get, with the same failure behavior.

Source: lib/typed-map.x:380

MapStringInt.iter

Iter MapStringInt.iter(MapStringInt map, Iter dest)

Initializes dest as a single-pass iterator over boxed values. The caller owns dest, and the iterator borrows map; both must remain live during traversal. A null dest returns NULL. Values follow bucket order, a null map is exhausted, and structural mutation invalidates the iterator.

Source: lib/typed-map.x:405

MapStringInt.keys

Iter MapStringInt.keys(MapStringInt map, Iter dest)

Initializes dest as a single-pass iterator over boxed keys. The caller owns dest, and the iterator borrows map; both must remain live during traversal. A null dest returns NULL. Keys follow bucket order, a null map is exhausted, and structural mutation invalidates the iterator. MapIntInt and both String-keyed families box keys without allocation. Each MapLongDouble pull allocates its long key as a Var in the current Scope; the yielded Var and anything retaining it must not outlive that Scope.

Raises: MapLongDouble iteration may raise <alloc-fail> or <bad-enc> while boxing a key.

Source: lib/typed-map.x:405

MapStringInt.len

unsigned MapStringInt.len(MapStringInt map)

Returns the number of entries, or zero for a null map.

Source: lib/typed-map.x:380

MapStringInt.map

Map MapStringInt.map(MapStringInt map)

Returns a fresh ordinary Map containing boxed keys and values. A null input returns NULL. The typed Map and its storage are unchanged.

Raises: any cause from boxing or inserting an entry.

Source: lib/typed-map.x:388

MapStringInt.merge

MapStringInt MapStringInt.merge(MapStringInt map, MapStringInt other)

Copies every entry of other into map and returns the destination. other wins conflicts. A null other is a no-op; a null destination is replaced by a fresh map. When a supplied destination fails partway, entries already copied remain; a newly created destination is discarded.

Raises: an allocation, size, or invariant cause while inserting.

Source: lib/typed-map.x:380

MapStringInt.new

MapStringInt MapStringInt.new(void)

Returns a fresh empty map owned by the current Scope. The initial table has two buckets and grows automatically.

Raises: <alloc-fail> or <size-limit> when storage cannot be created.

Source: lib/typed-map.x:380

MapStringInt.new_capacity

MapStringInt MapStringInt.new_capacity(unsigned capacity)

Returns a fresh empty map with exactly capacity buckets. The result and its backing arrays belong to the current Scope. capacity must be a power of two of at least two.

Raises: <bad-arg> for another capacity, or <alloc-fail> / <size-limit> when storage cannot be created.

Source: lib/typed-map.x:380

MapStringInt.postfixindex

int MapStringInt.postfixindex(MapStringInt map, String key, Symbol op)

Applies postfix ++ or -- and returns the previous value. The key must already exist, and only generated numeric families support these operations.

Raises: <bad-arg> for a null map or absent key, or <bad-op> for an unsupported operation. These failures leave the value unchanged.

Source: lib/typed-map.x:380

MapStringInt.repr

String MapStringInt.repr(MapStringInt map)

Returns the readable typed-Map representation.

Source: lib/typed-map.x:388

MapStringInt.set

void MapStringInt.set(MapStringInt map, String key, int val)

Copies key and val into the table, replacing an existing value. Insertion invalidates live cursors and iterators; replacement does not.

Raises: <bad-arg> for a null map, or an allocation, size, or invariant cause while inserting. Allocation and size failures leave the table unchanged.

Source: lib/typed-map.x:380

MapStringInt.setdefault

int MapStringInt.setdefault(MapStringInt map, String key, int defval)

Returns the value for key, inserting defval when absent. Insertion copies the native key and value fields and invalidates live cursors and iterators; an existing-key read does not mutate the table.

Raises: <bad-arg> for a null map, or an allocation, size, or invariant cause while inserting. Allocation and size failures leave the table unchanged.

Source: lib/typed-map.x:380

MapStringInt.setindex

int MapStringInt.setindex(MapStringInt map, String key, int val)

Stores val under key and returns val. This is the bracket-facing form of MapStringInt.set, with the same cursor invalidation and failure behavior.

Source: lib/typed-map.x:380

MapStringInt.str

String MapStringInt.str(MapStringInt map)

Returns the typed-Map display String.

Source: lib/typed-map.x:388

MapStringInt.truth

int MapStringInt.truth(MapStringInt map)

Returns one when map contains an entry.

Source: lib/typed-map.x:380

MapStringInt.try_del

int MapStringInt.try_del(MapStringInt map, String key, int *out)

Removes key, writes its value to out, and returns one when present. A null map, null out, or absent key returns zero without writing or mutation. Successful removal invalidates live cursors and iterators.

Source: lib/typed-map.x:380

MapStringInt.try_get

int MapStringInt.try_get(MapStringInt map, String key, int *out)

Writes the value for key to out and returns one when present. A null map, null out, or absent key returns zero without writing.

Source: lib/typed-map.x:380

MapStringInt.try_next

int MapStringInt.try_next(MapStringInt map, unsigned *cursor, String *key, int *val)

Writes the next bucket’s key and value, advances cursor, and returns one. Initialize the caller-owned cursor to zero. A null argument or exhaustion returns zero without changing key or val. Traversal follows bucket order, not insertion order, and structural mutation invalidates the cursor.

Source: lib/typed-map.x:380

MapStringInt.updateindex

int MapStringInt.updateindex(MapStringInt map, String key, Symbol op, int rhs)

Applies op to the value for key and returns the stored result. + inserts rhs when the key is absent; other operations require an existing key. Supported operations depend on the generated value type.

Raises: <bad-arg> for a null map or missing required key, a cause from the generated value operation, or an allocation, size, or invariant cause while inserting. Invalid operations leave an existing value unchanged. Allocation and size failures leave the table unchanged.

Source: lib/typed-map.x:380

MapStringInt.var

Var MapStringInt.var(MapStringInt map)

Boxes map with its registered typed-map tag without copying it. The typed pointer and Var share the same mutable map identity.

Source: lib/typed-map.x:405

MapStringInt.write_repr

Buffer MapStringInt.write_repr(MapStringInt map, Buffer out)

Appends the readable typed-Map representation in bucket order.

Source: lib/typed-map.x:388

MapStringInt.write_str

Buffer MapStringInt.write_str(MapStringInt map, Buffer out)

Appends the typed-Map display text in bucket order.

Source: lib/typed-map.x:388

MapStringString

MapStringString.compare

int MapStringString.compare(MapStringString a, MapStringString b)

Compares typed Maps by size and then sorted native key/value contents. Identical handles compare equal and NULL sorts first. Neither Map is mutated. Raises: <alloc-fail> while creating temporary storage, or any cause from key or value comparison.

Source: lib/typed-map.x:351

MapStringString.contains

int MapStringString.contains(MapStringString map, String key)

Returns one when key is present, or zero for a null map.

Source: lib/typed-map.x:343

MapStringString.copy

MapStringString MapStringString.copy(MapStringString map)

Returns a fresh shallow copy in the current Scope. The result has independent table storage but copies native key and value fields. A null input produces a fresh empty map.

Raises: an allocation, size, or invariant cause while copying.

Source: lib/typed-map.x:343

MapStringString.del

String MapStringString.del(MapStringString map, String key)

Removes key and returns its value. Successful removal invalidates live cursors and iterators.

Raises: <bad-arg> for a null map or absent key.

Source: lib/typed-map.x:343

MapStringString.enumerate

Iter MapStringString.enumerate(MapStringString map, Iter dest)

Initializes dest to yield canonical (key value) Lists in bucket order. The caller owns dest, and the iterator borrows map; both must remain live during traversal. A null dest returns NULL, and a null map is exhausted. Each step boxes both fields and interns two List cells. Each cell belongs to the pool owning its canonical match, which may be an ancestor pool, or to the current pool when newly allocated. Structural mutation invalidates the iterator. Each MapLongDouble pull allocates its long key as a Var in the current Scope; the yielded List and anything retaining it must not outlive that Scope.

Raises: <alloc-fail> or <size-limit> while interning the List, and for MapLongDouble, <alloc-fail> or <bad-enc> while boxing its key. Shared causes do not return from the pull.

Source: lib/typed-map.x:368

MapStringString.equal

int MapStringString.equal(MapStringString a, MapStringString b)

Reports key/value equality independent of bucket and insertion order. Two null maps compare equal; a null and a nonnull map compare unequal.

Source: lib/typed-map.x:343

MapStringString.get

String MapStringString.get(MapStringString map, String key)

Returns the value for key.

Raises: <bad-arg> for a null map or absent key.

Source: lib/typed-map.x:343

MapStringString.getdefault

String MapStringString.getdefault(MapStringString map, String key, String defval)

Returns the value for key, or defval without inserting it. A null map is treated as an empty one.

Source: lib/typed-map.x:343

MapStringString.getindex

String MapStringString.getindex(MapStringString map, String key)

Returns the value selected by bracket indexing. This is the bracket-facing form of MapStringString.get, with the same failure behavior.

Source: lib/typed-map.x:343

MapStringString.iter

Iter MapStringString.iter(MapStringString map, Iter dest)

Initializes dest as a single-pass iterator over boxed values. The caller owns dest, and the iterator borrows map; both must remain live during traversal. A null dest returns NULL. Values follow bucket order, a null map is exhausted, and structural mutation invalidates the iterator.

Source: lib/typed-map.x:368

MapStringString.keys

Iter MapStringString.keys(MapStringString map, Iter dest)

Initializes dest as a single-pass iterator over boxed keys. The caller owns dest, and the iterator borrows map; both must remain live during traversal. A null dest returns NULL. Keys follow bucket order, a null map is exhausted, and structural mutation invalidates the iterator. MapIntInt and both String-keyed families box keys without allocation. Each MapLongDouble pull allocates its long key as a Var in the current Scope; the yielded Var and anything retaining it must not outlive that Scope.

Raises: MapLongDouble iteration may raise <alloc-fail> or <bad-enc> while boxing a key.

Source: lib/typed-map.x:368

MapStringString.len

unsigned MapStringString.len(MapStringString map)

Returns the number of entries, or zero for a null map.

Source: lib/typed-map.x:343

MapStringString.map

Map MapStringString.map(MapStringString map)

Returns a fresh ordinary Map containing boxed keys and values. A null input returns NULL. The typed Map and its storage are unchanged.

Raises: any cause from boxing or inserting an entry.

Source: lib/typed-map.x:351

MapStringString.merge

MapStringString MapStringString.merge(MapStringString map, MapStringString other)

Copies every entry of other into map and returns the destination. other wins conflicts. A null other is a no-op; a null destination is replaced by a fresh map. When a supplied destination fails partway, entries already copied remain; a newly created destination is discarded.

Raises: an allocation, size, or invariant cause while inserting.

Source: lib/typed-map.x:343

MapStringString.new

MapStringString MapStringString.new(void)

Returns a fresh empty map owned by the current Scope. The initial table has two buckets and grows automatically.

Raises: <alloc-fail> or <size-limit> when storage cannot be created.

Source: lib/typed-map.x:343

MapStringString.new_capacity

MapStringString MapStringString.new_capacity(unsigned capacity)

Returns a fresh empty map with exactly capacity buckets. The result and its backing arrays belong to the current Scope. capacity must be a power of two of at least two.

Raises: <bad-arg> for another capacity, or <alloc-fail> / <size-limit> when storage cannot be created.

Source: lib/typed-map.x:343

MapStringString.postfixindex

String MapStringString.postfixindex(MapStringString map, String key, Symbol op)

Applies postfix ++ or -- and returns the previous value. The key must already exist, and only generated numeric families support these operations.

Raises: <bad-arg> for a null map or absent key, or <bad-op> for an unsupported operation. These failures leave the value unchanged.

Source: lib/typed-map.x:343

MapStringString.repr

String MapStringString.repr(MapStringString map)

Returns the readable typed-Map representation.

Source: lib/typed-map.x:351

MapStringString.set

void MapStringString.set(MapStringString map, String key, String val)

Copies key and val into the table, replacing an existing value. Insertion invalidates live cursors and iterators; replacement does not.

Raises: <bad-arg> for a null map, or an allocation, size, or invariant cause while inserting. Allocation and size failures leave the table unchanged.

Source: lib/typed-map.x:343

MapStringString.setdefault

String MapStringString.setdefault(MapStringString map, String key, String defval)

Returns the value for key, inserting defval when absent. Insertion copies the native key and value fields and invalidates live cursors and iterators; an existing-key read does not mutate the table.

Raises: <bad-arg> for a null map, or an allocation, size, or invariant cause while inserting. Allocation and size failures leave the table unchanged.

Source: lib/typed-map.x:343

MapStringString.setindex

String MapStringString.setindex(MapStringString map, String key, String val)

Stores val under key and returns val. This is the bracket-facing form of MapStringString.set, with the same cursor invalidation and failure behavior.

Source: lib/typed-map.x:343

MapStringString.str

String MapStringString.str(MapStringString map)

Returns the typed-Map display String.

Source: lib/typed-map.x:351

MapStringString.truth

int MapStringString.truth(MapStringString map)

Returns one when map contains an entry.

Source: lib/typed-map.x:343

MapStringString.try_del

int MapStringString.try_del(MapStringString map, String key, String *out)

Removes key, writes its value to out, and returns one when present. A null map, null out, or absent key returns zero without writing or mutation. Successful removal invalidates live cursors and iterators.

Source: lib/typed-map.x:343

MapStringString.try_get

int MapStringString.try_get(MapStringString map, String key, String *out)

Writes the value for key to out and returns one when present. A null map, null out, or absent key returns zero without writing.

Source: lib/typed-map.x:343

MapStringString.try_next

int MapStringString.try_next(MapStringString map, unsigned *cursor, String *key, String *val)

Writes the next bucket’s key and value, advances cursor, and returns one. Initialize the caller-owned cursor to zero. A null argument or exhaustion returns zero without changing key or val. Traversal follows bucket order, not insertion order, and structural mutation invalidates the cursor.

Source: lib/typed-map.x:343

MapStringString.updateindex

String MapStringString.updateindex(MapStringString map, String key, Symbol op, String rhs)

Applies op to the value for key and returns the stored result. + inserts rhs when the key is absent; other operations require an existing key. Supported operations depend on the generated value type.

Raises: <bad-arg> for a null map or missing required key, a cause from the generated value operation, or an allocation, size, or invariant cause while inserting. Invalid operations leave an existing value unchanged. Allocation and size failures leave the table unchanged.

Source: lib/typed-map.x:343

MapStringString.var

Var MapStringString.var(MapStringString map)

Boxes map with its registered typed-map tag without copying it. The typed pointer and Var share the same mutable map identity.

Source: lib/typed-map.x:368

MapStringString.write_repr

Buffer MapStringString.write_repr(MapStringString map, Buffer out)

Appends the readable typed-Map representation in bucket order.

Source: lib/typed-map.x:351

MapStringString.write_str

Buffer MapStringString.write_str(MapStringString map, Buffer out)

Appends the typed-Map display text in bucket order.

Source: lib/typed-map.x:351

Var

Var.mapintint

MapIntInt Var.mapintint(Var value)

Returns the typed-map pointer carried by value. value must carry this family’s registered tag; the converter does not validate the tag before reading its pointer payload.

Source: lib/typed-map.x:311

Var.maplongdouble

MapLongDouble Var.maplongdouble(Var value)

Returns the typed-map pointer carried by value. value must carry this family’s registered tag; the converter does not validate the tag before reading its pointer payload.

Source: lib/typed-map.x:331

Var.mapstringint

MapStringInt Var.mapstringint(Var value)

Returns the typed-map pointer carried by value. value must carry this family’s registered tag; the converter does not validate the tag before reading its pointer payload.

Source: lib/typed-map.x:405

Var.mapstringstring

MapStringString Var.mapstringstring(Var value)

Returns the typed-map pointer carried by value. value must carry this family’s registered tag; the converter does not validate the tag before reading its pointer payload.

Source: lib/typed-map.x:368

Public types

TypeKindSummary
MapIntIntstructA mutable, Scope-owned map from native int keys to int values.
MapLongDoublestructA mutable, Scope-owned map from native long keys to double values.
MapStringIntstructA mutable, Scope-owned map from canonical String keys to native int values.
MapStringStringstructA mutable, Scope-owned map from canonical Strings to canonical Strings.

MapIntInt

typedef struct MapIntInt { Scope *scope, Bytes hashes, entries; unsigned used; unsigned capacity; unsigned mask; } *MapIntInt

A mutable, Scope-owned map from native int keys to int values. Keys and values are copied into native entry fields; assignment shares the map, while MapIntInt.copy makes an independent table. Compound indexed updates support arithmetic, remainder, bitwise, and shift operators, plus postfix increment and decrement.

Source: lib/typed-map.x:25

MapLongDouble

typedef struct MapLongDouble { Scope *scope, Bytes hashes, entries; unsigned used; unsigned capacity; unsigned mask; } *MapLongDouble

A mutable, Scope-owned map from native long keys to double values. Keys and values are copied into native entry fields; assignment shares the map, while MapLongDouble.copy makes an independent table. Compound indexed updates support +, -, *, and /, plus postfix increment and decrement.

Source: lib/typed-map.x:38

MapStringInt

typedef struct MapStringInt { Scope *scope, Bytes hashes, entries; unsigned used; unsigned capacity; unsigned mask; } *MapStringInt

A mutable, Scope-owned map from canonical String keys to native int values. Exporting an owned map rebuilds it with destination-canonical keys before replacing its storage. Compound indexed updates support arithmetic, remainder, bitwise, and shift operators, plus postfix increment and decrement.

Source: lib/typed-map.x:68

MapStringString

typedef struct MapStringString { Scope *scope, Bytes hashes, entries; unsigned used; unsigned capacity; unsigned mask; } *MapStringString

A mutable, Scope-owned map from canonical Strings to canonical Strings. The native entry fields borrow the supplied String pointers. Exporting a map owned by a Context recanonicalizes only Strings owned by that Context in the destination pool before moving the map. Borrowed or outer-owned Strings retain their existing pool lifetime, which must outlive the map. Compound indexed update supports only concatenation; postfix update is unsupported.

Source: lib/typed-map.x:55

Design notes

These optional families store keys and values in native record fields. Their static operations do not box through Var. Separate methods provide Var conversion and Iter traversal.

Tests and examples

make verify (unittest/test-typed-map.x).