Documentation
¶
Overview ¶
Package immutable provides immutable collection implementations
Index ¶
- func NewMapOrdered[K comparable, V any](elements ...c.KV[K, V]) ordered.Map[K, V]
- func NewSetOrdered[T comparable](elements ...T) ordered.Set[T]
- type Map
- func (m Map[K, V]) All(consumer func(k K, v V) bool)
- func (m Map[K, V]) Contains(key K) (ok 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) (element V, ok 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]) IsEmpty() bool
- func (m Map[K, V]) Keys() MapKeys[K, V]
- 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, V)
- func (m Map[K, V]) Sort(comparer slice.Comparer[K]) ordered.Map[K, V]
- func (m Map[K, V]) StableSort(comparer slice.Comparer[K]) ordered.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() MapValues[K, V]
- type MapKeys
- func (m MapKeys[K, V]) All(consumer func(K) bool)
- func (m MapKeys[K, V]) Append(out []K) []K
- func (m MapKeys[K, V]) Conv(converter func(K) (K, error)) seq.SeqE[K]
- func (m MapKeys[K, V]) Convert(converter func(K) K) seq.Seq[K]
- func (m MapKeys[K, V]) Filt(filter func(K) (bool, error)) seq.SeqE[K]
- func (m MapKeys[K, V]) Filter(filter func(K) bool) seq.Seq[K]
- func (m MapKeys[K, V]) First(condition func(K) bool) (K, bool)
- func (m MapKeys[K, V]) ForEach(consumer func(K))
- func (m MapKeys[K, V]) HasAny(condition func(K) bool) bool
- func (m MapKeys[K, V]) Head() (K, bool)
- func (m MapKeys[K, V]) IsEmpty() bool
- func (m MapKeys[K, V]) Len() int
- func (m MapKeys[K, V]) Reduce(merge func(K, K) K) K
- func (m MapKeys[K, V]) Slice() []K
- func (m MapKeys[K, V]) String() string
- type MapValues
- func (m MapValues[K, V]) All(consumer func(V) bool)
- func (m MapValues[K, V]) Append(out []V) []V
- func (m MapValues[K, V]) Conv(converter func(V) (V, error)) seq.SeqE[V]
- func (m MapValues[K, V]) Convert(converter func(V) V) seq.Seq[V]
- func (m MapValues[K, V]) Filt(filter func(V) (bool, error)) seq.SeqE[V]
- func (m MapValues[K, V]) Filter(filter func(V) bool) seq.Seq[V]
- func (m MapValues[K, V]) First(condition func(V) bool) (V, bool)
- func (m MapValues[K, V]) ForEach(consumer func(V))
- func (m MapValues[K, V]) HasAny(condition func(V) bool) bool
- func (m MapValues[K, V]) Head() (V, bool)
- func (m MapValues[K, V]) IsEmpty() bool
- func (m MapValues[K, V]) Len() int
- func (m MapValues[K, V]) Reduce(merge func(V, V) V) V
- func (m MapValues[K, V]) Slice() []V
- func (m MapValues[K, V]) Sort(comparer slice.Comparer[V]) Vector[V]
- func (m MapValues[K, V]) String() string
- type Set
- func (s Set[T]) All(consumer func(T) bool)
- 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)) seq.SeqE[T]
- func (s Set[T]) Convert(converter func(T) T) seq.Seq[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, 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, bool)
- func (s Set[T]) IsEmpty() bool
- func (s Set[T]) Len() int
- func (s Set[T]) Reduce(merge func(T, T) T) T
- func (s Set[T]) Slice() []T
- func (s Set[T]) Sort(comparer slice.Comparer[T]) ordered.Set[T]
- func (s Set[T]) StableSort(comparer slice.Comparer[T]) ordered.Set[T]
- func (s Set[T]) String() string
- type Vector
- func (v Vector[T]) All(consumer func(T) bool)
- func (v Vector[T]) Append(out []T) []T
- func (v Vector[T]) Conv(converter func(T) (T, error)) seq.SeqE[T]
- func (v Vector[T]) Convert(converter func(T) T) seq.Seq[T]
- func (v Vector[T]) Filt(filter func(T) (bool, error)) seq.SeqE[T]
- func (v Vector[T]) Filter(filter func(T) bool) seq.Seq[T]
- func (v Vector[T]) First(condition func(T) bool) (T, bool)
- func (v Vector[T]) ForEach(consumer func(T))
- func (v Vector[T]) Get(index int) (out T, ok bool)
- func (v Vector[T]) HasAny(condition func(T) bool) bool
- func (v Vector[T]) Head() (T, bool)
- func (v Vector[T]) IAll(consumer func(int, T) bool)
- func (v Vector[T]) IsEmpty() bool
- func (v Vector[T]) Len() int
- func (v Vector[T]) Reduce(merge func(T, T) T) T
- func (v Vector[T]) Slice() []T
- func (v Vector[T]) Sort(comparer slice.Comparer[T]) Vector[T]
- func (v Vector[T]) StableSort(comparer slice.Comparer[T]) Vector[T]
- func (v Vector[T]) String() string
- func (v Vector[T]) Tail() (T, bool)
- func (v Vector[T]) TrackEach(consumer func(int, T))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMapOrdered ¶ added in v0.0.16
NewMapOrdered instantiates an ordered map using key/value pairs
func NewSetOrdered ¶ added in v0.0.16
func NewSetOrdered[T comparable](elements ...T) ordered.Set[T]
NewSetOrdered instantiates ordered set and copies elements to it
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 NewMapOf ¶
func NewMapOf[K comparable, V any](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](elements map[K]V) Map[K, V]
WrapMap instantiates Map using a map 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 an errorable 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 an errorable 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, V)
Reduce reduces the key/value pairs of the map into an one pair using the 'merge' function
func (Map[K, V]) StableSort ¶
StableSort returns sorted by keys map
type MapKeys ¶
type MapKeys[K comparable, V any] struct { // contains filtered or unexported fields }
MapKeys is the container reveal keys of a map and hides values
func WrapKeys ¶
func WrapKeys[K comparable, V any](elements map[K]V) MapKeys[K, V]
WrapKeys instantiates MapKeys using the elements as internal storage
func (MapKeys[K, V]) All ¶ added in v0.0.12
All is used to iterate through the collection using `for key := range`.
func (MapKeys[K, V]) Append ¶
func (m MapKeys[K, V]) Append(out []K) []K
Append collects the values to the specified 'out' slice
func (MapKeys[K, V]) Conv ¶
Conv returns an errorable seq that applies the 'converter' function to the collection elements
func (MapKeys[K, V]) Convert ¶
Convert returns a seq that applies the 'converter' function to the collection elements
func (MapKeys[K, V]) Filt ¶
Filt returns an errorable seq consisting of elements that satisfy the condition of the 'filter' function
func (MapKeys[K, V]) Filter ¶
Filter returns a seq consisting of elements that satisfy the condition of the 'filter' function
func (MapKeys[K, V]) ForEach ¶
func (m MapKeys[K, V]) ForEach(consumer func(K))
ForEach applies the 'consumer' function for every key
func (MapKeys[K, V]) HasAny ¶
HasAny checks whether the collection contains a key that satisfies the condition.
func (MapKeys[K, V]) Reduce ¶
func (m MapKeys[K, V]) 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](elements map[K]V) MapValues[K, V]
WrapVal instantiates MapValues using elements as internal storage.
func (MapValues[K, V]) All ¶ added in v0.0.12
All is used to iterate through the collection using `for val := range`.
func (MapValues[K, V]) Append ¶
func (m MapValues[K, V]) Append(out []V) []V
Append collects the values to the specified 'out' slice
func (MapValues[K, V]) Conv ¶
Conv returns an errorable seq that applies the 'converter' function to the collection elements
func (MapValues[K, V]) Convert ¶
Convert returns a seq that applies the 'converter' function to the collection elements
func (MapValues[K, V]) Filt ¶
Filt returns an errorable seq consisting of elements that satisfy the condition of the 'filter' function
func (MapValues[K, V]) Filter ¶
Filter returns a seq consisting of elements that satisfy the condition of the 'filter' function
func (MapValues[K, V]) ForEach ¶
func (m MapValues[K, V]) ForEach(consumer func(V))
ForEach applies the 'consumer' function for every value of the collection
func (MapValues[K, V]) HasAny ¶
HasAny checks whether the collection contains a value that satisfies the condition.
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
func (MapValues[K, V]) Slice ¶
func (m MapValues[K, V]) Slice() []V
Slice collects the values to a slice
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. The elements must be comparable.
func NewSet ¶
func NewSet[T comparable](elements ...T) Set[T]
NewSet instantiates set and copies elements to it
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 map[T]struct{}) Set[T]
WrapSet creates a set using a map as the internal storage.
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]) 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]) 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]) 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 transforms to the ordered set with sorted elements
type Vector ¶
type Vector[T any] struct { // contains filtered or unexported fields }
Vector is a collection implementation that provides elements order and index access.
func VectorFromSeq ¶ added in v0.0.15
VectorFromSeq creates a vector with elements retrieved by the seq.
func WrapVector ¶
WrapVector instantiates Vector using a slise as internal storage.
func (Vector[T]) All ¶ added in v0.0.12
All is used to iterate through the collection using `for e := range`.
func (Vector[T]) Append ¶
func (v Vector[T]) Append(out []T) []T
Append collects the values to the specified 'out' slice
func (Vector[T]) Conv ¶
Conv returns an errorable seq that applies the 'converter' function to the collection elements
func (Vector[T]) Convert ¶
Convert returns a seq that applies the 'converter' function to the collection elements
func (Vector[T]) Filt ¶
Filt returns an errorable seq consisting of elements that satisfy the condition of the 'filter' function
func (Vector[T]) Filter ¶
Filter returns a seq consisting of elements that satisfy the condition of the 'filter' function
func (Vector[T]) First ¶
First returns the first element that satisfies requirements of the condition.
func (Vector[T]) ForEach ¶
func (v Vector[T]) ForEach(consumer func(T))
ForEach applies the 'consumer' function for every element
func (Vector[T]) Get ¶
Get returns an element by the index, otherwise, if the provided index is ouf of the vector len, returns zero T and false in the second result
func (Vector[T]) HasAny ¶
HasAny checks whether the vector contains an element that satisfies the condition.
func (Vector[T]) IAll ¶ added in v0.0.15
IAll is used to iterate through the collection using `for i, e := range`.
func (Vector[T]) Reduce ¶
func (v Vector[T]) Reduce(merge func(T, T) T) T
Reduce reduces the elements into an one using the 'merge' function
func (Vector[T]) StableSort ¶
StableSort returns a stable sorted clone of the Vector
Directories
¶
| Path | Synopsis |
|---|---|
|
Package map_ provides immutable.Map constructors
|
Package map_ provides immutable.Map constructors |
|
Package ordered provides immutable ordered collection implementations
|
Package ordered provides immutable ordered collection implementations |
|
map_
Package map_ provides immutale ordered.Map constructors
|
Package map_ provides immutale ordered.Map constructors |
|
set
Package set provides github.com/m4gshm/gollections/collection/ordered.Set constructors and helpers
|
Package set provides github.com/m4gshm/gollections/collection/ordered.Set constructors and helpers |
|
Package set provides unordered github.com/m4gshm/gollections/collection/immutable.Set constructors and helpers
|
Package set provides unordered github.com/m4gshm/gollections/collection/immutable.Set constructors and helpers |
|
Package vector provides ordered immutable.Vector constructors and helpers
|
Package vector provides ordered immutable.Vector constructors and helpers |