mapset

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator added in v1.3.3

type Iterator[T any] struct {
	// contains filtered or unexported fields
}

Iterator is an iterator over a set.

func (Iterator[T]) Get added in v1.3.3

func (it Iterator[T]) Get() T

Get returns the current element.

func (Iterator[T]) Move added in v1.4.0

func (it Iterator[T]) Move()

Move moves the iterator to the next element.

func (Iterator[T]) Remove added in v1.4.0

func (it Iterator[T]) Remove()

Remove removes the current element from the set.

func (Iterator[T]) Valid added in v1.4.0

func (it Iterator[T]) Valid() bool

Valid returns true if the iterator is pointing to a valid element.

type Set added in v1.4.0

type Set[T any] struct {
	// contains filtered or unexported fields
}

Set is a set implementation based on maps. Keys are elements of the set, and values are empty structs.

func FromMap added in v1.3.2

func FromMap[T any](m maps.Map[T, empty]) Set[T]

FromMap creates a new set from a map.

func NewHashSet

func NewHashSet[T comparable]() Set[T]

NewHashSet creates a new hash set for comparable types.

func NewTreeSet added in v1.4.0

func NewTreeSet[T cmp.Ordered]() Set[T]

NewTreeSet creates a new tree set for ordered types.

func (Set[T]) Add added in v1.4.0

func (s Set[T]) Add(value T)

Add adds a value to the set.

func (Set[T]) Clear added in v1.4.0

func (s Set[T]) Clear()

Clear removes all elements from the set.

func (Set[T]) Clone added in v1.4.0

func (s Set[T]) Clone() sets.Set[T]

Clone returns a shallow copy of the set.

func (Set[T]) Contains added in v1.4.0

func (s Set[T]) Contains(value T) bool

Contains returns true if the set contains the value.

func (Set[T]) Iterator added in v1.4.0

func (s Set[T]) Iterator() iter.Iterator[T]

Iterator returns an iter.Iterator over the set.

func (Set[T]) Map added in v1.4.0

func (s Set[T]) Map() maps.Map[T, empty]

Map returns the underlying map.

func (Set[T]) Remove added in v1.4.0

func (s Set[T]) Remove(value T)

Remove removes a value from the set.

func (Set[T]) SetIterator added in v1.5.0

func (s Set[T]) SetIterator() sets.Iterator[T]

SetIterator returns an iterator over the set.

func (Set[T]) Size added in v1.4.0

func (s Set[T]) Size() int

Size returns the number of elements in the set.

func (Set[T]) Stream added in v1.4.0

func (s Set[T]) Stream(yield func(T) bool)

Stream streams the elements of the Set.

Jump to

Keyboard shortcuts

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