store

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: Apache-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SetStore

type SetStore[T comparable] interface {
	Add(items ...T)
	Remove(item T) error
	Discard(items ...T)
	Len() int
	IsEmpty() bool
	Contains(item T) bool
	Pop() (T, error)
	Items() []T
	For(func(item T))
	ForWithBreak(func(item T) bool)
	MarshalJSON() ([]byte, error)
	UnmarshalJSON(b []byte) error
}

type SimpleSetStore

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

func NewSimpleStore

func NewSimpleStore[T comparable]() *SimpleSetStore[T]

func (*SimpleSetStore[T]) Add

func (s *SimpleSetStore[T]) Add(items ...T)

Add adds item(s) to the store

func (*SimpleSetStore[T]) Contains

func (s *SimpleSetStore[T]) Contains(item T) bool

Contains returns whether an item is in the store

func (*SimpleSetStore[T]) Discard

func (s *SimpleSetStore[T]) Discard(items ...T)

Discard removes item(s) from the store if exist See also: Remove()

func (*SimpleSetStore[T]) For

func (s *SimpleSetStore[T]) For(f func(item T))

For runs a function on all the items in the store

func (*SimpleSetStore[T]) ForWithBreak

func (s *SimpleSetStore[T]) ForWithBreak(f func(item T) bool)

ForWithBreak runs a function on all the items in the store if f returns false, the iteration stops

func (*SimpleSetStore[T]) IsEmpty

func (s *SimpleSetStore[T]) IsEmpty() bool

IsEmpty returns true if there are no items in the store

func (*SimpleSetStore[T]) Items

func (s *SimpleSetStore[T]) Items() []T

Items returns a slice of all the Set items

func (*SimpleSetStore[T]) Len

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

Len returns the number of items in the store

func (*SimpleSetStore[T]) MarshalJSON added in v1.2.0

func (s *SimpleSetStore[T]) MarshalJSON() ([]byte, error)

func (*SimpleSetStore[T]) Pop

func (s *SimpleSetStore[T]) Pop() (T, error)

Pop removes an arbitrary item from the store and returns it. Returns error if the store is empty

func (*SimpleSetStore[T]) Remove

func (s *SimpleSetStore[T]) Remove(item T) error

Remove removes a single item from the store. Returns error if the item is not in the Set See also: Discard()

func (*SimpleSetStore[T]) UnmarshalJSON added in v1.2.0

func (s *SimpleSetStore[T]) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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