bucket_array

bucket_array α β is the underlying data type for hash_map α β, an array of linked lists of key-value pairs.

hash_map.mk_idx

Make a hash_map index from a nat hash value and a (positive) buffer size

bucket_array.read

Read the bucket corresponding to an element

bucket_array.write

Write the bucket corresponding to an element

bucket_array.modify

Modify (read, apply f, and write) the bucket corresponding to an element

bucket_array.as_list

The list of all key-value pairs in the bucket list

bucket_array.foldl

Fold a function f over the key-value pairs in the bucket list

hash_map.reinsert_aux

Insert the pair ⟨a, b⟩ into the correct location in the bucket array (without checking for duplication)

hash_map.find_aux

Search a bucket for a key a and return the value

hash_map.contains_aux

Returns tt if the bucket l contains the key a

hash_map.replace_aux

Modify a bucket to replace a value in the list. Leaves the list unchanged if the key is not found.

hash_map.erase_aux

Modify a bucket to remove a key, if it exists.

hash_map.valid

The predicate valid bkts sz means that bkts satisfies the hash_map invariants: There are exactly sz elements in it, every pair is in the bucket determined by its key and the hash function, and no key appears multiple times in the list.

hash_map

A hash map data structure, representing a finite key-value map with key type α and value type β (which may depend on α).

mk_hash_map

Construct an empty hash map with buffer size nbuckets (default 8).

hash_map.find

Return the value corresponding to a key, or none if not found

hash_map.contains

Return tt if the key exists in the map

hash_map.fold

Fold a function over the key-value pairs in the map

hash_map.entries

The list of key-value pairs in the map

hash_map.keys

The list of keys in the map

hash_map.insert

Insert a key-value pair into the map. (Modifies m in-place when applicable)

hash_map.insert_all

Insert a list of key-value pairs into the map. (Modifies m in-place when applicable)

hash_map.of_list

Construct a hash map from a list of key-value pairs.

hash_map.erase

Remove a key from the map. (Modifies m in-place when applicable)