Dictionary structures
Dictionaries map values to unique keys.Common Lispstandard already contains such structures (hash tables, alists, plists) and therefore idea should not be alien to a Lisp programmer. CL-DATA-STRUCTURES offers both functional and mutable dictionaries, with HAMT being the prime example of complete, feature rich implementation of the protocol. In practice, containers present in this module are either ordered containers (for instance binary search trees) or some sort of unordered hash table (either classiscal hashtable or some sort of hashing tree). In each case, overview of data structure is present in this document.
API
To obtain value under key use following functions:
- AT
To change mapping use following purely functional functions:
- INSERT
- ADD
- UPDATE
- UPDATE-IF
- ERASE
- ERASE-IF
To change mapping in destructive way, use following functions:
- (SETF AT)
- ADD!
- UPDATE!
- UPDATE-IF!
- ERASE!
- ERASE-IF!
This package adds another set of trait classes, specific to dictionaries.
Description: Container that provides location to value mapping. Either ordered or unordered.
Description: Dictionary that uses hashing function. Hashing function is assumed to return fixnum.
Description: Functional variant of a dictionary.
Description: Mutable variant of a dictionary.
Description: Transactional variant of a dictionary.
Description: Lazy variant of a dictionary.
Description: Functional variant of hashing a dictionary.
Description: Mutable variant of hashing a dictionary.
Description: Transactional variant of hashing a dictionary.
Description: Lazy variant of a hashing dictionary.
HAMT
HAMT stands from hash array mapped trie. This data structure is used the most commonly as functional dictionary in standard libraries of few recent languages (including Clojure and Scala). Cl-data-structures implementation offers also mutable and transactional variant of this structure. Although this container is not optimized for destructive modification, it is still faster then copy-on-write whole path from root to the bottom (conflict) node.
Dictionary implementation of HAMT is present in the system as a class.
Description: Root HAMT dictionary class.
Description: HAMT dictionary that implements functional api.
Description: HAMT dictionary that implements mutable api.
As you can see, it inherits DICTIONARY trait class as well as lower level FUNDAMENTAL-HAMT-CONTAINER class. All instances of this class can be used with following functions:
Functional dictionary is represented by the following class:
There is no lazy-hamt-dictionary class, because lazy hamt dictionary is nothing more then a TRANSACTIONAL-HAMT-DICTIONARY inside LAZY-BOX.
Constructing
To construct HAMT dictionary, use following functions.
Symbols in the package CL-DATA-STRUCTURES.DICTS.HAMT:Description: Constructs and return new functional-hamt-dictionary
Returns: new instance of functional-hamt-dictionary.
Notes: In theory HAMT can use infinite length of hash but this implementation uses 60 oldest bits at most.
Description: Constructs and returns a new mutable-hamt-dictionary
Returns: new instance of mutable-hamt-dictionary.
Notes: In theory HAMT can use infinite length of hash but this implementation uses 60 oldest bits at most.
Description: Constructs and returns a new mutable-hamt-dictionary
Returns: new instance of transactional-hamt-dictionary.
Notes: In theory HAMT can use infinite length of hash but this implementation uses 60 oldest bits at most.
Sparse RRB Vector
Sparse variant of the RRB vector. Unlike the CL:HASH-TABLE, this container will guarantee that the content is stored in the ascending order. Just like in the case of the RRB vectors, modification of the tail (which includes pushing new elements to the end) is optimized but put functions are not supported.
Description: SRRB sparse vector that implements mutable api.
Description: SRRB sparse vector that implements mutable api.
Description: Transactional SRRB sparse vector that implements mutable api.
Constructing
To construct SRRB vector, use following functions.
Symbols in the package CL-DATA-STRUCTURES.DICTS.HAMT: