Documentation
¶
Overview ¶
Package treebidimap implements a bidirectional map backed by two red-black tree.
This structure guarantees that the map will be in both ascending key and value order.
Other than key and value ordering, the goal with this structure is to avoid duplication of elements, which can be significant if contained elements are large.
A bidirectional map, or hash bag, is an associative data structure in which the (key,value) pairs form a one-to-one correspondence. Thus the binary relation is functional in each direction: value can also act as a key to key. A pair (a,b) thus provides a unique coupling between 'a' and 'b' so that 'b' can be found when 'a' is used as a key and 'a' can be found when 'b' is used as a key.
Structure is not thread safe.
Index ¶
- type Map
- func (m *Map[K, V]) Begin() (k K, v V, ok bool)
- func (m *Map[K, V]) Clear()
- func (m *Map[K, V]) Clone() container.Map[K, V]
- func (m *Map[K, V]) Delete(k K) (v V, ok bool)
- func (m *Map[K, V]) DeleteBegin() (k K, v V, ok bool)
- func (m *Map[K, V]) DeleteEnd() (k K, v V, ok bool)
- func (m *Map[K, V]) DeleteValue(v V) (k K, ok bool)
- func (m *Map[K, V]) End() (k K, v V, ok bool)
- func (m *Map[K, V]) Entries() ([]K, []V)
- func (m *Map[K, V]) Get(k K) (v V, ok bool)
- func (m *Map[K, V]) GetKey(v V) (k K, ok bool)
- func (m *Map[K, V]) Has(k K) bool
- func (m *Map[K, V]) HasValue(v V) bool
- func (m *Map[K, V]) IsEmpty() bool
- func (m *Map[K, V]) Iter() iter.Seq2[K, V]
- func (m *Map[K, V]) Keys() []K
- func (m *Map[K, V]) Len() int
- func (m *Map[K, V]) MarshalJSON() ([]byte, error)
- func (m *Map[K, V]) Put(k K, v V)
- func (m *Map[K, V]) RIter() iter.Seq2[K, V]
- func (m *Map[K, V]) String() string
- func (m *Map[K, V]) ToSlice() []V
- func (m *Map[K, V]) UnmarshalJSON(data []byte) error
- func (m *Map[K, V]) Values() []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K, V comparable] struct { // contains filtered or unexported fields }
func NewWith ¶
func NewWith[K, V comparable](kcmp cmp.Comparator[K], vcmp cmp.Comparator[V]) *Map[K, V]