set

package
v0.0.0-...-32842ed Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 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 OrderedSet

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

OrderedSet is same as Set but remembers insertion order.

func NewOrdered

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

func (*OrderedSet[T]) Add

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

func (*OrderedSet[T]) Clear

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

func (*OrderedSet[T]) Delete

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

func (*OrderedSet[T]) ForEach

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

ForEach iterates over set and invoke f with each elements. The order is FIFO. Add with an existing v does not update the order.

func (*OrderedSet[T]) Has

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

func (*OrderedSet[T]) Len

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

func (OrderedSet[T]) MarshalJSON

func (s OrderedSet[T]) MarshalJSON() ([]byte, error)

func (*OrderedSet[T]) UnmarshalJSON

func (s *OrderedSet[T]) UnmarshalJSON(data []byte) error

func (*OrderedSet[T]) Values

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

type Set

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

func New

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() []T

type SetLike

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() []T
}

Jump to

Keyboard shortcuts

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