Hash Table
- class npstructures.HashTable(keys, values, mod=None, key_dtype=None, value_dtype=None, safe_mode=True)[source]
Enables dict-like lookup of values for a predefined set of integer keys
Provides fast lookup for a predefined set of keys. The set of keys must be unique values andcannot be modified after the creation of the HashTable. This is in contrast to dict, where the set of keys is mutable. Indexing both with a single index, or an array_like index is supported. See examples
- Parameters:
- keysarray_like or RaggedArray
The keys for the lookup
- valuesarray_like or RaggedArray
The corresponding values
- modint, optional
the modulo-value used to create the hashes
- key_dtypeoptional
the datatype to use for keys. (Must be integer-type)
- value_dtypeoptional
the datatype to use for the values
Examples
>>> table = HashTable([10, 19, 20, 100], [3.14, 2.87, 1.11, 0]) >>> table[[19, 100]] array([2.87, 0. ])
- Attributes: