Documentation
¶
Overview ¶
Package bimap from: https://github.com/vishalkuo/bimap
Package bimap from: https://github.com/vishalkuo/bimap
Index ¶
- type BaseBiMap
- func (b *BaseBiMap[K, V]) Delete(k K) bool
- func (b *BaseBiMap[K, V]) DeleteInverse(v V) bool
- func (b *BaseBiMap[K, V]) Exists(k K) bool
- func (b *BaseBiMap[K, V]) ExistsInverse(k V) bool
- func (b *BaseBiMap[K, V]) Get(k K) (V, bool)
- func (b *BaseBiMap[K, V]) GetForwardMap() map[K]V
- func (b *BaseBiMap[K, V]) GetInverse(v V) (K, bool)
- func (b *BaseBiMap[K, V]) GetInverseMap() map[V]K
- func (b *BaseBiMap[K, V]) Insert(k K, v V) bool
- func (b *BaseBiMap[K, V]) MakeImmutable()
- func (b *BaseBiMap[K, V]) Reset()
- func (b *BaseBiMap[K, V]) Size() int
- type HashBiMap
- func (b *HashBiMap[K, V]) Delete(k K) bool
- func (b *HashBiMap[K, V]) DeleteInverse(v V) bool
- func (b *HashBiMap[K, V]) Exists(k K) bool
- func (b *HashBiMap[K, V]) ExistsInverse(k V) bool
- func (b *HashBiMap[K, V]) Get(k K) (V, bool)
- func (b *HashBiMap[K, V]) GetForwardMap() map[K]V
- func (b *HashBiMap[K, V]) GetInverse(v V) (K, bool)
- func (b *HashBiMap[K, V]) GetInverseMap() map[V]K
- func (b *HashBiMap[K, V]) Insert(k K, v V) bool
- func (b *HashBiMap[K, V]) MakeImmutable()
- func (b *HashBiMap[K, V]) Reset()
- func (b *HashBiMap[K, V]) Size() int
- type IBiMap
- func NewBaseMap[K comparable, V comparable]() IBiMap[K, V]
- func NewBaseMapFromMap[K comparable, V comparable](f map[K]V) IBiMap[K, V]
- func NewHashMap[K hashable, V hashable]() IBiMap[K, V]
- func NewHashMapFromMap[K hashable, V hashable](f map[K]V) IBiMap[K, V]
- func NewImmutableBaseMap[K comparable, V comparable](f map[K]V) IBiMap[K, V]
- func NewImmutableHashMap[K hashable, V hashable](f map[K]V) IBiMap[K, V]
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]) DeleteInverse ¶
func (*BaseBiMap[K, V]) ExistsInverse ¶
func (*BaseBiMap[K, V]) GetForwardMap ¶
func (b *BaseBiMap[K, V]) GetForwardMap() map[K]V
func (*BaseBiMap[K, V]) GetInverse ¶
func (*BaseBiMap[K, V]) GetInverseMap ¶
func (b *BaseBiMap[K, V]) GetInverseMap() map[V]K
func (*BaseBiMap[K, V]) MakeImmutable ¶
func (b *BaseBiMap[K, V]) MakeImmutable()
type HashBiMap ¶
type HashBiMap[K hashable, V hashable] struct {
// contains filtered or unexported fields
}
func (*HashBiMap[K, V]) DeleteInverse ¶
func (*HashBiMap[K, V]) ExistsInverse ¶
func (*HashBiMap[K, V]) GetForwardMap ¶
func (b *HashBiMap[K, V]) GetForwardMap() map[K]V
func (*HashBiMap[K, V]) GetInverse ¶
func (*HashBiMap[K, V]) GetInverseMap ¶
func (b *HashBiMap[K, V]) GetInverseMap() map[V]K
func (*HashBiMap[K, V]) MakeImmutable ¶
func (b *HashBiMap[K, V]) MakeImmutable()
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]
Click to show internal directories.
Click to hide internal directories.