bimap

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BiMap

type BiMap[K comparable, V comparable] struct {
	// contains filtered or unexported fields
}

BiMap a bi-directional map which is safe to use concurently.

func New

func New[K comparable, V comparable]() *BiMap[K, V]

New creates a new BiMap.

func NewFromMap

func NewFromMap[K comparable, V comparable](values map[K]V) *BiMap[K, V]

NewFromMap creates a new BiMap from a normal map.

func (*BiMap[K, V]) Delete

func (m *BiMap[K, V]) Delete(k K)

Delete removes an element from the map by key in the forward direction.

func (*BiMap[K, V]) DeleteBackwards

func (m *BiMap[K, V]) DeleteBackwards(v V)

DeleteBackwards deltes an element from the map by key in the backward direction.

func (*BiMap[K, V]) Exists

func (m *BiMap[K, V]) Exists(k K) bool

Exists checks if an element exists in forward direction.

func (*BiMap[K, V]) ExistsBackwards

func (m *BiMap[K, V]) ExistsBackwards(v V) bool

ExistsBackwards checks if an element exists in backward direction.

func (*BiMap[K, V]) Get

func (m *BiMap[K, V]) Get(k K) (V, bool)

Get returns an element from the map in forward direction if exists.

func (*BiMap[K, V]) GetBackwards

func (m *BiMap[K, V]) GetBackwards(v V) (K, bool)

GetBackwards returns an element form the map in backward direction if exists.

func (*BiMap[K, V]) Insert

func (m *BiMap[K, V]) Insert(k K, v V)

Insert inserts a new element in the BiMap.

func (*BiMap[K, V]) Size

func (m *BiMap[K, V]) Size() int

Size returns the size of the map.

Jump to

Keyboard shortcuts

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