bimap

package
v0.1.79 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 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 Map

type Map[A, B comparable] struct {
	// contains filtered or unexported fields
}

Map is a simple BiMap. It can be inverted to get the other side.

func (*Map[A, B]) Delete

func (m *Map[A, B]) Delete(a A) (change bool)

func (*Map[A, B]) DeleteFar

func (m *Map[A, B]) DeleteFar(b B) (change bool)

func (*Map[A, B]) Get

func (m *Map[A, B]) Get(a A) (b B, has bool)

func (*Map[A, B]) GetFar

func (m *Map[A, B]) GetFar(b B) (a A, has bool)

func (*Map[A, B]) Invert

func (m *Map[A, B]) Invert() (out *Map[B, A])

func (*Map[A, B]) Iter added in v0.1.66

func (m *Map[A, B]) Iter() (it iter.Seq2[A, B])

func (*Map[A, B]) Len

func (m *Map[A, B]) Len() (length int)

func (*Map[A, B]) Put

func (m *Map[A, B]) Put(a A, b B) (ok bool)

type OwnerMap

type OwnerMap[Owner comparable, Sub comparable] struct {
	// contains filtered or unexported fields
}

OwnerMap is a map of one owner to many subordinates.

func (*OwnerMap[O, S]) Add

func (m *OwnerMap[O, S]) Add(owner O, sub S) (ok bool)

Add adds the given sub to the owner. Fails if the sub is already owned.

func (*OwnerMap[O, S]) Clear

func (m *OwnerMap[O, S]) Clear(owner O) (was []S)

Clear removes all ownership records for the given Owner. Returns the prior records.

func (*OwnerMap[O, S]) Owner

func (m *OwnerMap[O, S]) Owner(sub S) (owner O, ok bool)

func (*OwnerMap[O, S]) Release

func (m *OwnerMap[O, S]) Release(sub S) (owner O, ok bool)

func (*OwnerMap[O, S]) Size

func (m *OwnerMap[O, S]) Size() (owners, subs int)

Jump to

Keyboard shortcuts

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