immutable

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package immutable provides implementations of constant containers.

Index

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 the Collection implementation that provides element access by an unique key.

func ConvertKVsToMap

func ConvertKVsToMap[K comparable, V any](elements []c.KV[K, V]) Map[K, V]

ConvertKVsToMap converts a slice of key/value pairs to the Map.

func NewMap

func NewMap[K comparable, V any](elements map[K]V) Map[K, V]

NewMap instantiates Map with values copied from an map.

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 (m Map[K, V]) Begin() c.KVIterator[K, V]

Begin creates a key/value iterator interface.

func (Map[K, V]) Collect

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

Collect exports the content as a map.

func (Map[K, V]) Contains

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

func (Map[K, V]) Filter

func (m Map[K, V]) Filter(filter c.BiPredicate[K, V]) c.MapPipe[K, V, map[K]V]

func (Map[K, V]) FilterKey

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

func (Map[K, V]) FilterValue

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

func (Map[K, V]) For

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

func (Map[K, V]) ForEach

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

func (Map[K, V]) Get

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

func (Map[K, V]) Head

func (m Map[K, V]) Head() it.EmbedMapKVIter[K, V]

Head creates a key/value iterator implementation started from the head.

func (Map[K, V]) IsEmpty

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

func (Map[K, V]) K

func (m Map[K, V]) K() MapKeys[K, V]

func (Map[K, V]) Keys

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

func (Map[K, V]) Len

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

func (Map[K, V]) Map

func (m Map[K, V]) Map(by c.BiConverter[K, V, K, V]) c.MapPipe[K, V, map[K]V]

Map creates an Iterator that applies a converter to iterable elements. The 'by' converter is applied only when the 'Next' method of returned Iterator is called and does not change the elements of the map.

func (Map[K, V]) MapKey

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

func (Map[K, V]) MapValue

func (m Map[K, V]) MapValue(by c.Converter[V, V]) c.MapPipe[K, V, map[K]V]

func (Map[K, V]) Reduce

func (m Map[K, V]) Reduce(by c.Quaternary[K, V]) (K, V)

Reduce reduces key\value pairs to an one.

func (Map[K, V]) Sort

func (m Map[K, V]) Sort(less slice.Less[K]) ordered.Map[K, V]

Sort transforms to the ordered Map contains sorted elements.

func (Map[K, V]) StableSort added in v0.0.5

func (m Map[K, V]) StableSort(less slice.Less[K]) ordered.Map[K, V]

func (Map[K, V]) String

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

String is part of the Stringer interface for printing the string representation of this Map.

func (Map[K, V]) Track

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

Track apply a tracker to touch key, value from the inside. To stop traking just return the map_.Break.

func (Map[K, V]) TrackEach

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

TrackEach apply a tracker to touch each key, value from the inside.

func (Map[K, V]) V

func (m Map[K, V]) V() MapValues[K, V]

func (Map[K, V]) Values

func (m Map[K, V]) Values() c.Collection[V, []V, c.Iterator[V]]

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](uniques map[K]V) MapKeys[K, V]

WrapKeys is non-copy constructor

func (MapKeys[K, V]) Begin

func (s MapKeys[K, V]) Begin() c.Iterator[K]

func (MapKeys[K, V]) Collect

func (s MapKeys[K, V]) Collect() []K

func (MapKeys[K, V]) Filter

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

func (MapKeys[K, V]) First

func (s MapKeys[K, V]) First() (it.Key[K, V], K, bool)

func (MapKeys[K, V]) For

func (s MapKeys[K, V]) For(walker func(K) error) error

func (MapKeys[K, V]) ForEach

func (s MapKeys[K, V]) ForEach(walker func(K))

func (MapKeys[K, V]) Head

func (s MapKeys[K, V]) Head() it.Key[K, V]

func (MapKeys[K, V]) IsEmpty

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

func (MapKeys[K, V]) Len

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

func (MapKeys[K, V]) Map

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

