Documentation ¶
Overview ¶
Package ordered provides immutable ordered collection implementations
Package ordered provides ordered map iterator implementations
Index ¶
- type Map
- func (m Map[K, V]) Contains(key K) (ok bool)
- func (m Map[K, V]) Conv(converter func(K, V) (K, V, error)) kvstream.Iter[K, V, map[K]V]
- func (m Map[K, V]) ConvKey(converter func(K) (K, error)) kvstream.Iter[K, V, map[K]V]
- func (m Map[K, V]) ConvValue(converter func(V) (V, error)) kvstream.Iter[K, V, map[K]V]
- func (m Map[K, V]) Convert(converter func(K, V) (K, V)) stream.Iter[K, V, map[K]V]
- func (m Map[K, V]) ConvertKey(by func(K) K) stream.Iter[K, V, map[K]V]
- func (m Map[K, V]) ConvertValue(converter func(V) V) stream.Iter[K, V, map[K]V]
- func (m Map[K, V]) Filt(predicate func(K, V) (bool, error)) kvstream.Iter[K, V, map[K]V]
- func (m Map[K, V]) FiltKey(predicate func(K) (bool, error)) kvstream.Iter[K, V, map[K]V]
- func (m Map[K, V]) FiltValue(predicate func(V) (bool, error)) kvstream.Iter[K, V, map[K]V]
- func (m Map[K, V]) Filter(predicate func(K, V) bool) stream.Iter[K, V, map[K]V]
- func (m Map[K, V]) FilterKey(predicate func(K) bool) stream.Iter[K, V, map[K]V]
- func (m Map[K, V]) FilterValue(predicate func(V) bool) stream.Iter[K, V, map[K]V]
- func (m Map[K, V]) First() (MapIter[K, V], K, V, bool)
- func (m Map[K, V]) For(walker func(c.KV[K, V]) error) error
- func (m Map[K, V]) ForEach(walker func(c.KV[K, V]))
- func (m Map[K, V]) Get(key K) (element V, ok bool)
- func (m Map[K, V]) HasAny(predicate func(K, V) bool) bool
- func (m Map[K, V]) Head() MapIter[K, V]
- func (m Map[K, V]) IsEmpty() bool
- func (m Map[K, V]) Iter() kv.Iterator[K, V]
- func (m Map[K, V]) Keys() MapKeys[K]
- func (m Map[K, V]) Len() int
- func (m Map[K, V]) Loop() *MapIter[K, V]
- func (m Map[K, V]) Map() map[K]V
- func (m Map[K, V]) Reduce(merge func(K, K, V, V) (K, V)) (K, V)
- func (m Map[K, V]) Sort(less slice.Less[K]) Map[K, V]
- func (m Map[K, V]) StableSort(less slice.Less[K]) Map[K, V]
- func (m Map[K, V]) String() string
- func (m Map[K, V]) Tail() MapIter[K, V]
- func (m Map[K, V]) Track(tracker func(K, V) error) error
- func (m Map[K, V]) TrackEach(tracker func(K, V))
- func (m Map[K, V]) Values() MapValues[K, V]
- type MapIter
- type MapKeys
- func (m MapKeys[K]) Append(out []K) []K
- func (m MapKeys[K]) Conv(converter func(K) (K, error)) breakStream.Iter[K]
- func (m MapKeys[K]) Convert(converter func(K) K) stream.Iter[K]
- func (m MapKeys[K]) Filt(predicate func(K) (bool, error)) breakStream.Iter[K]
- func (m MapKeys[K]) Filter(filter func(K) bool) stream.Iter[K]
- func (m MapKeys[K]) First() (slice.Iter[K], K, bool)
- func (m MapKeys[K]) For(walker func(K) error) error
- func (m MapKeys[K]) ForEach(walker func(K))
- func (m MapKeys[K]) Get(index int) (K, bool)
- func (m MapKeys[K]) HasAny(predicate func(K) bool) bool
- func (m MapKeys[K]) Head() slice.Iter[K]
- func (m MapKeys[K]) IsEmpty() bool
- func (m MapKeys[K]) Iter() c.Iterator[K]
- func (m MapKeys[K]) Len() int
- func (m MapKeys[K]) Reduce(merge func(K, K) K) K
- func (m MapKeys[K]) Slice() (out []K)
- func (m MapKeys[K]) String() string
- type MapValues
- func (m MapValues[K, V]) Append(out []V) (values []V)
- func (m MapValues[K, V]) Conv(converter func(V) (V, error)) breakStream.Iter[V]
- func (m MapValues[K, V]) Convert(converter func(V) V) stream.Iter[V]
- func (m MapValues[K, V]) Filt(filter func(V) (bool, error)) breakStream.Iter[V]
- func (m MapValues[K, V]) Filter(filter func(V) bool) stream.Iter[V]
- func (m MapValues[K, V]) First() (ValIter[K, V], V, bool)
- func (m MapValues[K, V]) For(walker func(V) error) error
- func (m MapValues[K, V]) ForEach(walker func(V))
- func (m MapValues[K, V]) Get(index int) (V, bool)
- func (m MapValues[K, V]) HasAny(predicate func(V) bool) bool
- func (m MapValues[K, V]) Head() ValIter[K, V]
- func (m MapValues[K, V]) IsEmpty() bool
- func (m MapValues[K, V]) Iter() c.Iterator[V]
- func (m MapValues[K, V]) Len() int
- func (m MapValues[K, V]) Loop() *ValIter[K, V]
- func (m MapValues[K, V]) Reduce(merge func(V, V) V) V
- func (m MapValues[K, V]) Slice() (values []V)
- func (m MapValues[K, V]) String() string
- type Set
- func (s Set[T]) Append(out []T) []T
- func (s Set[T]) Contains(element T) (ok bool)
- func (s Set[T]) Conv(converter func(T) (T, error)) breakStream.Iter[T]
- func (s Set[T]) Convert(converter func(T) T) stream.Iter[T]
- func (s Set[T]) Filt(predicate func(T) (bool, error)) breakStream.Iter[T]
- func (s Set[T]) Filter(predicate func(T) bool) stream.Iter[T]
- func (s Set[T]) First() (slice.Iter[T], T, bool)
- func (s Set[T]) For(walker func(T) error) error
- func (s Set[T]) ForEach(walker func(T))
- func (s Set[T]) HasAny(predicate func(T) bool) bool
- func (s Set[T]) Head() slice.Iter[T]
- func (s Set[T]) IsEmpty() bool
- func (s Set[T]) Iter() c.Iterator[T]
- func (s Set[T]) Last() (slice.Iter[T], T, bool)
- func (s Set[T]) Len() int
- func (s Set[T]) Loop() *slice.Iter[T]
- func (s Set[T]) Reduce(merge func(T, T) T) T
- func (s Set[T]) Slice() []T
- func (s Set[T]) Sort(less slice.Less[T]) Set[T]
- func (s Set[T]) StableSort(less slice.Less[T]) Set[T]
- func (s Set[T]) String() string
- func (s Set[T]) Tail() slice.Iter[T]
- type ValIter
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 MapFromLoop ¶
func MapFromLoop[K comparable, V any](next func() (K, V, bool)) Map[K, V]
MapFromLoop creates a map with elements retrieved converter the 'next' function
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 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 ordered Map using a map and an order slice as internal storage.
func (Map[K, V]) Conv ¶
Conv returns a breakable stream that applies the 'converter' function to the collection elements
func (Map[K, V]) ConvKey ¶
ConvKey returns a stream that applies the 'converter' function to keys of the map
func (Map[K, V]) ConvValue ¶
ConvValue returns a breakable stream that applies the 'converter' function to values of the map
func (Map[K, V]) Convert ¶
Convert returns a stream that applies the 'converter' function to the collection elements
func (Map[K, V]) ConvertKey ¶
ConvertKey returns a stream that applies the 'converter' function to keys of the map
func (Map[K, V]) ConvertValue ¶
ConvertValue returns a stream that applies the 'converter' function to values of the map
func (Map[K, V]) Filt ¶
Filt returns a breakable stream consisting of elements that satisfy the condition of the 'predicate' function
func (Map[K, V]) FiltKey ¶
FiltKey returns a stream consisting of key/value pairs where the key satisfies the condition of the 'predicate' function
func (Map[K, V]) FiltValue ¶
FiltValue returns a breakable stream consisting of key/value pairs where the value satisfies the condition of the 'predicate' function
func (Map[K, V]) Filter ¶
Filter returns a stream consisting of elements that satisfy the condition of the 'predicate' function
func (Map[K, V]) FilterKey ¶
FilterKey returns a stream consisting of key/value pairs where the key satisfies the condition of the 'predicate' function
func (Map[K, V]) FilterValue ¶
FilterValue returns a stream consisting of key/value pairs where the value satisfies the condition of the 'predicate' function
func (Map[K, V]) First ¶
First returns the first key/value pair of the map, an iterator to iterate over the remaining pair, and true\false marker of availability next pairs. If no more then ok==false.
func (Map[K, V]) For ¶
For applies the 'walker' function for key/value pairs. Return the c.ErrBreak to stop.
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 finds the first key/value pair that satisfies the 'predicate' function condition and returns true if successful
func (Map[K, V]) Reduce ¶
func (m Map[K, V]) Reduce(merge func(K, K, V, V) (K, V)) (K, 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 the elements
func (Map[K, V]) Track ¶
Track applies the 'tracker' function for key/value pairs. Return the c.ErrBreak to stop.
type MapIter ¶
type MapIter[K comparable, V any] struct { // contains filtered or unexported fields }
MapIter is the ordered key/value pairs Iterator implementation
func NewMapIter ¶
func NewMapIter[K comparable, V any](uniques map[K]V, elements slice.Iter[K]) MapIter[K, V]
NewMapIter is the Iter constructor
func (*MapIter[K, V]) Next ¶
Next returns the next key/value pair. The ok result indicates whether the pair was returned by the iterator. If ok == false, then the iteration must be completed.
func (*MapIter[K, V]) Start ¶ added in v0.0.10
Start is used with for loop construct like 'for i, k, v, ok := i.Start(); ok; k, v, ok = i.Next() { }'
type MapKeys ¶
type MapKeys[K comparable] struct { // contains filtered or unexported fields }
MapKeys is the wrapper for Map'm keys
func WrapKeys ¶
func WrapKeys[K comparable](elements []K) MapKeys[K]
WrapKeys instantiates MapKeys using the elements as internal storage
func (MapKeys[K]) Append ¶
func (m MapKeys[K]) Append(out []K) []K
Append collects the values to the specified 'out' slice
func (MapKeys[K]) Conv ¶
func (m MapKeys[K]) Conv(converter func(K) (K, error)) breakStream.Iter[K]
Conv returns a breakable stream that applies the 'converter' function to the collection elements
func (MapKeys[K]) Convert ¶
Convert returns a stream that applies the 'converter' function to the collection elements
func (MapKeys[K]) Filt ¶
func (m MapKeys[K]) Filt(predicate func(K) (bool, error)) breakStream.Iter[K]
Filt returns a breakable stream consisting of elements that satisfy the condition of the 'predicate' function
func (MapKeys[K]) Filter ¶
Filter returns a stream consisting of elements that satisfy the condition of the 'predicate' function
func (MapKeys[K]) First ¶
First returns the first element of the collection, an iterator to iterate over the remaining elements, and true\false marker of availability next elements. If no more elements then ok==false.
func (MapKeys[K]) For ¶
For applies the 'walker' function for every key. Return the c.ErrBreak to stop.
func (MapKeys[K]) ForEach ¶
func (m MapKeys[K]) ForEach(walker func(K))
ForEach applies the 'walker' function for every element
func (MapKeys[K]) Get ¶
Get returns an element by the index, otherwise, if the provided index is ouf of the collection len, returns zero T and false in the second result
func (MapKeys[K]) HasAny ¶
HasAny finds the first element that satisfies the 'predicate' function condition and returns true if successful
func (MapKeys[K]) Reduce ¶
func (m MapKeys[K]) Reduce(merge func(K, K) K) K
Reduce reduces the elements into an one using the 'merge' function
type MapValues ¶
type MapValues[K comparable, V any] struct { // contains filtered or unexported fields }
MapValues is the wrapper for Map'm values.
func WrapVal ¶
func WrapVal[K comparable, V any](order []K, elements map[K]V) MapValues[K, V]
WrapVal instantiates MapValues using elements as internal storage.
func (MapValues[K, V]) Append ¶
func (m MapValues[K, V]) Append(out []V) (values []V)
Append collects the values to the specified 'out' slice
func (MapValues[K, V]) Conv ¶
func (m MapValues[K, V]) Conv(converter func(V) (V, error)) breakStream.Iter[V]
Conv returns a breakable stream that applies the 'converter' function to the collection elements
func (MapValues[K, V]) Convert ¶
Convert returns a stream that applies the 'converter' function to the collection elements
func (MapValues[K, V]) Filt ¶
func (m MapValues[K, V]) Filt(filter func(V) (bool, error)) breakStream.Iter[V]
Filt returns a breakable stream consisting of elements that satisfy the condition of the 'predicate' function
func (MapValues[K, V]) Filter ¶
Filter returns a stream consisting of elements that satisfy the condition of the 'predicate' function
func (MapValues[K, V]) First ¶
First returns the first element of the collection, an iterator to iterate over the remaining elements, and true\false marker of availability next elements. If no more elements then ok==false.
func (MapValues[K, V]) For ¶
For applies the 'walker' function for every value. Return the c.ErrBreak to stop.
func (MapValues[K, V]) ForEach ¶
func (m MapValues[K, V]) ForEach(walker func(V))
ForEach applies the 'walker' function for every value
func (MapValues[K, V]) Get ¶
Get returns an element by the index, otherwise, if the provided index is ouf of the collection len, returns zero T and false in the second result
func (MapValues[K, V]) HasAny ¶
HasAny finds the first element that satisfies the 'predicate' function condition and returns true if successful
func (MapValues[K, V]) Reduce ¶
func (m MapValues[K, V]) Reduce(merge func(V, V) V) V
Reduce reduces the elements into an one using the 'merge' function
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
Set is a collection implementation that provides storage for unique elements, prevents duplication, and guarantees access order. The elements must be comparable.
func NewSet ¶
func NewSet[T comparable](elements ...T) Set[T]
NewSet instantiates set and copies elements to it
func SetFromLoop ¶
func SetFromLoop[T comparable](next func() (T, bool)) Set[T]
SetFromLoop creates a set with elements retrieved by the 'next' function. The next returns an element with true or zero value with false if there are no more elements.
func WrapSet ¶
func WrapSet[T comparable](order []T, elements map[T]struct{}) Set[T]
WrapSet creates a set using a map and an order slice as the internal storage.
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 ¶
func (s Set[T]) Conv(converter func(T) (T, error)) breakStream.Iter[T]
Conv returns a breakable stream that applies the 'converter' function to the collection elements
func (Set[T]) Convert ¶
Convert returns a stream that applies the 'converter' function to the collection elements
func (Set[T]) Filt ¶
func (s Set[T]) Filt(predicate func(T) (bool, error)) breakStream.Iter[T]
Filt returns a breakable stream consisting of elements that satisfy the condition of the 'predicate' function
func (Set[T]) Filter ¶
Filter returns a stream consisting of elements that satisfy the condition of the 'predicate' function
func (Set[T]) First ¶
First returns the first element of the collection, an iterator to iterate over the remaining elements, and true\false marker of availability next elements. If no more elements then ok==false.
func (Set[T]) For ¶
For applies the 'walker' function for every element. Return the c.ErrBreak to stop.
func (Set[T]) ForEach ¶
func (s Set[T]) ForEach(walker func(T))
ForEach applies the 'walker' function for every element
func (Set[T]) HasAny ¶
HasAny finds the first element that satisfies the 'predicate' function condition and returns true if successful
func (Set[T]) Last ¶
Last returns the latest element of the collection, an iterator to reverse iterate over the remaining elements, and true\false marker of availability previous elements. If no more elements then ok==false.
func (Set[T]) Reduce ¶
func (s Set[T]) Reduce(merge func(T, T) T) T
Reduce reduces the elements into an one using the 'merge' function
func (Set[T]) StableSort ¶
StableSort sorts the elements
type ValIter ¶
type ValIter[K comparable, V any] struct { // contains filtered or unexported fields }
ValIter is the Iteratoc over Map values
func NewValIter ¶
func NewValIter[K comparable, V any](elements []K, uniques map[K]V) ValIter[K, V]
NewValIter is default ValIter constructor
func (*ValIter[K, V]) For ¶
For takes elements retrieved by the iterator. Can be interrupt by returning ErrBreak
func (*ValIter[K, V]) ForEach ¶
func (i *ValIter[K, V]) ForEach(walker func(element V))
ForEach FlatIter all elements retrieved by the iterator