slices

package
v0.0.0-...-27647ab Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: BSD-3-Clause Imports: 6 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[T any](s []T, fn func(T) bool) bool

func Any

func Any[T any](s []T, fn func(T) bool) bool

func Apply

func Apply[T any](fn func(t T), s []T)

func AsAny

func AsAny[T any](s []T) []any

func Cast

func Cast[T, R any](s []T) []R

func Clone

func Clone[T any](s []T) []T

func Contains

func Contains[T comparable](s []T, v T) bool

func Count

func Count[T comparable](s []T, v T) int

func CountFunc

func CountFunc[T comparable](s []T, fn func(T) bool) int

func DeepFlatten

func DeepFlatten[T any](vs ...any) []T

func DeleteAt

func DeleteAt[T any](s []T, i int) []T

func Dup2

func Dup2[T any](v T) (T, T)

func Dup3

func Dup3[T any](v T) (T, T, T)

func Dup4

func Dup4[T any](v T) (T, T, T, T)

func Equal

func Equal[T comparable](l, r []T) bool

func Filter

func Filter[T any](fn func(t T) bool, s []T) []T

func Find

func Find[T comparable](s []T, v T) (int, bool)

func FindElemFunc

func FindElemFunc[T any](s []T, fn func(T) bool) (T, bool)

func FindFunc

func FindFunc[T any](s []T, fn func(T) bool) (int, bool)

func FindFuncLast

func FindFuncLast[T any](s []T, fn func(T) bool) (int, bool)

func FindLast

func FindLast[T comparable](s []T, v T) (int, bool)

func FlatMap

func FlatMap[T, R any](fn func(t T) []R, s []T) []R

func Flatten

func Flatten[T any](s [][]T) []T

func Get

func Get[T any](s []T, i int) T

func IndexMap

func IndexMap[T, R any](fn func(i int, t T) R, s []T) []R

func Interleave

func Interleave[T any](s []T, e T) []T

func Join

func Join[T any](ss ...[]T) []T

func KvsOf

func KvsOf[K, V any](o ...any) []bt.Kv[K, V]

func MakeAppend

func MakeAppend[T any](s []T, a ...T) []T

func MakePrepend

func MakePrepend[T any](s []T, a ...T) []T

func Map

func Map[T, R any](fn func(t T) R, s []T) []R

func Partition

func Partition[T any](fn func(t T) bool, s []T) (t []T, f []T)

func Pop

func Pop[T any](s *[]T) T

func PtrTo

func PtrTo[T any](s []T, i int) *T

func PtrUnpack1

func PtrUnpack1[T any](s []T) *T

func PtrUnpack2

func PtrUnpack2[T any](s []T) (*T, *T)

func PtrUnpack3

func PtrUnpack3[T any](s []T) (*T, *T, *T)

func PtrUnpack4

func PtrUnpack4[T any](s []T) (*T, *T, *T, *T)

func Reduce

func Reduce[T any](fn func(l, r T) T, d T, s []T) T

func Repeat

func Repeat[T any](s []T, n int) []T

func Reshape

func Reshape[T any](s []T, start, stop, step int) []T

func Reverse

func Reverse[T any](s []T) []T

func Reversed

func Reversed[T any](s []T) []T

func Set

func Set[T any](s []T, i int, t T)

func ShiftAs

func ShiftAs[E any](s *[]any) (E, bool)

func Sort

func Sort[T constraints.Ordered](s []T) []T

func Sorted

func Sorted[T constraints.Ordered](s []T) []T

func TryShiftAs

func TryShiftAs[E any](s *[]any) E

func Unpack1

func Unpack1[T any](s []T) T

func Unpack2

func Unpack2[T any](s []T) (T, T)

func Unpack3

func Unpack3[T any](s []T) (T, T, T)

func Unpack4

func Unpack4[T any](s []T) (T, T, T, T)

func ZipMap2

func ZipMap2[T, U, R any](fn func(t T, u U) R, ts []T, us []U) []R

func ZipMap3

func ZipMap3[T, U, V, R any](fn func(t T, u U, v V) R, ts []T, us []U, vs []V) []R

Types

type PqInitItem

type PqInitItem[T any] struct {
	Value    T
	Priority float32
}

type PqItem

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

func (PqItem[T]) Priority

func (i PqItem[T]) Priority() float32

type PriorityQueue

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

func (*PriorityQueue[T]) At

func (pq *PriorityQueue[T]) At(index int) *PqItem[T]

func (*PriorityQueue[T]) Init

func (pq *PriorityQueue[T]) Init(items []PqInitItem[T])

func (*PriorityQueue[T]) Len

func (pq *PriorityQueue[T]) Len() int

func (*PriorityQueue[T]) Pop

func (pq *PriorityQueue[T]) Pop() PqItem[T]

func (*PriorityQueue[T]) Push

func (pq *PriorityQueue[T]) Push(value T, priority float32)

func (*PriorityQueue[T]) UpdatePriority

func (pq *PriorityQueue[T]) UpdatePriority(item *PqItem[T], priority float32)

type PtrPriorityQueue

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

func (*PtrPriorityQueue[T]) At

func (pq *PtrPriorityQueue[T]) At(index int) *PqItem[T]

func (*PtrPriorityQueue[T]) Init

func (pq *PtrPriorityQueue[T]) Init(items []PqInitItem[T])

func (*PtrPriorityQueue[T]) Len

func (pq *PtrPriorityQueue[T]) Len() int

func (*PtrPriorityQueue[T]) Pop

func (pq *PtrPriorityQueue[T]) Pop() PqItem[T]

func (*PtrPriorityQueue[T]) Push

func (pq *PtrPriorityQueue[T]) Push(value T, priority float32)

func (*PtrPriorityQueue[T]) UpdatePriority

func (pq *PtrPriorityQueue[T]) UpdatePriority(item *PqItem[T], priority float32)

type SliceLengthError

type SliceLengthError struct {
	Actual, Expected int
}

func (SliceLengthError) Error

func (e SliceLengthError) Error() string

type Stack

type Stack[T any] []T

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() T

func (*Stack[T]) Push

func (s *Stack[T]) Push(t T)

func (*Stack[T]) Top

func (s *Stack[T]) Top() *T

Jump to

Keyboard shortcuts

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