mutable

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package mutable provides implementations of mutable containers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iter

type Iter[T any, TS ~[]T] struct {
	// contains filtered or unexported fields
}

Iter is the Iterator implementation for mutable containers.

func NewHead

func NewHead[T any, TS ~[]T](elements *TS, del func(int) bool) Iter[T, TS]

NewHead instantiates Iter starting at the first element of a sclie.

func NewTail

func NewTail[T any, TS ~[]T](elements *TS, del func(int) bool) Iter[T, TS]

NewTail instantiates Iter starting at the last element of a sclie.

func (*Iter[T, TS]) Cap

func (i *Iter[T, TS]) Cap() int

func (*Iter[T, TS]) Delete

func (i *Iter[T, TS]) Delete() bool

func (*Iter[T, TS]) DeleteNext

func (i *Iter[T, TS]) DeleteNext() bool

func (*Iter[T, TS]) DeletePrev

func (i *Iter[T, TS]) DeletePrev() bool

func (*Iter[T, TS]) Get

func (i *Iter[T, TS]) Get() (T, bool)

func (*Iter[T, TS]) GetNext

func (i *Iter[T, TS]) GetNext() T

func (*Iter[T, TS]) GetPrev

func (i *Iter[T, TS]) GetPrev() T

func (*Iter[T, TS]) HasNext

func (i *Iter[T, TS]) HasNext() bool

func (*Iter[T, TS]) HasPrev

func (i *Iter[T, TS]) HasPrev() bool

func (*Iter[T, TS]) Next

func (i *Iter[T, TS]) Next() (T, bool)

func (*Iter[T, TS]) Prev

func (i *Iter[T, TS]) Prev() (T, bool)

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]) Collect

func (s Map[K, V]) Collect() map[K]V

func (Map[K, V]) Contains

func (s Map[K, V]) Contains(key K) bool

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]) FilterKey

func (s Map[K, V]) FilterKey(fit c.Predicate[K]) c.MapPipe[K, V, map[K]V]

func (Map[K, V]) FilterValue

func (s Map[K, V]) FilterValue(fit c.Predicate[V]) c.MapPipe[K, V, map[K]V]

func (Map[K, V]) First

func (s Map[K, V]) First() (it.KV[K, V], K, V, bool)

func (Map[K, V]) For

func (s Map[K, V]) For(walker func(c.KV[K, V]) error) error

func (Map[K, V]) ForEach

func (s Map[K, V]) ForEach(walker func(c.KV[K, V]))

func (Map[K, V]) Get

func (s Map[K, V]) Get(key K) (V, bool)

func (Map[K, V]) Head

func (s Map[K, V]) Head() it.KV[K, V]

func (Map[K, V]) IsEmpty

func (s Map[K, V]) IsEmpty() bool

func (Map[K, V]) K

func (s Map[K, V]) K() immutable.MapKeys[K, V]

func (Map[K, V]) Keys

func (s Map[K, V]) Keys() c.Collection[K, []K, c.Iterator[K]]

func (Map[K, V]) Len

func (s Map[K, V]) Len() int

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]) MapKey

func (s Map[K, V]) MapKey(by c.Converter[K, K]) c.MapPipe[K, V, map[K]V]

func (Map[K, V]) MapValue

