rbtreebimap

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2025 License: MIT Imports: 7 Imported by: 0

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.

Reference: https://en.wikipedia.org/wiki/Bidirectional_map

Index

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 New

func New[K, V cmp.Ordered]() *Map[K, V]

func NewWith

func NewWith[K, V comparable](kcmp cmp.Comparator[K], vcmp cmp.Comparator[V]) *Map[K, V]

func (*Map[K, V]) Begin added in v0.9.0

func (m *Map[K, V]) Begin() (k K, v V, ok bool)

func (*Map[K, V]) Clear

func (m *Map[K, V]) Clear()

func (*Map[K, V]) Clone added in v0.9.0

func (m *Map[K, V]) Clone() container.Map[K, V]

func (*Map[K, V]) Delete added in v0.9.0

func (m *Map[K, V]) Delete(k K) (v V, ok bool)

func (*Map[K, V]) DeleteBegin added in v0.9.0

func (m *Map[K, V]) DeleteBegin() (k K, v V, ok bool)

func (*Map[K, V]) DeleteEnd added in v0.9.0

func (m *Map[K, V]) DeleteEnd() (k K, v V, ok bool)

func (*Map[K, V]) DeleteValue added in v0.9.0

func (m *Map[K, V]) DeleteValue(v V) (k K, ok bool)

func (*Map[K, V]) End added in v0.9.0

func (m *Map[K, V]) End() (k K, v V, ok bool)

func (*Map[K, V]) Entries added in v0.9.0

func (m *Map[K, V]) Entries() ([]K, []V)

func (*Map[K, V]) Get

func (m *Map[K, V]) Get(k K) (v V, ok bool)

func (*Map[K, V]) GetKey

func (m *Map[K, V]) GetKey(v V) (k K, ok bool)

func (*Map[K, V]) Has added in v0.9.0

func (m *Map[K, V]) Has(k K) bool

func (*Map[K, V]) HasValue added in v0.9.0

func (m *Map[K, V]) HasValue(v V) bool

func (*Map[K, V]) IsEmpty added in v0.9.0

func (m *Map[K, V]) IsEmpty() bool

func (*Map[K, V]) Iter added in v0.9.0

func (m *Map[K, V]) Iter() iter.Seq2[K, V]

func (*Map[K, V]) Keys

func (m *Map[K, V]) Keys() []K

func (*Map[K, V]) Len

func (m *Map[K, V]) Len() int

func (*Map[K, V]) MarshalJSON

func (m *Map[K, V]) MarshalJSON() ([]byte, error)

func (*Map[K, V]) Put

func (m *Map[K, V]) Put(k K, v V)

func (*Map[K, V]) RIter added in v0.9.0

func (m *Map[K, V]) RIter() iter.Seq2[K, V]

func (*Map[K, V]) String

func (m *Map[K, V]) String() string

func (*Map[K, V]) ToSlice added in v0.9.0

func (m *Map[K, V]) ToSlice() []V

func (*Map[K, V]) UnmarshalJSON

func (m *Map[K, V]) UnmarshalJSON(data []byte) error

func (*Map[K, V]) Values

func (m *Map[K, V]) Values() []V

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL