Documentation
¶
Overview ¶
Package set contains some nifty tools for manipulating sets of data, including implementations for slices AND maps. This package should probably make its way into rosetta, once things settle down.
Index ¶
- func Copy[V Value, S Set[V]](from S, to S)
- func Each[V Value, S Set[V]](set Set[V], f func(V))
- func Intersect[V Value, S Set[V]](left S, right S, target S)
- func MaxKey[V Value, S Set[V]](set S) string
- func Reduce[V Value, S Set[V], R any](set S, f func(V, R) R) R
- type Map
- type Set
- type Slice
- func (set *Slice[V]) Append(value V)
- func (set *Slice[V]) Delete(key string)
- func (set Slice[V]) Get(key string) (V, bool)
- func (set Slice[V]) GetAll() <-chan V
- func (set *Slice[V]) GetPointer(name string) (any, bool)
- func (set Slice[V]) Keys() []string
- func (set Slice[V]) Len() int
- func (set Slice[V]) Length() int
- func (set Slice[V]) Less(i int, j int) bool
- func (set *Slice[V]) Put(value V)
- func (set *Slice[V]) Remove(name string)
- func (set *Slice[V]) Sort()
- func (set *Slice[V]) Swap(i int, j int)
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Intersect ¶
Intersect returns a new store that contains only the items that are in both stores.
Types ¶
type Map ¶
Map is a simple in-memory map-based set for arbitrary data.
func (Map[V]) Get ¶
Get returns the object with the given ID. If no object with the given ID is found, Get returns an empty object.
func (Map[V]) GetAll ¶
func (set Map[V]) GetAll() <-chan V
GetAll returns a channel that will yield all of the items in the set.
type Set ¶
type Set[V Value] interface { Len() int Keys() []string Get(key string) (V, bool) GetAll() <-chan V Put(value V) Delete(key string) }
TODO: Should we migrate the `set` package to Rosetta? Interop with other libs, like `sliceof` and `mapof`? Set interface defines the functions that a set must implement
type Slice ¶
type Slice[V Value] []V
Slice is a simple in-memory slice-based set for arbitrary data.
func (Slice[V]) Get ¶
Get returns the object with the given ID. If no object with the given ID is found, Get returns an empty object.
func (Slice[V]) GetAll ¶
func (set Slice[V]) GetAll() <-chan V
GetAll returns a channel that will yield all of the items in the store.