Documentation
¶
Index ¶
- type SetStore
- type SimpleSetStore
- func (s *SimpleSetStore[T]) Add(items ...T)
- func (s *SimpleSetStore[T]) Contains(item T) bool
- func (s *SimpleSetStore[T]) Discard(items ...T)
- func (s *SimpleSetStore[T]) For(f func(item T))
- func (s *SimpleSetStore[T]) ForWithBreak(f func(item T) bool)
- func (s *SimpleSetStore[T]) IsEmpty() bool
- func (s *SimpleSetStore[T]) Items() []T
- func (s *SimpleSetStore[T]) Len() int
- func (s *SimpleSetStore[T]) MarshalJSON() ([]byte, error)
- func (s *SimpleSetStore[T]) Pop() (T, error)
- func (s *SimpleSetStore[T]) Remove(item T) error
- func (s *SimpleSetStore[T]) UnmarshalJSON(b []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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