container

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[T any](iter Iterator[T], fn func(elem T) bool) bool

func Any

func Any[T any](iter Iterator[T], fn func(elem T) bool) bool

func Fold

func Fold[T, U any](iter Iterator[T], init U, fn func(acc U, elem T) U) U

func ListBinaryContains

func ListBinaryContains[T constraints.Ordered](list List[T], elem T) bool

func ListBinarySearch

func ListBinarySearch[T constraints.Ordered](list List[T], elem T) int

func ListContains

func ListContains[T comparable](list List[T], elem T) bool

func ListRemove

func ListRemove[T comparable](list *List[T], elem T)

func ListSearch

func ListSearch[T comparable](list List[T], elem T) int

func ScanIfWithIndex

func ScanIfWithIndex[T any](iter Iterator[T], fn func(index int, elem T) bool)

func ScanWithIndex

func ScanWithIndex[T any](iter Iterator[T], fn func(index int, elem T))

func Sort

func Sort[T constraints.Ordered](list List[T])

func SortBy

func SortBy[T any](list List[T], fn func(lhs, rhs T) bool)

func SortStable

func SortStable[T constraints.Ordered](list List[T])

func SortStableBy

func SortStableBy[T any](list List[T], fn func(lhs, rhs T) bool)

Types

type Heap

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

func NewHeap

func NewHeap[T any](comp func(l, r T) bool) *Heap[T]

func NewHeapLess

func NewHeapLess[T constraints.Ordered]() *Heap[T]

func (*Heap[T]) Copy

func (heap *Heap[T]) Copy() *Heap[T]

func (*Heap[T]) Data

func (heap *Heap[T]) Data() []T

func (*Heap[T]) Len

func (heap *Heap[T]) Len() int

func (*Heap[T]) Peek

func (heap *Heap[T]) Peek() (first T, ok bool)

func (*Heap[T]) Pop

func (heap *Heap[T]) Pop() T

func (*Heap[T]) Push

func (heap *Heap[T]) Push(v T)

func (*Heap[T]) Remove

func (heap *Heap[T]) Remove(i int) T

type Iterator

type Iterator[T any] interface {
	ScanIf(fn func(elem T) bool)
	Scan(fn func(elem T))
	Len() int
}

type List

type List[T any] []T

func Filter

func Filter[T any](iter Iterator[T], fn func(elem T) bool) List[T]

func FlatTrans

func FlatTrans[T, U any](iter Iterator[T], fn func(elem T) Iterator[U]) List[U]

func ListOf

func ListOf[T any](iter Iterator[T]) List[T]

func NewList

func NewList[T any](args ...T) List[T]

func Sorted

func Sorted[T constraints.Ordered](list List[T]) List[T]

func SortedBy

func SortedBy[T any](list List[T], fn func(lhs, rhs T) bool) List[T]

func SortedStable

func SortedStable[T constraints.Ordered](list List[T]) List[T]

func SortedStableBy

func SortedStableBy[T any](list List[T], fn func(lhs, rhs T) bool) List[T]

func Trans

func Trans[T, U any](iter Iterator[T], fn func(elem T) U) List[U]

func Zip

func Zip[T, U any](iterA Iterator[T], iterB Iterator[U]) List[Pair[T, U]]

func (*List[T]) Add

func (list *List[T]) Add(elem T)

func (*List[T]) AddIndex

func (list *List[T]) AddIndex(index int, elem T)

func (*List[T]) Clear

func (list *List[T]) Clear()

func (List[T]) Copy

func (list List[T]) Copy() List[T]

func (List[T]) IsEmpty

func (list List[T]) IsEmpty() bool

func (List[T]) Len

func (list List[T]) Len() int

func (*List[T]) RemoveIf

func (list *List[T]) RemoveIf(fn func(elem T) bool)

func (*List[T]) RemoveIndex

func (list *List[T]) RemoveIndex(index int)

func (*List[T]) RemoveLast

func (list *List[T]) RemoveLast()

func (*List[T]) RemoveSwap

func (list *List[T]) RemoveSwap(index int)

func (List[T]) Scan

func (list List[T]) Scan(fn func(elem T))