func (s Map[K, V]) MapValue(by c.Converter[V, 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)

func (Map[K, V]) Set

func (s Map[K, V]) Set(key K, value V) bool

func (Map[K, V]) String

func (s Map[K, V]) String() string

func (Map[K, V]) Track

func (s Map[K, V]) Track(tracker func(K, V) error) error

func (Map[K, V]) TrackEach

func (s Map[K, V]) TrackEach(tracker func(K, V))

func (Map[K, V]) V

func (s Map[K, V]) V() immutable.MapValues[K, V]

func (Map[K, V]) Values

func (s Map[K, V]) Values() c.Collection[V, []V, c.Iterator[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]) Add

func (s Set[K]) Add(elements ...K) bool

func (Set[K]) AddAll

func (s Set[K]) AddAll(elements []K) bool

func (Set[K]) AddOne

func (s Set[K]) AddOne(element K) bool

func (Set[K]) Begin

func (s Set[K]) Begin() c.Iterator[K]

func (Set[K]) BeginEdit

func (s Set[K]) BeginEdit() c.DelIterator[K]

func (Set[K]) Collect

func (s Set[K]) Collect() []K

func (Set[K]) Contains

func (s Set[K]) Contains(val K) bool

func (Set[T]) Copy

func (s Set[T]) Copy() Set[T]

func (Set[K]) Delete

func (s Set[K]) Delete(elements ...K) bool

func (Set[K]) DeleteOne

func (s Set[K]) DeleteOne(element K) bool

func (Set[K]) Filter

func (s Set[K]) Filter(filter c.Predicate[K]) c.Pipe[K, []K]

func (Set[K]) For

func (s Set[K]) For(walker func(K) error) error

func (Set[K]) ForEach

func (s Set[K]) ForEach(walker func(K))

func (Set[K]) Head

func (s Set[K]) Head() *SetIter[K]

func (Set[T]) IsEmpty

func (s Set[T]) IsEmpty() bool

func (Set[K]) Len

func (s Set[K]) Len() int

func (Set[K]) Map

func (s Set[K]) Map(by c.Converter[K, K]) c.Pipe[K, []K]

func (Set[K]) Reduce

func (s Set[K]) Reduce(by c.Binary[K]) K

func (Set[T]) Sort

func (s Set[T]) Sort(less func(e1, e2 T) bool) *ordered.Set[T]

Sort transforms to the ordered Set contains sorted elements.

func (Set[K]) String

func (s Set[K]) String() string

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.

func (*SetIter[K]) Delete

func (i *SetIter[K]) Delete() bool

func (*SetIter[K]) Next

func (i *SetIter[K]) Next() (K, bool)

type Vector

type Vector[T any] []T

Vector is the Collection implementation that provides elements order and index access.

func NewVector

func NewVector[T any](capacity int) *Vector[T]

NewVector instantiates Vector with a predefined capacity.

func ToVector

func ToVector[T any](elements []T) *Vector[T]

ToVector instantiates Vector based on copy of elements slice

func WrapVector

func WrapVector[T any](elements []T) *Vector[T]

WrapVector instantiates Vector using a slise as internal storage.

func (*Vector[T]) Add

func (v *Vector[T]) Add(elements ...T) bool

func (*Vector[T]) AddAll

func (v *Vector[T]) AddAll(elements []T) bool

func (*Vector[T]) AddOne

func (v *Vector[T]) AddOne(element T) bool

func (*Vector[T]) Begin

func (v *Vector[T]) Begin() c.Iterator[T]

func (*Vector[T]) BeginEdit

func (v *Vector[T]) BeginEdit() c.DelIterator[T]

func (*Vector[T]) Collect

func (v *Vector[T]) Collect() []T

func (*Vector[T]) Copy

func (v *Vector[T]) Copy() *Vector[T]

func (*Vector[T]) Delete

func (v *Vector[T]) Delete(indexes ...int) bool

func (*Vector[T]) DeleteOne

func (v *Vector[T]) DeleteOne(index int) bool

func (*Vector[T]) Filter

func (v *Vector[T]) Filter(filter c.Predicate[T]) c.Pipe[T, []T]

func (*Vector[T]) First

func (v *Vector[T]) First() (Iter[T, Vector[T]], T, bool)

func (*Vector[T]) For

func (v *Vector[T]) For(walker func(T) error) error

func (*Vector[T]) ForEach

func (v *Vector[T]) ForEach(walker func(T))

func (*Vector[T]) Get

func (v *Vector[T]) Get(index int) (T, bool)

func (*Vector[T]) Head

func (v *Vector[T]) Head() Iter[T, Vector[T]]

func (*Vector[T]) IsEmpty

func (v *Vector[T]) IsEmpty() bool

func (*Vector[T]) Last

func (v *Vector[T]) Last() (Iter[T, Vector[T]], T, bool)

func (*Vector[T]) Len

func (v *Vector[T]) Len() int

func (*Vector[T]) Map

func (v *Vector[T]) Map(by c.Converter[T, T]) c.Pipe[T, []T]

func (*Vector[T]) Reduce

func (v *Vector[T]) Reduce(by c.Binary[T]) T

func (*Vector[T]) Remove

func (v *Vector[T]) Remove(index int) (T, bool)

func (*Vector[T]) Set

func (v *Vector[T]) Set(index int, value T) bool

func (*Vector[t]) Sort

func (v *Vector[t]) Sort(less func(e1, e2 t) bool) *Vector[t]

Sotr sorts the Vector in-place and returns it.

func (*Vector[T]) String

func (v *Vector[T]) String() string

String returns then string representation.

func (*Vector[T]) Tail

func (v *Vector[T]) Tail() Iter[T, Vector[T]]

func (*Vector[T]) Track

func (v *Vector[T]) Track(tracker func(int, T) error) error

func (*Vector[T]) TrackEach

func (v *Vector[T]) TrackEach(tracker func(int, T))

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL