Documentation
¶
Overview ¶
Package ordered provides mutable ordered collection implementations
Index ¶
- type Map
- func MapFromSeq2[K comparable, V any](seq seq.Seq2[K, V]) *Map[K, V]
- func NewMap[K comparable, V any](elements ...c.KV[K, V]) *Map[K, V]
- func NewMapCap[K comparable, V any](capacity int) *Map[K, V]
- func NewMapOf[K comparable, V any](order []K, elements map[K]V) *Map[K, V]
- func WrapMap[K comparable, V any](order []K, elements map[K]V) *Map[K, V]
- func (m *Map[K, V]) All(consumer func(K, V) bool)
- func (m *Map[K, V]) Contains(key K) bool
- func (m *Map[K, V]) Conv(converter func(K, V) (K, V, error)) seq.SeqE[c.KV[K, V]]
- func (m *Map[K, V]) ConvKey(converter func(K) (K, error)) seq.SeqE[c.KV[K, V]]
- func (m *Map[K, V]) ConvValue(converter func(V) (V, error)) seq.SeqE[c.KV[K, V]]
- func (m *Map[K, V]) Convert(converter func(K, V) (K, V)) seq.Seq2[K, V]
- func (m *Map[K, V]) ConvertKey(converter func(K) K) seq.Seq2[K, V]
- func (m *Map[K, V]) ConvertValue(converter func(V) V) seq.Seq2[K, V]
- func (m *Map[K, V]) Filt(filter func(K, V) (bool, error)) seq.SeqE[c.KV[K, V]]
- func (m *Map[K, V]) FiltKey(filter func(K) (bool, error)) seq.SeqE[c.KV[K, V]]
- func (m *Map[K, V]) FiltValue(filter func(V) (bool, error)) seq.SeqE[c.KV[K, V]]
- func (m *Map[K, V]) Filter(filter func(K, V) bool) seq.Seq2[K, V]
- func (m *Map[K, V]) FilterKey(filter func(K) bool) seq.Seq2[K, V]
- func (m *Map[K, V]) FilterValue(filter func(V) bool) seq.Seq2[K, V]
- func (m *Map[K, V]) Get(key K) (V, bool)
- func (m *Map[K, V]) HasAny(condition func(K, V) bool) bool
- func (m *Map[K, V]) Head() (K, V, bool)
- func (m *Map[K, V]) Immutable() ordered.Map[K, V]
- func (m *Map[K, V]) IsEmpty() bool
- func (m *Map[K, V]) Keys() ordered.MapKeys[K]
- func (m *Map[K, V]) Len() int
- func (m *Map[K, V]) Map() map[K]V
- func (m *Map[K, V]) Reduce(merge func(K, K, V, V) (K, V)) (k K, v V)
- func (m *Map[K, V]) Set(key K, value V)
- func (m *Map[K, V]) SetMap(kvs c.TrackEach[K, V])
- func (m *Map[K, V]) SetNew(key K, value V) bool
- func (m *Map[K, V]) Sort(comparer slice.Comparer[K]) *Map[K, V]
- func (m *Map[K, V]) StableSort(comparer slice.Comparer[K]) *Map[K, V]
- func (m *Map[K, V]) String() string
- func (m *Map[K, V]) TrackEach(consumer func(K, V))
- func (m *Map[K, V]) Values() ordered.MapValues[K, V]
- type Set
- func (s *Set[T]) Add(elements ...T)
- func (s *Set[T]) AddAll(other seq.Seq[T])
- func (s *Set[T]) AddAllNew(other seq.Seq[T]) (ok bool)
- func (s *Set[T]) AddNew(elements ...T) bool
- func (s *Set[T]) AddOne(element T)
- func (s *Set[T]) AddOneNew(element T) (ok bool)
- func (s *Set[T]) All(consumer func(T) bool)
- func (s *Set[T]) Append(out []T) []T
- func (s *Set[T]) Clone() *Set[T]
- func (s *Set[T]) Contains(element T) (ok bool)
- func (s *Set[T]) Conv(converter func(T) (T, error)) seq.SeqE[T]
- func (s *Set[T]) Convert(converter func(T) T) seq.Seq[T]
- func (s *Set[T]) Delete(elements ...T)
- func (s *Set[T]) DeleteActual(elements ...T) bool
- func (s *Set[T]) DeleteActualOne(element T) bool
- func (s *Set[T]) DeleteOne(v T)
- func (s *Set[T]) Filt(filter func(T) (bool, error)) seq.SeqE[T]
- func (s *Set[T]) Filter(filter func(T) bool) seq.Seq[T]
- func (s *Set[T]) First(condition func(T) bool) (t T, ok bool)
- func (s *Set[T]) ForEach(consumer func(T))
- func (s *Set[T]) HasAny(condition func(T) bool) bool
- func (s *Set[T]) Head() (t T, ok bool)
- func (s *Set[T]) IAll(consumer func(int, T) bool)
- func (s *Set[T]) IsEmpty() bool
- func (s *Set[T]) Len() int
- func (s *Set[T]) Reduce(merge func(T, T) T) (t T)
- func (s *Set[T]) Slice() (out []T)
- func (s *Set[T]) Sort(comparer slice.Comparer[T]) *Set[T]
- func (s *Set[T]) StableSort(comparer slice.Comparer[T]) *Set[T]
- func (s *Set[T]) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Map is a collection implementation that provides elements access by an unique key.
func MapFromSeq2 ¶ added in v0.0.15
func MapFromSeq2[K comparable, V any](seq seq.Seq2[K, V]) *Map[K, V]
MapFromSeq2 creates a map with elements retrieved by the seq.
func NewMap ¶
func NewMap[K comparable, V any](elements ...c.KV[K, V]) *Map[K, V]
NewMap instantiates a map using key/value pairs
func NewMapCap ¶
func NewMapCap[K comparable, V any](capacity int) *Map[K, V]
NewMapCap instantiates Map with a predefined capacity
func NewMapOf ¶
func NewMapOf[K comparable, V any](order []K, elements map[K]V) *Map[K, V]
NewMapOf instantiates Map populated by the 'elements' map key/values
func WrapMap ¶
func WrapMap[K comparable, V any](order []K, elements map[K]V) *Map[K, V]
WrapMap instantiates an ordered Map using a map and an order slice as internal storage
func (*Map[K, V]) All ¶ added in v0.0.12
All is used to iterate through the collection using `for key, val := range`.
func (*Map[K, V]) Conv ¶
Conv returns an errorable seq that applies the 'converter' function to the collection elements
func (*Map[K, V]) ConvKey ¶
ConvKey returns a seq that applies the 'converter' function to keys of the map
func (*Map[K, V]) ConvValue ¶
ConvValue returns an errorable seq that applies the 'converter' function to values of the map
func (*Map[K, V]) Convert ¶
Convert returns a seq that applies the 'converter' function to the collection elements
func (*Map[K, V]) ConvertKey ¶
ConvertKey returns a seq that applies the 'converter' function to keys of the map
func (*Map[K, V]) ConvertValue ¶
ConvertValue returns a seq that applies the 'converter' function to values of the map
func (*Map[K, V]) Filt ¶
Filt returns an errorable seq consisting of elements that satisfy the condition of the 'filter' function
func (*Map[K, V]) FiltKey ¶
FiltKey returns a seq consisting of key/value pairs where the key satisfies the condition of the 'filter' function
func (*Map[K, V]) FiltValue ¶
FiltValue returns an errorable seq consisting of key/value pairs where the value satisfies the condition of the 'filter' function
func (*Map[K, V]) Filter ¶
Filter returns a seq consisting of elements that satisfy the condition of the 'filter' function
func (*Map[K, V]) FilterKey ¶
FilterKey returns a seq consisting of key/value pairs where the key satisfies the condition of the 'filter' function
func (*Map[K, V]) FilterValue ¶
FilterValue returns a seq consisting of key/value pairs where the value satisfies the condition of the 'filter' function
func (*Map[K, V]) Get ¶
Get returns the value for a key. If ok==false, then the map does not contain the key.
func (*Map[K, V]) HasAny ¶
HasAny checks whether the map contains a key\value pair that satisfies the condition.
func (*Map[K, V]) Map ¶
func (m *Map[K, V]) Map() map[K]V
Map collects the key/value pairs into a new map
func (*Map[K, V]) Reduce ¶
func (m *Map[K, V]) Reduce(merge func(K, K, V, V) (K, V)) (k K, v V)
Reduce reduces the key/value pairs of the map into an one pair using the 'merge' function
func (*Map[K, V]) StableSort ¶
StableSort sorts keys in-place (no copy)
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
Set is a collection implementation that provides element uniqueness and access order. Elements must be comparable.
func NewSet ¶
func NewSet[T comparable](elements ...T) *Set[T]
NewSet instantiates set and copies elements to it
func NewSetCap ¶
func NewSetCap[T comparable](capacity int) *Set[T]
NewSetCap creates a set with a predefined capacity
func SetFromSeq ¶ added in v0.0.15
func SetFromSeq[T comparable](seq seq.Seq[T]) *Set[T]
SetFromSeq creates a set with elements retrieved by the seq.
func WrapSet ¶
func WrapSet[T comparable](elements []T, uniques map[T]int) *Set[T]
WrapSet creates a set using a map and an order slice as the internal storage.
func (*Set[T]) AddAllNew ¶
AddAllNew inserts elements from the "other" sequence if they are not contained in the collection
func (*Set[T]) All ¶ added in v0.0.12
All is used to iterate through the collection using `for e := range`.
func (*Set[T]) Append ¶
func (s *Set[T]) Append(out []T) []T
Append collects the values to the specified 'out' slice
func (*Set[T]) Conv ¶
Conv returns an errorable seq that applies the 'converter' function to the collection elements
func (*Set[T]) Convert ¶
Convert returns a seq that applies the 'converter' function to the collection elements
func (*Set[T]) Delete ¶
func (s *Set[T]) Delete(elements ...T)
Delete removes elements from the collection
func (*Set[T]) DeleteActual ¶
DeleteActual removes elements only if they are contained in the collection
func (*Set[T]) DeleteActualOne ¶
DeleteActualOne removes an element only if it is contained in the collection
func (*Set[T]) DeleteOne ¶
func (s *Set[T]) DeleteOne(v T)
DeleteOne removes an element from the collection
func (*Set[T]) Filt ¶
Filt returns an errorable seq consisting of elements that satisfy the condition of the 'filter' function
func (*Set[T]) Filter ¶
Filter returns a seq consisting of elements that satisfy the condition of the 'filter' function
func (*Set[T]) First ¶
First returns the first element that satisfies requirements of the condition.
func (*Set[T]) ForEach ¶
func (s *Set[T]) ForEach(consumer func(T))
ForEach applies the 'consumer' function for every element
func (*Set[T]) HasAny ¶
HasAny checks whether the set contains an element that satisfies the condition.
func (*Set[T]) IAll ¶ added in v0.0.15
IAll is used to iterate through the collection using `for i, e := range`.
func (*Set[T]) Reduce ¶
func (s *Set[T]) Reduce(merge func(T, T) T) (t T)
Reduce reduces the elements into an one using the 'merge' function
func (*Set[T]) StableSort ¶
StableSort sorts the elements
Directories
¶
| Path | Synopsis |
|---|---|
|
Package map_ provides mutable ordered.Map constructors
|
Package map_ provides mutable ordered.Map constructors |
|
Package set provides mutable github.com/m4gshm/gollections/collection/ordered.Set constructors and helpers
|
Package set provides mutable github.com/m4gshm/gollections/collection/ordered.Set constructors and helpers |