Documentation ¶
Overview ¶
Package c provides common types of containers, utility types and functions.
Index ¶
- type Access
- type Addable
- type BiConverter
- type BiPredicate
- type Checkable
- type Collection
- type Container
- type Converter
- type DelIterator
- type Deleteable
- type Flatter
- type Iterable
- type Iterator
- type KV
- type KVIterator
- type Map
- type MapPipe
- type MapTransformable
- type Pipe
- type Predicate
- type PrevIterator
- type Removable
- type Set
- type Settable
- 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).
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) //returns an estimated internal storage capacity Cap() int }
Iterator is the interface that provides iterate over elements of a collection.
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) Cap() int }
KVIterator is the interface that provides iterate over all key/value pair of a map.
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 Pipe ¶
type Pipe[T any, Collection any] interface { Transformable[T, Collection] Container[Collection, Iterator[T]] Walk[T] WalkEach[T] Reduce(op.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 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 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.