func (MapKeys[K, V]) Reduce

func (s MapKeys[K, V]) Reduce(by c.Binary[K]) K

func (MapKeys[K, V]) String

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

type MapValues

type MapValues[K comparable, V any] struct {
	// contains filtered or unexported fields
}

MapValues is the wrapper for Map's 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]) Begin

func (s MapValues[K, V]) Begin() c.Iterator[V]

func (MapValues[K, V]) Collect

func (s MapValues[K, V]) Collect() []V

func (MapValues[K, V]) Filter

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

func (MapValues[K, V]) First

func (s MapValues[K, V]) First() (it.Val[K, V], V, bool)

func (MapValues[K, V]) For

func (s MapValues[K, V]) For(walker func(V) error) error

func (MapValues[K, V]) ForEach

func (s MapValues[K, V]) ForEach(walker func(V))

func (MapValues[K, V]) Head

func (s MapValues[K, V]) Head() it.Val[K, V]

func (MapValues[K, V]) IsEmpty

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

func (MapValues[K, V]) Len

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

func (MapValues[K, V]) Map

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

func (MapValues[K, V]) Reduce

func (s MapValues[K, V]) Reduce(by c.Binary[V]) V

func (MapValues[K, V]) Sort

func (s MapValues[K, V]) Sort(less func(e1, e2 V) bool) Vector[V]

func (MapValues[K, V]) String

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

type Set

type Set[T comparable] struct {
	// contains filtered or unexported fields
}

Set is the Collection implementation that provides the uniqueness of its elements. Elements must be comparable.

func NewSet

func NewSet[T comparable](elements []T) Set[T]

NewSet instantiates Set and copies elements to it.

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

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

func (Set[T]) Collect

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

func (Set[T]) Contains

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

func (Set[T]) Filter

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

func (Set[T]) First

func (s Set[T]) First() (it.Key[T, struct{}], T, bool)

func (Set[T]) For

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

func (Set[T]) ForEach

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

func (Set[T]) Head

func (s Set[T]) Head() it.Key[T, struct{}]

func (Set[T]) IsEmpty

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

func (Set[T]) Len

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

func (Set[T]) Map

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

func (Set[T]) Reduce

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

func (Set[T]) Sort

func (s Set[T]) Sort(less slice.Less[T]) ordered.Set[T]

Sort transforms to the ordered Set.

func (Set[T]) StableSort added in v0.0.5

func (s Set[T]) StableSort(less slice.Less[T]) ordered.Set[T]

func (Set[T]) String

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

type Vector

type Vector[T any] struct {
	// contains filtered or unexported fields
}

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

func NewVector

func NewVector[T any](elements []T) Vector[T]

NewVector instantiates Vector and copies elements to it.

func WrapVector

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

WrapVector instantiates Vector using a slise as internal storage.

func (Vector[T]) Begin

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

func (Vector[T]) Collect

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

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() (it.ArrayIter[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() it.ArrayIter[T]

func (Vector[T]) IsEmpty

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

func (Vector[T]) Last

func (v Vector[T]) Last() (it.ArrayIter[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]) Sort

func (v Vector[T]) Sort(less slice.Less[T]) Vector[T]

func (Vector[T]) StableSort added in v0.0.5

func (v Vector[T]) StableSort(less slice.Less[T]) Vector[T]

func (Vector[T]) String

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

func (Vector[T]) Tail

func (v Vector[T]) Tail() it.ArrayIter[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
Package map_ provides the unordered map container implementation
Package map_ provides the unordered map container implementation
Package omap provides the ordered map container implementation
Package omap provides the ordered map container implementation
Package oset provides the ordered set container implementation
Package oset provides the ordered set container implementation
Package set provides the unordered set container implementation
Package set provides the unordered set container implementation
Package vector provides the Vector (ordered) implementation
Package vector provides the Vector (ordered) implementation

Jump to

Keyboard shortcuts

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