package patricia-tree
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=32e5639ec6af0f7763d6bf48a8711d8d9cd0d79af1fc8cecf1c73a442c1c1fa7
sha512=749fb6696e83b88b782d70248cb646a8a7ac02d1e781f15d680ff1b41949b936259abd6979680fc9812b9c9cf8406ca24ccf3e785b8b7977519394a04d53f451
doc/patricia-tree/PatriciaTree/SetNode/index.html
Module PatriciaTree.SetNodeSource
An optimized representation for sets, i.e. maps to unit: we do not store a reference to unit (note that you can further optimize when you know the representation of the key). This is the node used in MakeHeterogeneousSet and MakeSet.
We use a uniform type 'map view to pattern match on maps and sets The actual types 'map t can be a bit different from 'map view to allow for more efficient representations, but view should be a constant time operation for quick conversions.
Parameters
module Key : sig ... endSignature
Types
The type of value, which depends on the type of the key and the type of the map.
The type of the map, which is parameterized by a type.
Constructors: build values
A singleton leaf, similar to BASE_MAP.singleton
A branch node. This shouldn't be called externally unless you know what you're doing! Doing so could easily break the data structure's invariants.
When called, it assumes that:
- Neither
tree0nortree1should be empty. branching_bitshould have a single bit setprefixshould be normalized (bits belowbranching_bitset to zero)- All elements of
tree0should have theirto_intstart byprefixfollowed by 0 at positionbranching_bit). - All elements of
tree1should have theirto_intstart byprefixfollowed by 0 at positionbranching_bit).
Destructors: access the value
type 'map view = private | Empty : 'map view(*Can happen only at the toplevel: there is no empty interior node.
*)| Branch : {} -> 'map view(*Same constraints as
branch:branching_bitcontains only one bit set; the corresponding mask is (branching_bit - 1).prefixis normalized: the bits below thebranching_bitare set to zero (i.e.prefix & (branching_bit - 1) = 0).- All elements of
tree0should have theirto_intstart byprefixfollowed by 0 at positionbranching_bit). - All elements of
tree1should have theirto_intstart byprefixfollowed by 0 at positionbranching_bit).
| Leaf : {} -> 'map view(*A key -> value mapping.
*)
This makes the map nodes accessible to the pattern matching algorithm; this corresponds 1:1 to the SimpleNode implementation. This just needs to be copy-and-pasted for every node type.