Type Parameters:
Key: ~int32
Item: any Table is a data structure mapping 32 bit descriptor to items.
# Negative keys are invalid.
Negative keys (e.g. -1) are invalid inputs and will return a corresponding
not-found value. This matches POSIX behavior of file descriptors.
See https://pubs.opengroup.org/onlinepubs/9699919799/functions/dirfd.html#tag_16_90
# Data structure design
The data structure optimizes for memory density and lookup performance,
trading off compute at insertion time. This is a useful compromise for the
use cases we employ it with: items are usually accessed a lot more often
than they are inserted, each operation requires a table lookup, so we are
better off spending extra compute to insert items in the table in order to
get cheaper lookups. Memory efficiency is also crucial to support scaling
with programs that maintain thousands of items: having a high or non-linear
memory-to-item ratio could otherwise be used as an attack vector by
malicious applications attempting to damage performance of the host. Delete deletes the item stored at the given key from the table. Insert inserts the given item to the table, returning the key that it is
mapped to or false if the table was full.
The method does not perform deduplication, it is possible for the same item
to be inserted multiple times, each insertion will return a different key. InsertAt inserts the given `item` at the item descriptor `key`. This returns
false if the insert was impossible due to negative key. Len returns the number of items stored in the table. Lookup returns the item associated with the given key (may be nil). Range calls f for each item and its associated key in the table. The function
f might return false to interupt the iteration. Reset clears the content of the table.
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.