Documentation
¶
Overview ¶
Package mutable provides implementations of mutable containers.
Index ¶
- type Iter
- func (i *Iter[TS, T]) Cap() int
- func (i *Iter[TS, T]) Delete() bool
- func (i *Iter[TS, T]) DeleteNext() bool
- func (i *Iter[TS, T]) DeletePrev() bool
- func (i *Iter[TS, T]) Get() (T, bool)
- func (i *Iter[TS, T]) GetNext() T
- func (i *Iter[TS, T]) GetPrev() T
- func (i *Iter[TS, T]) HasNext() bool
- func (i *Iter[TS, T]) HasPrev() bool
- func (i *Iter[TS, T]) Next() (T, bool)
- func (i *Iter[TS, T]) Prev() (T, bool)
- type Map
- func (s Map[K, V]) Begin() c.KVIterator[K, V]
- func (s Map[K, V]) Collect() map[K]V
- func (s Map[K, V]) Contains(key K) bool
- func (s Map[K, V]) Filter(filter c.BiPredicate[K, V]) c.MapPipe[K, V, map[K]V]
- func (s Map[K, V]) FilterKey(fit c.Predicate[K]) c.MapPipe[K, V, map[K]V]
- func (s Map[K, V]) FilterValue(fit c.Predicate[V]) c.MapPipe[K, V, map[K]V]
- func (s Map[K, V]) First() (it.EmbedMapKVIter[K, V], K, V, bool)
- func (s Map[K, V]) For(walker func(c.KV[K, V]) error) error
- func (s Map[K, V]) ForEach(walker func(c.KV[K, V]))
- func (s Map[K, V]) Get(key K) (V, bool)
- func (s Map[K, V]) Head() it.EmbedMapKVIter[K, V]
- func (s Map[K, V]) IsEmpty() bool
- func (s Map[K, V]) K() immutable.MapKeys[K, V]
- func (s Map[K, V]) Keys() c.Collection[K, []K, c.Iterator[K]]
- func (s Map[K, V]) Len() int
- func (s Map[K, V]) Map(by c.BiConverter[K, V, K, V]) c.MapPipe[K, V, map[K]V]
- func (s Map[K, V]) MapKey(by c.Converter[K, K]) c.MapPipe[K, V, map[K]V]
- func (s Map[K, V]) MapValue(by c.Converter[V, V]) c.MapPipe[K, V, map[K]V]
- func (s Map[K, V]) Reduce(by c.Quaternary[K, V]) (K, V)
- func (s Map[K, V]) Set(key K, value V) bool
- func (s Map[K, V]) String() string
- func (s Map[K, V]) Track(tracker func(K, V) error) error
- func (s Map[K, V]) TrackEach(tracker func(K, V))
- func (s Map[K, V]) V() immutable.MapValues[K, V]
- func (s Map[K, V]) Values() c.Collection[V, []V, c.Iterator[V]]
- type Set
- func (s Set[K]) Add(elements ...K) bool
- func (s Set[K]) AddAll(elements []K) bool
- func (s Set[K]) AddOne(element K) bool
- func (s Set[K]) Begin() c.Iterator[K]
- func (s Set[K]) BeginEdit() c.DelIterator[K]
- func (s Set[K]) Collect() []K
- func (s Set[K]) Contains(val K) bool
- func (s Set[T]) Copy() Set[T]
- func (s Set[K]) Delete(elements ...K) bool
- func (s Set[K]) DeleteOne(element K) bool
- func (s Set[K]) Filter(filter c.Predicate[K]) c.Pipe[K, []K]
- func (s Set[K]) For(walker func(K) error) error
- func (s Set[K]) ForEach(walker func(K))
- func (s Set[K]) Head() *SetIter[K]
- func (s Set[T]) IsEmpty() bool
- func (s Set[K]) Len() int
- func (s Set[K]) Map(by c.Converter[K, K]) c.Pipe[K, []K]
- func (s Set[K]) Reduce(by c.Binary[K]) K
- 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[K]) String() string
- type SetIter
- type Vector
- func (v *Vector[T]) Add(elements ...T) bool
- func (v *Vector[T]) AddAll(elements []T) bool
- func (v *Vector[T]) AddOne(element T) bool
- func (v *Vector[T]) Begin() c.Iterator[T]
- func (v *Vector[T]) BeginEdit() c.DelIterator[T]
- func (v *Vector[T]) Collect() []T
- func (v *Vector[T]) Copy() *Vector[T]
- func (v *Vector[T]) Delete(indexes ...int) bool
- func (v *Vector[T]) DeleteOne(index int) bool
- func (v *Vector[T]) Filter(filter c.Predicate[T]) c.Pipe[T, []T]
- func (v *Vector[T]) First() (Iter[Vector[T], 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, bool)
- func (v *Vector[T]) Head() Iter[Vector[T], T]
- func (v *Vector[T]) IsEmpty() bool
- func (v *Vector[T]) Last() (Iter[Vector[T], T], T, bool)
- func (v *Vector[T]) Len() int
- func (v *Vector[T]) Map(by c.Converter[T, T]) c.Pipe[T, []T]
- func (v *Vector[T]) Reduce(by c.Binary[T]) T
- func (v *Vector[T]) Remove(index int) (T, bool)
- func (v *Vector[T]) Set(index int, value T) bool
- 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() Iter[Vector[T], 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 Iter ¶
type Iter[TS ~[]T, T any] struct { // contains filtered or unexported fields }
Iter is the Iterator implementation for mutable containers.
func (*Iter[TS, T]) DeleteNext ¶
func (*Iter[TS, T]) DeletePrev ¶
type Map ¶
type Map[K comparable, V any] map[K]V
Map is the Collection implementation based on the embedded map.
func AsMap ¶
func AsMap[K comparable, V any](elements []c.KV[K, V]) Map[K, V]
AsMap converts a slice of key/value pairs to teh Map.
func NewMap ¶
func NewMap[K comparable, V any](capacity int) Map[K, V]
NewMap instantiates Map with a predefined capacity.
func ToMap ¶
func ToMap[K comparable, V any](elements map[K]V) Map[K, V]
ToMap instantiates Map and copies elements to it.
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]) Begin ¶
func (s Map[K, V]) Begin() c.KVIterator[K, V]
func (Map[K, V]) Filter ¶
func (s Map[K, V]) Filter(filter c.BiPredicate[K, V]) c.MapPipe[K, V, map[K]V]
func (Map[K, V]) FilterValue ¶
func (Map[K, V]) Head ¶
func (s Map[K, V]) Head() it.EmbedMapKVIter[K, V]
func (Map[K, V]) Map ¶
func (s Map[K, V]) Map(by c.BiConverter[K, V, K, V]) c.MapPipe[K, V, map[K]V]
func (Map[K, V]) Reduce ¶
func (s Map[K, V]) Reduce(by c.Quaternary[K, V]) (K, V)
type Set ¶
type Set[K comparable] struct { // contains filtered or unexported fields }
Set is the Collection implementation that provides element uniqueness. The elements must be comparable.
func NewSet ¶
func NewSet[T comparable](capacity int) Set[T]
NewSet creates a set with a predefined capacity.
func ToSet ¶
func ToSet[T comparable](elements []T) Set[T]
ToSet converts an elements slice to the set containing them.
func WrapSet ¶
func WrapSet[K comparable](elements map[K]struct{}) Set[K]
WrapSet creates a set using a map as the internal storage.
func (Set[K]) BeginEdit ¶
func (s Set[K]) BeginEdit() c.DelIterator[K]
func (*Set[T]) StableSort ¶ added in v0.0.5
type SetIter ¶
type SetIter[K comparable] struct { it.Key[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) bool) *SetIter[K]
NewSetIter creates SetIter instance.
type Vector ¶
type Vector[T any] []T
Vector is the Collection implementation that provides elements order and index access.
func WrapVector ¶
WrapVector instantiates Vector using a slise as internal storage.
func (*Vector[T]) BeginEdit ¶
func (v *Vector[T]) BeginEdit() c.DelIterator[T]
BeginEdit creates an iterator with deleting elements
func (*Vector[T]) Collect ¶
func (v *Vector[T]) Collect() []T
Collect transforms the vector to a slice
func (*Vector[T]) First ¶
First returns the first element of the vector, an iterator to iterate over the remaining elements, and true\false marker of availability next elements. If no more elements then returns false in the last value.
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]) Last ¶
Last returns the last element of the vector, an iterator to iterate over the remaining elements, and true\false marker of availability prev elements. If no more elements then returns false in the last value.