gbimap

package
v0.0.0-...-2bcc11b Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: GPL-3.0 Imports: 2 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 struct {
	// contains filtered or unexported fields
}

BiMap is a bi-directional map

func NewBiMap

func NewBiMap(initialValues ...Tuple) (*BiMap, error)

NewBiMap creates a new bi-directional map

func (*BiMap) DelByKey

func (bm *BiMap) DelByKey(key any) error

DelByKey deletes a key-value pair from a key. Returns an error if provided argument is not a key

func (*BiMap) DelByVal

func (bm *BiMap) DelByVal(value any) error

DelByVal deletes a key-value pair from a value. Returns an error if provided argument is not a value

func (*BiMap) GetKeyByVal

func (bm *BiMap) GetKeyByVal(value any) any

GetKeyByVal gets a key from a value

func (*BiMap) GetValByKey

func (bm *BiMap) GetValByKey(key any) any

GetValByKey gets a value from a key

func (*BiMap) IsEqual

func (bm *BiMap) IsEqual(otherBm BiMap) bool

IsEqual checks if a BiMap is equal to another

func (*BiMap) Keys

func (bm *BiMap) Keys() []any

Keys returns a slice with all the BiMap keys

func (*BiMap) Left

func (bm *BiMap) Left() map[any]any

Left returns the "key: value" mapping of the BiMap

func (*BiMap) Right

func (bm *BiMap) Right() map[any]any

Right returns the "value: key" mapping of the BiMap

func (*BiMap) Set

func (bm *BiMap) Set(key any, value any) error

Set sets a key-value pair on the map. Returns an error if key or value is duplicate

func (*BiMap) Size

func (bm *BiMap) Size() int

Size returns the size of the map

func (*BiMap) Vals

func (bm *BiMap) Vals() []any

Vals returns a slice with all the BiMap values

type Tuple

type Tuple struct {
	// contains filtered or unexported fields
}

Tuple is a key-value pair used to initialized a new BiMap with values

Jump to

Keyboard shortcuts

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