colf

package
v0.11.5 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

Package colf contains some commonly used collections abstractions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAll

func AddAll[E any](appendable Addable[E], iterable Iterable[E])

AddAll adds all elements from Iterable to Addable.

func Contains

func Contains[E comparable](iterable Iterable[E], value E) (match bool)

Contains checks if an element is in an Iterable.

Types

type Addable

type Addable[E any] interface{ Add(element E) }

Addable is a mutable collection which can be added elements to.

type ForEach

type ForEach[E any] func(element E) bool

ForEach is an iteration function.

type Iterable

type Iterable[E any] interface{ ForEach(forEach ForEach[E]) }

Iterable can be iterated with a ForEach function.

type Set

type Set[E comparable] map[E]bool

Set contains non-repeating values.

func (*Set[E]) Add

func (s *Set[E]) Add(element E)

func (Set[E]) ForEach

func (s Set[E]) ForEach(forEach ForEach[E])

func (Set[E]) MarshalJSON

func (s Set[E]) MarshalJSON() ([]byte, error)

func (Set[E]) MarshalYAML

func (s Set[E]) MarshalYAML() (interface{}, error)

func (Set[E]) Size

func (s Set[E]) Size() int

func (*Set[E]) UnmarshalJSON

func (s *Set[E]) UnmarshalJSON(data []byte) error

func (*Set[E]) UnmarshalYAML

func (s *Set[E]) UnmarshalYAML(node *yaml.Node) error

type Sizeable

type Sizeable interface{ Size() int }

Sizeable is a collection with a defined size.

type Slice

type Slice[E any] []E

Slice is a wrapper for slices.

func Keys

func Keys[K comparable, V any](values map[K]V) Slice[K]

Keys returns a Set containing map keys.

func ToSlice

func ToSlice[E any](iterable Iterable[E]) Slice[E]

ToSlice collects all elements from Iterable into a Slice.

func (*Slice[E]) Add

func (s *Slice[E]) Add(element E)

func (Slice[E]) ForEach

func (s Slice[E]) ForEach(forEach ForEach[E])

func (Slice[E]) Size

func (s Slice[E]) Size() int

Jump to

Keyboard shortcuts

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