Documentation ¶
Overview ¶
Package c provides common types of containers, utility types and functions.
Index ¶
- type Access
- type Addable
- type BiConverter
- type BiPredicate
- type Binary
- type Checkable
- type Collection
- type Container
- type Converter
- type DelIterator
- type Deleteable
- type Flatter
- type Iterable
- type Iterator
- type IteratorBreakable
- type KV
- type KVIterator
- type KVIteratorBreakable
- type Map
- type MapPipe
- type MapTransformable
- type Number
- type Pipe
- type Predicate
- type PrevIterator
- type Quaternary
- type Removable
- type Set
- type Settable
- type Sized
- type Summable
- type Track
- type TrackEach
- type Transformable
- type Vector
- type Walk
- type WalkEach
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Access ¶
Access is the interface that provides access to an element by its pointer (index, key, coordinate, etc.) Where:
P - a type of pointer to a value (index, map key, coordinates) V - any arbitrary type of the value
type BiConverter ¶
type BiConverter[From1, From2, To1, To2 any] func(From1, From2) (To1, To2)
BiConverter convert pairs of From -> To.
type BiPredicate ¶
BiPredicate tests values pair (converts to true or false).
func FitKey ¶ added in v0.0.5
func FitKey[K, V any](fit Predicate[K]) BiPredicate[K, V]
FitKey adapts a key appliable predicate to a key\value one
func FitValue ¶ added in v0.0.5
func FitValue[K, V any](fit Predicate[V]) BiPredicate[K, V]
FitValue adapts a value appliable predicate to a key\value one
type Binary ¶ added in v0.0.3
type Binary[T any] func(T, T) T
Binary is an operation with two arguments
type Collection ¶
type Collection[T any, Collection any, IT any] interface { Container[Collection, IT] Walk[T] WalkEach[T] Len() int IsEmpty() bool }
Collection is the interface of a finite-size container. Where:
T - any arbitrary type Collection - a collection type (may be slice, map or chain) IT - a iterator type (Iterator, KVIterator)
type Container ¶
Container is the base interface of implementations. Where:
Collection - a collection type (may be slice, map or chain) IT - a iterator type (Iterator, KVIterator)
type DelIterator ¶
DelIterator is the Iterator provides deleting of current element.
type Deleteable ¶
Deleteable is the interface that provides removing any elements from the collection.
type Iterable ¶
type Iterable[IT any] interface { Begin() IT }
Iterable is an iterator supplier interface
type Iterator ¶
type Iterator[T any] interface { // retrieves a next element and true or zero value of T and false if no more elements Next() (T, bool) }
Iterator is the interface that provides iterate over elements of a collection
type IteratorBreakable ¶ added in v0.0.4
type IteratorBreakable[T any] interface { Iterator[T] //returns an iteration abort error Error() error }
IteratorBreakable is the interface that provides iterate over elements of a source, where an iteration can be interrupted by an error.
type KV ¶
KV is the simplest implementation of a key/value pair.
type KVIterator ¶
type KVIterator[K, V any] interface { //retrieves next elements or zero values if no more elements Next() (K, V, bool) }
KVIterator is the interface that provides iterate over key/value pairs
type KVIteratorBreakable ¶ added in v0.0.5
type KVIteratorBreakable[K, V any] interface { KVIterator[K, V] //returns an iteration abort error Error() error }
KVIteratorBreakable is the interface that provides iterate over key/value pairs, where an iteration can be interrupted by an error
type Map ¶
type Map[K comparable, V any] interface { Collection[KV[K, V], map[K]V, KVIterator[K, V]] Track[V, K] TrackEach[V, K] Checkable[K] Access[K, V] MapTransformable[K, V, map[K]V] Keys() Collection[K, []K, Iterator[K]] Values() Collection[V, []V, Iterator[V]] }
Map - collection interface that stores key/value pairs and provide access to an element by its key
type MapPipe ¶
type MapPipe[K comparable, V any, Map any] interface { MapTransformable[K, V, Map] Container[Map, KVIterator[K, V]] }
MapPipe extends MapTransformable by finalize methods like ForEach, Collect or Reduce.
type MapTransformable ¶
type MapTransformable[K comparable, V any, Map any] interface { Filter(BiPredicate[K, V]) MapPipe[K, V, Map] Map(BiConverter[K, V, K, V]) MapPipe[K, V, Map] FilterKey(Predicate[K]) MapPipe[K, V, Map] MapKey(Converter[K, K]) MapPipe[K, V, Map] FilterValue(Predicate[V]) MapPipe[K, V, Map] MapValue(Converter[V, V]) MapPipe[K, V, Map] }
MapTransformable is the interface that provides limited kit of map transformation methods. The full kit of transformer functions are in the package 'c/map_'
type Number ¶ added in v0.0.3
type Number interface { constraints.Integer | constraints.Float | constraints.Complex }
Number is a type that supports the operators +, -, /, *
type Pipe ¶
type Pipe[T any, Collection any] interface { Transformable[T, Collection] Container[Collection, Iterator[T]] Walk[T] WalkEach[T] Reduce(Binary[T]) T }
Pipe extends Transformable by finalize methods like ForEach, Collect or Reduce.
type PrevIterator ¶
type PrevIterator[T any] interface { Iterator[T] //retrieves a prev element and true or zero value of T and false if no more elements Prev() (T, bool) }
PrevIterator is the Iterator that provides reverse iteration over elements of a collection
type Quaternary ¶ added in v0.0.3
type Quaternary[t1, t2 any] func(t1, t2, t1, t2) (t1, t2)
Quaternary is an operation with four arguments
type Removable ¶
Removable is the interface that provides removing an element by its pointer (index or key).
type Set ¶
type Set[T any] interface { Collection[T, []T, Iterator[T]] Transformable[T, []T] Checkable[T] }
Set - collection interface that ensures the uniqueness of elements (does not insert duplicate values).
type Settable ¶
Settable is the interface that provides replacing an element by its pointer (index or key).
type Sized ¶ added in v0.0.4
type Sized interface { // returns an estimated internal storage capacity or -1 if the capacity cannot be calculated Cap() int }
Sized - storage interface with measurable capacity
type Summable ¶ added in v0.0.3
type Summable interface { constraints.Ordered | constraints.Complex }
Summable is a type that supports the operator +
type Track ¶
Track is the interface of a collection that provides traversing of the elements with position tracking (index, key, coordinates, etc.).
type TrackEach ¶
TrackEach is the interface of a collection that provides traversing of the elements with position tracking (index, key, coordinates, etc.) without error checking
type Transformable ¶
type Transformable[T any, Collection any] interface { Filter(Predicate[T]) Pipe[T, Collection] Map(Converter[T, T]) Pipe[T, Collection] }
Transformable is the interface that provides limited kit of container transformation methods. The full kit of transformer functions are in the package 'c'
type Vector ¶
type Vector[T any] interface { Collection[T, []T, Iterator[T]] Track[T, int] TrackEach[T, int] Access[int, T] Transformable[T, []T] }
Vector - collection interface that provides elements order and access by index to the elements.