hashtable is an improvement on storing items in AutoHotkey Objects.
With hashtable you can
- store any string key without losing access to hashtable's methods
- prevent string keys from being case-folded
- prevent floating point number keys from being indexed by their current string representation instead of their value
⚠️ Hash tables are inherently unordered. When enumerating a hash table, do not expect to process keys in sorted order or the order they were inserted. If you need to process keys in a certain order, store them in that order in an Array and enumerate that while operating on the hashtable or use something other than a hash table (like an AVL tree).
⚠️ Mutating a hash table while enumerating it might cause items to be processed more than once or skipped. You can get the desired effect by enumerating a clone of the hashtable while mutating the hashtable you intend to keep.
⚠️ Floating point number keys are rarely useful because it is rarely safe to compare the result of a floating point calculation exactly. Converting mathematical constants to their names is an example of a valid use.
⚠️ Object keys are rarely useful because they are indexed by their address. Two objects might behave identically in every way, but if they are not the same object (stored in the same location in memory), they will not be associated with the same value. Recording visited nodes in a graph traversal algorithm is an example of a valid use.
hashtable is compatible with AutoHotkey v1.
export.ahk
must be included explicitly or placed in a library directory.
hashtable’s constructor accepts items as Arrays containing a key and a value, in that order.
hashtable is generally used with the following two methods:
hashtable.create(Key, Value)
hashtable.read(Key)
create(Key, Value)
writes the value associated with a key.
read(Key)
reads the value associated with a key.
Supports the following interfaces from Object:
hashtable.delete(Key)
hashtable.count()
hashtable._NewEnum()
hashtable.hasKey(Key)
hashtable.clone()
Follows CRUD operations (create, read, update, delete)
.create
.read
.update
.delete
and .clear
.clone
, .hasKey
, and .size