setmap

package
v1.11.10-rc.3 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: BSD-3-Clause Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry[K any, V comparable] struct {
	Key K
	Set set.Set[V]
}

type SetMap

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

SetMap is a map to a set where all sets are non-overlapping.

func New

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

New creates a new empty setmap.

func (*SetMap[K, V]) DeleteKey

func (m *SetMap[K, V]) DeleteKey(key K) (set.Set[V], bool)

DeleteKey removes [key] from the map and returns the set it mapped to.

func (*SetMap[K, V]) DeleteOverlapping

func (m *SetMap[K, V]) DeleteOverlapping(set set.Set[V]) []Entry[K, V]

DeleteOverlapping removes and returns all the entries where the set overlaps with set.

func (*SetMap[K, V]) DeleteValue

func (m *SetMap[K, V]) DeleteValue(val V) (K, set.Set[V], bool)

DeleteValue removes and returns the entry that contained [val].

func (*SetMap[K, V]) GetKey

func (m *SetMap[K, V]) GetKey(val V) (K, bool)

GetKey that maps to the provided value.

func (*SetMap[K, V]) GetSet

func (m *SetMap[K, V]) GetSet(key K) (set.Set[V], bool)

GetSet that is mapped to by the provided key.

func (*SetMap[K, _]) HasKey

func (m *SetMap[K, _]) HasKey(key K) bool

HasKey returns true if [key] is in the map.

func (*SetMap[_, V]) HasOverlap

func (m *SetMap[_, V]) HasOverlap(set set.Set[V]) bool

HasOverlap returns true if set overlaps with any of the sets in the map.

func (*SetMap[_, V]) HasValue

func (m *SetMap[_, V]) HasValue(val V) bool

HasValue returns true if [val] is in a set in the map.

func (*SetMap[K, V]) Len

func (m *SetMap[K, V]) Len() int

Len return the number of sets in the map.

func (*SetMap[K, V]) LenValues

func (m *SetMap[K, V]) LenValues() int

LenValues return the total number of values across all sets in the map.

func (*SetMap[K, V]) Put

func (m *SetMap[K, V]) Put(key K, set set.Set[V]) []Entry[K, V]

Put the new entry into the map. Removes and returns: * The existing entry for [key]. * Existing entries where the set overlaps with the set.

Jump to

Keyboard shortcuts

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