bimap

package
v1.45.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package bimap from: https://github.com/vishalkuo/bimap

Package bimap from: https://github.com/vishalkuo/bimap

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseBiMap

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

func (*BaseBiMap[K, V]) Delete

func (b *BaseBiMap[K, V]) Delete(k K) bool

func (*BaseBiMap[K, V]) DeleteInverse

func (b *BaseBiMap[K, V]) DeleteInverse(v V) bool

func (*BaseBiMap[K, V]) Exists

func (b *BaseBiMap[K, V]) Exists(k K) bool

func (*BaseBiMap[K, V]) ExistsInverse

func (b *BaseBiMap[K, V]) ExistsInverse(k V) bool

func (*BaseBiMap[K, V]) Get

func (b *BaseBiMap[K, V]) Get(k K) (V, bool)

func (*BaseBiMap[K, V]) GetForwardMap

func (b *BaseBiMap[K, V]) GetForwardMap() map[K]V

func (*BaseBiMap[K, V]) GetInverse

func (b *BaseBiMap[K, V]) GetInverse(v V) (K, bool)

func (*BaseBiMap[K, V]) GetInverseMap

func (b *BaseBiMap[K, V]) GetInverseMap() map[V]K

func (*BaseBiMap[K, V]) Insert

func (b *BaseBiMap[K, V]) Insert(k K, v V) bool

func (*BaseBiMap[K, V]) MakeImmutable

func (b *BaseBiMap[K, V]) MakeImmutable()

func (*BaseBiMap[K, V]) Reset

func (b *BaseBiMap[K, V]) Reset()

func (*BaseBiMap[K, V]) Size

func (b *BaseBiMap[K, V]) Size() int

type HashBiMap

type HashBiMap[K hashable, V hashable] struct {
	// contains filtered or unexported fields
}

func (*HashBiMap[K, V]) Delete

func (b *HashBiMap[K, V]) Delete(k K) bool

func (*HashBiMap[K, V]) DeleteInverse

func (b *HashBiMap[K, V]) DeleteInverse(v V) bool

func (*HashBiMap[K, V]) Exists

func (b *HashBiMap[K, V]) Exists(k K) bool

func (*HashBiMap[K, V]) ExistsInverse

func (b *HashBiMap[K, V]) ExistsInverse(k V) bool

func (*HashBiMap[K, V]) Get

func (b *HashBiMap[K, V]) Get(k K) (V, bool)

func (*HashBiMap[K, V]) GetForwardMap

func (b *HashBiMap[K, V]) GetForwardMap() map[K]V

func (*HashBiMap[K, V]) GetInverse

func (b *HashBiMap[K, V]) GetInverse(v V) (K, bool)

func (*HashBiMap[K, V]) GetInverseMap

func (b *HashBiMap[K, V]) GetInverseMap() map[V]K

func (*HashBiMap[K, V]) Insert

func (b *HashBiMap[K, V]) Insert(k K, v V) bool

func (*HashBiMap[K, V]) MakeImmutable

func (b *HashBiMap[K, V]) MakeImmutable()

func (*HashBiMap[K, V]) Reset

func (b *HashBiMap[K, V]) Reset()

func (*HashBiMap[K, V]) Size

func (b *HashBiMap[K, V]) Size() int

type IBiMap

type IBiMap[K comparable, V comparable] interface {
	// Insert adds a key-value pair to the map. Returns true if successful, false if the map is immutable.
	Insert(k K, v V) bool

	// Exists checks if the specified key exists in the forward map. Returns true if the key exists.
	Exists(k K) bool

	// ExistsInverse checks if the specified value exists in the inverse map. Returns true if the value exists.
	ExistsInverse(k V) bool

	// Get retrieves the value corresponding to the given key. Returns the value and a bool indicating success.
	Get(k K) (V, bool)

	// GetInverse retrieves the key corresponding to the given value. Returns the key and a bool indicating success.
	GetInverse(v V) (K, bool)

	// Delete removes the entry associated with the given key. Returns true if successful, false if the map is immutable.
	Delete(k K) bool

	// DeleteInverse removes the entry associated with the given value. Returns true if successful, false if immutable.
	DeleteInverse(v V) bool

	// GetInverseMap returns a copy of the inverse map (value-to-key mapping) for external use.
	GetInverseMap() map[V]K

	// GetForwardMap returns a copy of the forward map (key-to-value mapping) for external use.
	GetForwardMap() map[K]V

	// MakeImmutable converts the map to an immutable state, preventing further insertions or modifications.
	MakeImmutable()

	// Size returns the number of entries currently stored in the map.
	Size() int

	// Reset clears all entries in the map, resetting it to an empty state. No effect if the map is immutable.
	Reset()
	// contains filtered or unexported methods
}

IBiMap represents a bidirectional map interface allowing key-value and value-key lookups with mutual exclusivity.

func NewBaseMap

func NewBaseMap[K comparable, V comparable]() IBiMap[K, V]

func NewBaseMapFromMap

func NewBaseMapFromMap[K comparable, V comparable](f map[K]V) IBiMap[K, V]

func NewHashMap

func NewHashMap[K hashable, V hashable]() IBiMap[K, V]

func NewHashMapFromMap

func NewHashMapFromMap[K hashable, V hashable](f map[K]V) IBiMap[K, V]

func NewImmutableBaseMap

func NewImmutableBaseMap[K comparable, V comparable](f map[K]V) IBiMap[K, V]

func NewImmutableHashMap

func NewImmutableHashMap[K hashable, V hashable](f map[K]V) IBiMap[K, V]

Jump to

Keyboard shortcuts

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