Dict module
Dictionaries to map keys of one type to values of another type. The Dict type is generally most useful, but TinyDict can be used when the number of keys is very small (10 or fewer). The Set module may also be useful, and its HashSet replaces the ExistDict in this module in previous Kaya versions. Looking up and adding values to a dictionary will usually take a constant amount of time regardless of the size of the dictionary, and so these are often more efficient than usings lists.
Data types
- Dict::Dict<a,b> - Dictionary/Hash Table.
- Dict::TinyDict<a,b> - Tiny Dictionary/Hash Table.
Functions
- Void add(Dict<a, b> dict,a key,b val) - Add an entry to a dictionary.
- Void add(TinyDict<a, b> dict,a key,b val) - Add an entry to a tiny dictionary.
- Void delete(Dict<a, b> dict,a key) - Remove an entry from a dictionary
- Void delete(TinyDict<a, b> dict,a key) - Remove an entry from a tiny dictionary
- Dict<a, b> dict([Pair<a, b> ] entries) - Create a dictionary from a list of pairs
- Bool empty(Dict<a, b> dict) - Check if a dictionary is empty
- Bool empty(TinyDict<a, b> dict) - Check if a tiny dictionary is empty
- [Pair<a, b> ] entries(Dict<a, b> dict) - List all entries in a dictionary
- [Pair<a, b> ] entries(TinyDict<a, b> dict) - List all entries in a tiny dictionary
- Bool exists(Dict<a, b> dict,a key) - Check if a key exists in a dictionary.
- Bool exists(TinyDict<a, b> dict,a key) - Check if a key exists in a tiny dictionary.
- [a] keys(Dict<a, b> dict) - List all keys in a dictionary
- [a] keys(TinyDict<a, b> dict) - List all keys in a tiny dictionary
- Maybe<b> lookup(Dict<a, b> dict,a key) - Look up a value in a dictionary.
- Maybe<b> lookup(TinyDict<a, b> dict,a key) - Look up a value in a tiny dictionary.
- Dict<a, b> new(Int buckets=157,Int(a) hashfn=hash) - Create a new dictionary.
- TinyDict<a, b> newTiny() - Create a new tiny dictionary.
- Int numBuckets(Dict<a, b> d) - Get the number of buckets used in a dictionary
- [b] vals(Dict<a, b> dict) - List all values in a dictionary
- [b] vals(TinyDict<a, b> dict) - List all values in a tiny dictionary