Documentation ¶
Overview ¶
Package mutable provides implementations of mutable containers.
Index ¶
- type Map
- func MapFromLoop[K comparable, V any](next func() (K, V, bool)) *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](elements map[K]V) *Map[K, V]
- func WrapMap[K comparable, V any](elements map[K]V) *Map[K, V]
- func (m *Map[K, V]) Contains(key K) (ok bool)
- func (m *Map[K, V]) Conv(converter func(K, V) (K, V, error)) breakKvStream.Iter[K, V, map[K]V]
- func (m Map[K, V]) ConvKey(converter func(K) (K, error)) breakKvStream.Iter[K, V, map[K]V]
- func (m Map[K, V]) ConvValue(converter func(V) (V, error)) breakKvStream.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(converter 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]) Delete(keys ...K)
- func (m *Map[K, V]) DeleteOne(key K)
- func (m *Map[K, V]) Filt(predicate func(K, V) (bool, error)) breakKvStream.Iter[K, V, map[K]V]
- func (m Map[K, V]) FiltKey(predicate func(K) (bool, error)) breakKvStream.Iter[K, V, map[K]V]
- func (m *Map[K, V]) FiltValue(predicate func(V) (bool, error)) breakKvStream.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() (map_.Iter[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) (val V, ok bool)
- func (m *Map[K, V]) HasAny(predicate func(K, V) bool) bool
- func (m *Map[K, V]) Head() map_.Iter[K, V]
- func (m *Map[K, V]) Immutable() immutable.Map[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() immutable.MapKeys[K, V]
- func (m *Map[K, V]) Len() int
- func (m *Map[K, V]) Loop() *map_.Iter[K, V]
- func (m *Map[K, V]) Map() (out map[K]V)
- func (m *Map[K, V]) Reduce(merge func(K, V, K, V) (K, V)) (k K, v V)
- func (m *Map[K, V]) Remove(key K) (v V, ok bool)
- func (m *Map[K, V]) Set(key K, value V)
- func (m *Map[K, V]) SetMap(other c.TrackEachLoop[K, V])
- func (m *Map[K, V]) SetNew(key K, value V) bool
- func (m *Map[K, V]) String() string
- 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() immutable.MapValues[K, V]
- type Set
- func (s *Set[T]) Add(elements ...T)
- func (s *Set[T]) AddAll(elements c.ForEachLoop[T])
- func (s *Set[T]) AddAllNew(other c.ForEachLoop[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]) 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)) breakStream.Iter[T]
- func (s *Set[T]) Convert(converter func(T) T) stream.Iter[T]
- func (s *Set[T]) Delete(elements ...T)
- func (s *Set[T]) DeleteActual(elements ...T) bool
- func (s *Set[T]) DeleteActualOne(element T) (ok bool)
- func (s *Set[T]) DeleteOne(element 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() (SetIter[T], T, bool)
- func (s *Set[T]) For(walker func(T) error) error
- func (s *Set[T]) ForEach(walker func(T))
- func (s *Set[K]) HasAny(predicate func(K) bool) bool
- func (s *Set[T]) Head() SetIter[T]
- func (s *Set[T]) IsEmpty() bool
- func (s *Set[T]) Iter() c.Iterator[T]
- func (s *Set[T]) IterEdit() c.DelIterator[T]
- func (s *Set[T]) Len() int
- func (s *Set[T]) Loop() *SetIter[T]
- func (s *Set[T]) Reduce(merge func(T, T) T) (t T)
- func (s *Set[T]) Slice() (out []T)
- func (s *Set[T]) Sort(less slice.Less[T]) *ordered.Set[T]
- func (s *Set[T]) StableSort(less slice.Less[T]) *ordered.Set[T]
- func (s *Set[T]) String() string
- type SetIter
- type SliceIter
- func (i *SliceIter[T]) Cap() int
- func (i *SliceIter[T]) Delete()
- func (i *SliceIter[T]) DeleteNext() bool
- func (i *SliceIter[T]) DeletePrev() bool
- func (i *SliceIter[T]) For(walker func(element T) error) error
- func (i *SliceIter[T]) ForEach(walker func(element T))
- func (i *SliceIter[T]) Get() (t T, ok bool)
- func (i *SliceIter[T]) GetNext() (t T)
- func (i *SliceIter[T]) GetPrev() (t T)
- func (i *SliceIter[T]) HasNext() bool
- func (i *SliceIter[T]) HasPrev() bool
- func (i *SliceIter[T]) Next() (T, bool)
- func (i *SliceIter[T]) Prev() (T, bool)
- type Vector
- func (v *Vector[T]) Add(elements ...T)
- func (v *Vector[T]) AddAll(other c.ForEachLoop[T])
- func (v *Vector[T]) AddOne(element T)
- func (v *Vector[T]) Append(out []T) []T
- func (v *Vector[T]) Clone() *Vector[T]
- func (v *Vector[T]) Conv(converter func(T) (T, error)) breakStream.Iter[T]
- func (v *Vector[T]) Convert(converter func(T) T) stream.Iter[T]
- func (v *Vector[T]) Delete(indexes ...int)
- func (v *Vector[T]) DeleteActual(indexes ...int) bool
- func (v *Vector[T]) DeleteActualOne(index int) bool
- func (v *Vector[T]) DeleteOne(index int)
- func (v *Vector[T]) Filt(predicate func(T) (bool, error)) breakStream.Iter[T]
- func (v *Vector[T]) Filter(filter func(T) bool) stream.Iter[T]
- func (v *Vector[T]) First() (SliceIter[T], T, bool)
- func (v *Vector[T]) For(walker func(T) error) error
- func (v *Vector[T]) ForEach(walker func(T))
- func (v *Vector[T]) Get(index int) (t T, ok bool)
- func (v *Vector[T]) HasAny(predicate func(T) bool) (ok bool)
- func (v *Vector[T]) Head() SliceIter[T]
- func (v *Vector[T]) IsEmpty() bool
- func (v *Vector[T]) Iter() c.Iterator[T]
- func (v *Vector[T]) IterEdit() c.DelIterator[T]
- func (v *Vector[T]) Last() (SliceIter[T], T, bool)
- func (v *Vector[T]) Len() int
- func (v *Vector[T]) Loop() *SliceIter[T]
- func (v *Vector[T]) Reduce(merge func(T, T) T) (out T)
- func (v *Vector[T]) Remove(index int) (t T, ok bool)
- func (v *Vector[T]) Set(index int, value T)
- func (v *Vector[T]) SetNew(index int, value T) bool
- func (v *Vector[T]) Slice() (out []T)
- func (v *Vector[T]) Sort(less slice.Less[T]) *Vector[T]
- func (v *Vector[T]) StableSort(less slice.Less[T]) *Vector[T]
- func (v *Vector[T]) String() string
- func (v *Vector[T]) Tail() SliceIter[T]
- func (v *Vector[T]) Track(tracker func(int, T) error) error
- func (v *Vector[T]) TrackEach(tracker func(int, T))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K comparable, V any] map[K]V
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 an 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](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]) Conv ¶
func (m *Map[K, V]) Conv(converter func(K, V) (K, V, error)) breakKvStream.Iter[K, V, map[K]V]
Conv returns a breakable stream that applies the 'converter' function to the collection elements
func (Map[K, V]) ConvKey ¶
func (m Map[K, V]) ConvKey(converter func(K) (K, error)) breakKvStream.Iter[K, V, map[K]V]
ConvKey returns a breabkable stream that applies the 'converter' function to keys of the map
func (Map[K, V]) ConvValue ¶
func (m Map[K, V]) ConvValue(converter func(V) (V, error)) breakKvStream.Iter[K, V, map[K]V]
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]) Delete ¶
func (m *Map[K, V]) Delete(keys ...K)
Delete removes value by their keys from the map
func (*Map[K, V]) DeleteOne ¶
func (m *Map[K, V]) DeleteOne(key K)
DeleteOne removes an value by the key from the map
func (*Map[K, V]) Filt ¶
func (m *Map[K, V]) Filt(predicate func(K, V) (bool, error)) breakKvStream.Iter[K, V, map[K]V]
Filt returns a breakable stream consisting of elements that satisfy the condition of the 'predicate' function
func (Map[K, V]) FiltKey ¶
func (m Map[K, V]) FiltKey(predicate func(K) (bool, error)) breakKvStream.Iter[K, V, map[K]V]
FiltKey returns a breakable stream consisting of key/value pairs where the key satisfies the condition of the 'predicate' function
func (*Map[K, V]) FiltValue ¶
func (m *Map[K, V]) FiltValue(predicate func(V) (bool, error)) breakKvStream.Iter[K, V, map[K]V]
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 every key/value pair. 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]) Map ¶
func (m *Map[K, V]) Map() (out map[K]V)
Map collects the key/value pairs to a map
func (*Map[K, V]) Reduce ¶
func (m *Map[K, V]) Reduce(merge func(K, V, K, 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]) SetMap ¶
func (m *Map[K, V]) SetMap(other c.TrackEachLoop[K, V])
SetMap inserts all elements from the 'other' map
func (*Map[K, V]) Track ¶
Track applies the 'tracker' function for key/value pairs. Return the c.ErrBreak to stop.
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
Set is a collection implementation that provides element uniqueness. The 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 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](elements map[T]struct{}) *Set[T]
WrapSet creates a set using a map as the internal storage.
func (*Set[T]) AddAll ¶
func (s *Set[T]) AddAll(elements c.ForEachLoop[T])
AddAll inserts all elements from the "other" collection
func (*Set[T]) AddAllNew ¶
func (s *Set[T]) AddAllNew(other c.ForEachLoop[T]) (ok bool)
AddAllNew inserts elements from the "other" collection if they are not contained in the collection
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]) 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(element T)
DeleteOne removes an element from the collection
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 the elements. 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[K]) HasAny ¶
HasAny finds the first element that satisfies the 'predicate' function condition and returns true if successful
func (*Set[T]) IterEdit ¶
func (s *Set[T]) IterEdit() c.DelIterator[T]
IterEdit creates iterator that can delete iterable elements
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 transforms to the ordered Set contains sorted elements
type SetIter ¶
type SetIter[K comparable] struct { map_.KeyIter[K, struct{}] // contains filtered or unexported fields }
SetIter is the Set Iterator implementation.
func NewSetIter ¶
func NewSetIter[K comparable](uniques map[K]struct{}, del func(element K)) SetIter[K]
NewSetIter creates SetIter instance.
type SliceIter ¶
type SliceIter[T any] struct { // contains filtered or unexported fields }
SliceIter is the Iterator implementation for mutable containers.
func (*SliceIter[T]) DeleteNext ¶
DeleteNext deletes the next element if it exists
func (*SliceIter[T]) DeletePrev ¶
DeletePrev deletes the previos element if it exists
func (*SliceIter[T]) For ¶
For takes elements retrieved by the iterator. Can be interrupt by returning ErrBreak
func (*SliceIter[T]) ForEach ¶
func (i *SliceIter[T]) ForEach(walker func(element T))
ForEach FlatIter all elements retrieved by the iterator
func (*SliceIter[T]) Get ¶
Get returns the current element. The ok result indicates whether the element was returned by the iterator. If ok == false, then the iteration must be completed.
func (*SliceIter[T]) GetNext ¶
func (i *SliceIter[T]) GetNext() (t T)
GetNext returns the next element
func (*SliceIter[T]) GetPrev ¶
func (i *SliceIter[T]) GetPrev() (t T)
GetPrev returns the previous element
type Vector ¶
type Vector[T any] []T
Vector is a collection implementation that provides elements order and index access
func NewVectorCap ¶
NewVectorCap instantiates Vector with a predefined capacity
func VectorFromLoop ¶
VectorFromLoop creates a vector 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 WrapVector ¶
WrapVector instantiates Vector using a slise as internal storage
func (*Vector[T]) Add ¶
func (v *Vector[T]) Add(elements ...T)
Add adds elements to the end of the vector
func (*Vector[T]) AddAll ¶
func (v *Vector[T]) AddAll(other c.ForEachLoop[T])
AddAll inserts all elements from the "other" collection
func (*Vector[T]) AddOne ¶
func (v *Vector[T]) AddOne(element T)
AddOne adds an element to the end of the vector
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 ¶
func (v *Vector[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 (*Vector[T]) Convert ¶
Convert returns a stream that applies the 'converter' function to the collection elements
func (*Vector[T]) DeleteActual ¶
DeleteActual drops elements by indexes with verification of no-op
func (*Vector[T]) DeleteActualOne ¶
DeleteActualOne removes an element by the index
func (*Vector[T]) Filt ¶
func (v *Vector[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 (*Vector[T]) Filter ¶
Filter returns a stream consisting of vector elements matching the filter
func (*Vector[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 (*Vector[T]) For ¶
For applies the 'walker' function for the elements. Return the c.ErrBreak to stop.
func (*Vector[T]) ForEach ¶
func (v *Vector[T]) ForEach(walker func(T))
ForEach applies walker to elements without error checking
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 finds the first element that satisfies the 'predicate' function condition and returns true if successful
func (*Vector[T]) IterEdit ¶
func (v *Vector[T]) IterEdit() c.DelIterator[T]
IterEdit creates iterator that can delete iterable elements
func (*Vector[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 (*Vector[T]) Reduce ¶
func (v *Vector[T]) Reduce(merge func(T, T) T) (out T)
Reduce reduces the elements into an one using the 'merge' function
func (*Vector[T]) Slice ¶
func (v *Vector[T]) Slice() (out []T)
Slice collects the elements to a slice
func (*Vector[T]) StableSort ¶
StableSort stable sorts the Vector in-place and returns it
Directories ¶
Path | Synopsis |
---|---|
Package map_ provides unordered mutable.Map constructors
|
Package map_ provides unordered mutable.Map constructors |
Package ordered provides mutable ordered collection implementations
|
Package ordered provides mutable ordered collection implementations |
map_
Package map_ provides mutable ordered.Map constructors
|
Package map_ provides mutable ordered.Map constructors |
set
Package set provides mutable ordered.Set constructors and helpers
|
Package set provides mutable ordered.Set constructors and helpers |
Package set provides unordered mutable.Set constructors and helpers
|
Package set provides unordered mutable.Set constructors and helpers |
Package sync provides parametrized Map implementation
|
Package sync provides parametrized Map implementation |
Package vector provides mutable.Vector constructors and helpers
|
Package vector provides mutable.Vector constructors and helpers |