set

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: Apache-2.0 Imports: 2 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OrderedSet added in v0.0.9

type OrderedSet[T comparable] struct {
	// contains filtered or unexported fields
}

OrderedSet is same as Set but remembers insertion order.

func NewOrdered added in v0.0.9

func NewOrdered[T comparable]() *OrderedSet[T]

func (*OrderedSet[T]) Add added in v0.0.9

func (s *OrderedSet[T]) Add(v T)

func (*OrderedSet[T]) Clear added in v0.0.9

func (s *OrderedSet[T]) Clear()

func (*OrderedSet[T]) Delete added in v0.0.9

func (s *OrderedSet[T]) Delete(v T) (deleted bool)

func (*OrderedSet[T]) ForEach added in v0.0.9

func (s *OrderedSet[T]) ForEach(f func(v T, idx int))

ForEach iterates over set and invoke f with each elements. Order is FIFO. Call of Add with existing v does not change order.

func (*OrderedSet[T]) Has added in v0.0.9

func (s *OrderedSet[T]) Has(v T) (has bool)

func (*OrderedSet[T]) Len added in v0.0.9

func (s *OrderedSet[T]) Len() int

func (*OrderedSet[T]) Values added in v0.0.9

func (s *OrderedSet[T]) Values() iterator.Iterator[T]

type Set

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

func New added in v0.0.9

func New[T comparable]() *Set[T]

func (*Set[T]) Add

func (s *Set[T]) Add(v T)

func (*Set[T]) Clear

func (s *Set[T]) Clear()

func (*Set[T]) Delete

func (s *Set[T]) Delete(v T) (deleted bool)

func (*Set[T]) ForEach

func (s *Set[T]) ForEach(f func(v T, idx int))

Order is undefined.

func (*Set[T]) Has

func (s *Set[T]) Has(v T) (has bool)

func (*Set[T]) Len

func (s *Set[T]) Len() int

func (*Set[T]) Values

func (s *Set[T]) Values() iterator.Iterator[T]

type SetLike added in v0.2.0

type SetLike[T comparable] interface {
	Len() int
	Add(v T)
	Clear()
	Delete(v T) (deleted bool)
	ForEach(f func(v T, idx int))
	Has(v T) (has bool)
	Values() iterator.Iterator[T]
}

Jump to

Keyboard shortcuts

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