kv

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package kv provides generic key/value pair constructors and helpers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New[K any, V any](key K, value V) c.KV[K, V]

New creates a key/value pair holder

Types

type Collection

type Collection[K comparable, V any, M map[K]V | map[K][]V] interface {
	c.TrackLoop[K, V]
	c.TrackEachLoop[K, V]
	Iterable[K, V]
	c.MapFactory[K, V, M]

	Reduce(merger func(K, K, V, V) (K, V)) (K, V)
}

Collection is the base interface of associative collections

type Convertable

type Convertable[K, V, KVStream, KVStreamBreakable any] interface {
	Convert(converter func(K, V) (K, V)) KVStream
	Conv(converter func(K, V) (K, V, error)) KVStreamBreakable

	ConvertKey(converter func(K) K) KVStream
	ConvertValue(converter func(V) V) KVStream

	ConvKey(converter func(K) (K, error)) KVStreamBreakable
	ConvValue(converter func(V) (V, error)) KVStreamBreakable
}

Convertable provides limited kit of map transformation methods

type Filterable

type Filterable[K, V, KVStream, KVStreamBreakable any] interface {
	Filter(predicate func(K, V) bool) KVStream
	Filt(predicate func(K, V) (bool, error)) KVStreamBreakable

	FilterKey(predicate func(K) bool) KVStream
	FilterValue(predicate func(V) bool) KVStream

	FiltKey(predicate func(K) (bool, error)) KVStreamBreakable
	FiltValue(predicate func(V) (bool, error)) KVStreamBreakable
}

Filterable provides limited kit of filering methods

type Iterable

type Iterable[K, V any] interface {
	Iter() Iterator[K, V]
}

Iterable is an iterator supplier interface

type Iterator

type Iterator[K, V any] interface {
	// Next returns the next key/value pair.
	// The ok result indicates whether the element was returned by the iterator.
	// If ok == false, then the iteration must be completed.
	Next() (key K, value V, ok bool)
	c.TrackLoop[K, V]
	c.TrackEachLoop[K, V]
}

Iterator provides iterate over key/value pairs

Directories

Path Synopsis
Package group provides short aliases for functions that are used to group collection elements
Package group provides short aliases for functions that are used to group collection elements
Package iter provides generic constructors and helpers for key/value iterators
Package iter provides generic constructors and helpers for key/value iterators
group
Package group provides short aliases for functions that are used to group key/values retieved by an iterator
Package group provides short aliases for functions that are used to group key/values retieved by an iterator
Package loop provides helpers for loop operation over key/value pairs and iterator implementations
Package loop provides helpers for loop operation over key/value pairs and iterator implementations
group
Package group provides short aliases for functions thath are used to group key/value pairs retrieved by a loop
Package group provides short aliases for functions thath are used to group key/value pairs retrieved by a loop
Package stream provides a stream implementation and helper functions
Package stream provides a stream implementation and helper functions

Jump to

Keyboard shortcuts

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