Documentation
¶
Index ¶
- func Equal(p, q *Trie) bool
- func IntersectKeySlices(p, q []key.Key) []key.Key
- func UnionKeySlices(left, right []key.Key) []key.Key
- type InvariantDiscrepancy
- type Trie
- func Add(trie *Trie, q key.Key) *Trie
- func AddAtDepth(depth int, trie *Trie, q key.Key) *Trie
- func FromKeys(k []key.Key) *Trie
- func FromKeysAtDepth(depth int, k []key.Key) *Trie
- func Intersect(p, q *Trie) *Trie
- func IntersectAtDepth(depth int, p, q *Trie) *Trie
- func New() *Trie
- func Remove(trie *Trie, q key.Key) *Trie
- func RemoveAtDepth(depth int, trie *Trie, q key.Key) *Trie
- func Union(left, right *Trie) *Trie
- func UnionAtDepth(depth int, left, right *Trie) *Trie
- func (trie *Trie) Add(q key.Key) (insertedDepth int, insertedOK bool)
- func (trie *Trie) AddAtDepth(depth int, q key.Key) (insertedDepth int, insertedOK bool)
- func (trie *Trie) CheckInvariant() *InvariantDiscrepancy
- func (trie *Trie) Copy() *Trie
- func (trie *Trie) Depth() int
- func (trie *Trie) DepthAtDepth(depth int) int
- func (trie *Trie) Find(q key.Key) (reachedDepth int, found bool)
- func (trie *Trie) FindAtDepth(depth int, q key.Key) (reachedDepth int, found bool)
- func (trie *Trie) IsEmpty() bool
- func (trie *Trie) IsEmptyLeaf() bool
- func (trie *Trie) IsLeaf() bool
- func (trie *Trie) IsNonEmptyLeaf() bool
- func (trie *Trie) List() []key.Key
- func (trie *Trie) Remove(q key.Key) (removedDepth int, removed bool)
- func (trie *Trie) RemoveAtDepth(depth int, q key.Key) (reachedDepth int, removed bool)
- func (trie *Trie) Size() int
- func (trie *Trie) SizeAtDepth(depth int) int
- func (trie *Trie) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type InvariantDiscrepancy ¶
type Trie ¶
Trie is a trie for equal-length bit vectors, which stores values only in the leaves. Trie node invariants: (1) Either both branches are nil, or both are non-nil. (2) If branches are non-nil, key must be nil. (3) If both branches are leaves, then they are both non-empty (have keys).
func Add ¶
Add adds the key q to trie, returning a new trie. Add is immutable/non-destructive: The original trie remains unchanged.
func Intersect ¶
Intersect computes the intersection of the keys in p and q. p and q must be non-nil. The returned trie is never nil.
func IntersectAtDepth ¶
func UnionAtDepth ¶
func (*Trie) AddAtDepth ¶
func (*Trie) CheckInvariant ¶
func (trie *Trie) CheckInvariant() *InvariantDiscrepancy
CheckInvariant panics of the trie does not meet its invariant.
func (*Trie) DepthAtDepth ¶
func (*Trie) Find ¶
Find looks for the key q in the trie. It returns the depth of the leaf reached along the path of q, regardless of whether q was found in that leaf. It also returns a boolean flag indicating whether the key was found.
func (*Trie) FindAtDepth ¶
func (*Trie) IsEmptyLeaf ¶
func (*Trie) IsNonEmptyLeaf ¶
func (*Trie) Remove ¶
Remove removes the key q from the trie. Remove mutates the trie. TODO: Also implement an immutable version of Remove.
func (*Trie) RemoveAtDepth ¶
func (*Trie) Size ¶
Size returns the number of keys added to the trie. In other words, it returns the number of non-empty leaves in the trie.