Documentation ¶
Index ¶
- type FIFO
- type Heap
- type HeapFunc
- type LIFO
- type RadixMap
- func (r *RadixMap[E]) All() iter.Seq2[string, E]
- func (r *RadixMap[E]) Delete(key string) (old E, ok bool)
- func (r *RadixMap[E]) Get(key string) (value E, ok bool)
- func (r *RadixMap[E]) Len() int
- func (r *RadixMap[E]) PrefixesOf(s string) iter.Seq2[string, E]
- func (r *RadixMap[E]) Set(key string, value E) (old E, ok bool)
- func (r *RadixMap[E]) WithPrefix(p string) iter.Seq2[string, E]
- type RadixSet
- func (s *RadixSet) Add(str string) (added bool)
- func (s *RadixSet) All() iter.Seq[string]
- func (s *RadixSet) Contains(str string) bool
- func (s *RadixSet) Delete(key string) (deleted bool)
- func (s *RadixSet) Len() int
- func (s *RadixSet) PrefixesOf(str string) iter.Seq[string]
- func (s *RadixSet) WithPrefix(p string) iter.Seq[string]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FIFO ¶
type FIFO[E any] struct { // contains filtered or unexported fields }
FIFO is a First-In-First-Out queue. A zero FIFO is an empty queue ready to use.
type Heap ¶
type Heap[E constraints.Ordered] []E
Heap implements a min-heap.
func (*Heap[E]) Fix ¶
Fix re-establishes the heap ordering after the element at index i has changed its value. Changing the value of the element at index i and then calling Fix is equivalent to, but less expensive than, calling Remove(h, i) followed by a Push of the new value.
The complexity is O(log n) where n = h.Len().
func (*Heap[E]) Init ¶
func (h *Heap[E]) Init()
Init establishes the heap invariants required by the other routines in this package. Init is idempotent with respect to the heap invariants and may be called whenever the heap invariants may have been invalidated.
The complexity is O(n) where n = h.Len().
func (*Heap[E]) Pop ¶
func (h *Heap[E]) Pop() E
Pop removes and returns the minimum element (according to Less) from the heap. Pop is equivalent to Remove(h, 0).
The complexity is O(log n) where n = h.Len().
type HeapFunc ¶
HeapFunc implements a min-heap with custom comparison.
func (*HeapFunc[E]) Fix ¶
Fix re-establishes the heap ordering after the element at index i has changed its value. Changing the value of the element at index i and then calling Fix is equivalent to, but less expensive than, calling Remove(h, i) followed by a Push of the new value.
The complexity is O(log n) where n = h.Len().
func (*HeapFunc[E]) Init ¶
func (h *HeapFunc[E]) Init()
Init establishes the heap invariants required by the other routines in this package. Init is idempotent with respect to the heap invariants and may be called whenever the heap invariants may have been invalidated.
The complexity is O(n) where n = h.Len().
func (*HeapFunc[E]) Pop ¶
func (h *HeapFunc[E]) Pop() E
Pop removes and returns the minimum element (according to Less) from the heap. Pop is equivalent to Remove(h, 0).
The complexity is O(log n) where n = h.Len().
type RadixMap ¶
type RadixMap[E any] struct { // contains filtered or unexported fields }
func (*RadixMap[E]) All ¶
All returns an iterator over all key/value pairs in the map. The key must not be retained by the caller and is only valid until the next iteration.
func (*RadixMap[E]) Delete ¶
Delete the value stored under key. Returns the previous value stored under key, if any.
func (*RadixMap[E]) PrefixesOf ¶
PrefixesOf returns an iterator over all key/value pairs in the map which are a prefix of s. The key must not be retained by the caller and is only valid until the next iteration.
type RadixSet ¶
type RadixSet RadixMap[struct{}]
RadixSet is a set of strings, stored as a radix tree.
func (*RadixSet) All ¶
All returns an iterator over all the elements in the set. The value must not be retained by the caller and is only valid until the next iteration.
func (*RadixSet) PrefixesOf ¶
PrefixesOf returns an iterator over all elements in the set which are a prefix of s. The value must not be retained by the caller and is only valid until the next iteration.