func (List[T]) ScanIV

func (list List[T]) ScanIV(fn func(index int, elem T))

func (List[T]) ScanIf

func (list List[T]) ScanIf(fn func(elem T) bool)

func (List[T]) Shuffle

func (list List[T]) Shuffle()

func (List[T]) Shuffled

func (list List[T]) Shuffled() List[T]

func (List[T]) Swap

func (list List[T]) Swap(i, j int)

type Map

type Map[T comparable, U any] map[T]U

func GroupBy

func GroupBy[T any, U comparable, V any](iter Iterator[T], keyFn func(T) U, valueFn func(T) V) Map[U, List[V]]

func MapBy

func MapBy[T comparable, U any](iter Iterator[T], fn func(elem T) U) Map[T, U]

func MapOf

func MapOf[T comparable, U any](iter Iterator[Pair[T, U]]) Map[T, U]

func NewMap

func NewMap[T comparable, U any](args ...Pair[T, U]) Map[T, U]

func (Map[T, U]) Add

func (m Map[T, U]) Add(key T, value U)

func (Map[T, U]) AddAll

func (m Map[T, U]) AddAll(iter Iterator[Pair[T, U]])

func (*Map[T, U]) Clear

func (m *Map[T, U]) Clear()

func (Map[T, U]) Contains

func (m Map[T, U]) Contains(key T) bool

func (Map[T, U]) Copy

func (m Map[T, U]) Copy() Map[T, U]

func (Map[T, U]) Get

func (m Map[T, U]) Get(key T) (U, bool)

func (Map[T, U]) IsEmpty

func (m Map[T, U]) IsEmpty() bool

func (Map[T, U]) Keys

func (m Map[T, U]) Keys() List[T]

func (Map[T, U]) Len

func (m Map[T, U]) Len() int

func (Map[T, U]) Remove

func (m Map[T, U]) Remove(key T)

func (Map[T, U]) RemoveAll

func (m Map[T, U]) RemoveAll(iter Iterator[T])

func (Map[T, U]) Scan

func (m Map[T, U]) Scan(fn func(entry Pair[T, U]))

func (Map[T, U]) ScanIf

func (m Map[T, U]) ScanIf(fn func(entry Pair[T, U]) bool)

func (Map[T, U]) ScanKV

func (m Map[T, U]) ScanKV(fn func(k T, v U))

func (Map[T, U]) ScanKVIf

func (m Map[T, U]) ScanKVIf(fn func(k T, v U) bool)

func (Map[T, U]) Values

func (m Map[T, U]) Values() List[U]

func (Map[T, U]) WithKey

func (m Map[T, U]) WithKey(key T, fn func(key T, value U)) int

type OrderedMap

type OrderedMap[T constraints.Ordered, U any] struct {
	// contains filtered or unexported fields
}

func NewOrderedMap

func NewOrderedMap[T constraints.Ordered, U any](args ...Pair[T, U]) *OrderedMap[T, U]

func OrderedMapBy

func OrderedMapBy[T constraints.Ordered, U any](iter Iterator[T], fn func(elem T) U) *OrderedMap[T, U]

func OrderedMapOf

func OrderedMapOf[T constraints.Ordered, U any](iter Iterator[Pair[T, U]]) *OrderedMap[T, U]

func (*OrderedMap[T, U]) Add

func (m *OrderedMap[T, U]) Add(key T, value U)

func (*OrderedMap[T, U]) AddAll

func (m *OrderedMap[T, U]) AddAll(iter Iterator[Pair[T, U]])

func (*OrderedMap[T, U]) Clear

func (m *OrderedMap[T, U]) Clear()

func (*OrderedMap[T, U]) Contains

func (m *OrderedMap[T, U]) Contains(key T) bool

func (*OrderedMap[T, U]) Copy

func (m *OrderedMap[T, U]) Copy() *OrderedMap[T, U]

func (*OrderedMap[T, U]) Get

func (m *OrderedMap[T, U]) Get(key T) (U, bool)

func (*OrderedMap[T, U]) IsEmpty

func (m *OrderedMap[T, U]) IsEmpty() bool

func (*OrderedMap[T, U]) Keys

func (m *OrderedMap[T, U]) Keys() List[T]

func (*OrderedMap[T, U]) Len

func (m *OrderedMap[T, U]) Len() int

func (*OrderedMap[T, U]) Remove

func (m *OrderedMap[T, U]) Remove(key T)

func (*OrderedMap[T, U]) RemoveAll

func (m *OrderedMap[T, U]) RemoveAll(iter Iterator[T])

func (*OrderedMap[T, U]) Scan

func (m *OrderedMap[T, U]) Scan(fn func(entry Pair[T, U]))

func (*OrderedMap[T, U]) ScanIKV

func (m *OrderedMap[T, U]) ScanIKV(fn func(index int, key T, value U))

func (*OrderedMap[T, U]) ScanIf

func (m *OrderedMap[T, U]) ScanIf(fn func(entry Pair[T, U]) bool)

func (*OrderedMap[T, U]) ScanKV

func (m *OrderedMap[T, U]) ScanKV(fn func(key T, value U))

func (*OrderedMap[T, U]) ScanKVIf

func (m *OrderedMap[T, U]) ScanKVIf(fn func(key T, value U) bool)

func (*OrderedMap[T, U]) Values

func (m *OrderedMap[T, U]) Values() List[U]

func (*OrderedMap[T, U]) WithKey

func (m *OrderedMap[T, U]) WithKey(key T, fn func(key T, value U)) int

func (*OrderedMap[T, U]) WithKeyRange

func (m *OrderedMap[T, U]) WithKeyRange(keyLow T, keyHigh T, fn func(key T, value U)) (cnt int)

TODO

type OrderedSet

type OrderedSet[T constraints.Ordered] struct {
	// contains filtered or unexported fields
}

func NewOrderedSet

func NewOrderedSet[T constraints.Ordered](args ...T) *OrderedSet[T]

func OrderedSetOf

func OrderedSetOf[T constraints.Ordered](iter Iterator[T]) *OrderedSet[T]

func (*OrderedSet[T]) Add

func (set *OrderedSet[T]) Add(elem T)

func (*OrderedSet[T]) Clear

func (set *OrderedSet[T]) Clear()

func (*OrderedSet[T]) Contains

func (set *OrderedSet[T]) Contains(elem T) bool

func (*OrderedSet[T]) Copy

func (set *OrderedSet[T]) Copy() *OrderedSet[T]

func (*OrderedSet[T]) GetAt

func (m *OrderedSet[T]) GetAt(key int) (value T, err bool)

func (*OrderedSet[T]) Intersect

func (set *OrderedSet[T]) Intersect(rhs *OrderedSet[T])

func (*OrderedSet[T]) Intersected

func (set *OrderedSet[T]) Intersected(rhs *OrderedSet[T]) *OrderedSet[T]

func (*OrderedSet[T]) IsEmpty

func (set *OrderedSet[T]) IsEmpty() bool

func (*OrderedSet[T]) Len

func (set *OrderedSet[T]) Len() int

func (*OrderedSet[T]) Remove

func (set *OrderedSet[T]) Remove(elem T)

func (*OrderedSet[T]) Scan

func (set *OrderedSet[T]) Scan(fn func(elem T))

func (*OrderedSet[T]) ScanIV

func (set *OrderedSet[T]) ScanIV(fn func(i int, elem T))

func (*OrderedSet[T]) ScanIf

func (set *OrderedSet[T]) ScanIf(fn func(elem T) bool)

func (*OrderedSet[T]) Substract

func (set *OrderedSet[T]) Substract(rhs *OrderedSet[T])

func (*OrderedSet[T]) Substracted

func (set *OrderedSet[T]) Substracted(rhs *OrderedSet[T]) *OrderedSet[T]

func (*OrderedSet[T]) Union

func (set *OrderedSet[T]) Union(rhs *OrderedSet[T])

func (*OrderedSet[T]) Unioned

func (set *OrderedSet[T]) Unioned(rhs *OrderedSet[T]) *OrderedSet[T]

func (*OrderedSet[T]) WithKey

func (m *OrderedSet[T]) WithKey(key T, fn func(key T)) int

func (*OrderedSet[T]) WithKeyRange

func (m *OrderedSet[T]) WithKeyRange(keyLow T, keyHigh T, fn func(key T)) (cnt int)

TODO

type Pair

type Pair[T, U any] struct {
	First  T
	Second U
}

type Set

type Set[T comparable] map[T]struct{}

func NewSet

func NewSet[T comparable](args ...T) Set[T]

func SetOf

func SetOf[T comparable](iter Iterator[T]) Set[T]

func (Set[T]) Add

func (set Set[T]) Add(elem T)

func (*Set[T]) Clear

func (set *Set[T]) Clear()

func (Set[T]) Contains

func (set Set[T]) Contains(elem T) bool

func (Set[T]) Copy

func (set Set[T]) Copy() Set[T]

func (Set[T]) Intersect

func (set Set[T]) Intersect(iter Iterator[T])

func (Set[T]) Intersected

func (set Set[T]) Intersected(iter Iterator[T]) Set[T]

func (Set[T]) IsEmpty

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

func (Set[T]) Len

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

func (Set[T]) Remove

func (set Set[T]) Remove(elem T)

func (Set[T]) Scan

func (set Set[T]) Scan(fn func(elem T))

func (Set[T]) ScanIf

func (set Set[T]) ScanIf(fn func(elem T) bool)

func (Set[T]) Substract

func (set Set[T]) Substract(iter Iterator[T])

func (Set[T]) Substracted

func (set Set[T]) Substracted(iter Iterator[T]) Set[T]

func (Set[T]) Union

func (set Set[T]) Union(iter Iterator[T])

func (Set[T]) Unioned

func (set Set[T]) Unioned(iter Iterator[T]) Set[T]

func (Set[T]) WithKey

func (set Set[T]) WithKey(key T, fn func(key T)) int

type ThreadSafeQueue

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

func NewThreadSafeQueue

func NewThreadSafeQueue[T any]() (q *ThreadSafeQueue[T])

NewThreadSafeQueue creates a lock-free queue

func (*ThreadSafeQueue[T]) Deq

func (q *ThreadSafeQueue[T]) Deq() (ret T)

func (*ThreadSafeQueue[T]) Empty

func (q *ThreadSafeQueue[T]) Empty() bool

func (*ThreadSafeQueue[T]) Enq

func (q *ThreadSafeQueue[T]) Enq(v T)

type Triple

type Triple[T, U, V any] struct {
	First  T
	Second U
	Third  V
}

type Tuple10

type Tuple10[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 any] struct {
	V0 T0
	V1 T1
	V2 T2
	V3 T3
	V4 T4
	V5 T5
	V6 T6
	V7 T7
	V8 T8
	V9 T9
}

type Tuple4

type Tuple4[T0, T1, T2, T3 any] struct {
	V0 T0
	V1 T1
	V2 T2
	V3 T3
}

type Tuple5

type Tuple5[T0, T1, T2, T3, T4 any] struct {
	V0 T0
	V1 T1
	V2 T2
	V3 T3
	V4 T4
}

type Tuple6

type Tuple6[T0, T1, T2, T3, T4, T5 any] struct {
	V0 T0
	V1 T1
	V2 T2
	V3 T3
	V4 T4
	V5 T5
}

type Tuple7

type Tuple7[T0, T1, T2, T3, T4, T5, T6 any] struct {
	V0 T0
	V1 T1
	V2 T2
	V3 T3
	V4 T4
	V5 T5
	V6 T6
}

type Tuple8

type Tuple8[T0, T1, T2, T3, T4, T5, T6, T7 any] struct {
	V0 T0
	V1 T1
	V2 T2
	V3 T3
	V4 T4
	V5 T5
	V6 T6
	V7 T7
}

type Tuple9

type Tuple9[T0, T1, T2, T3, T4, T5, T6, T7, T8 any] struct {
	V0 T0
	V1 T1
	V2 T2
	V3 T3
	V4 T4
	V5 T5
	V6 T6
	V7 T7
	V8 T8
}

Jump to

Keyboard shortcuts

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