Documentation
¶
Index ¶
- func Clone[T any](sl []T) []T
- func Eq[T comparable](left, right []T) bool
- func Find[T any](sl []T, predicate func(v T) bool) (v T, found bool)
- func FindLast[T any](sl []T, predicate func(v T) bool) (v T, found bool)
- func Get[T any](sl []T, index uint) (v T, ok bool)
- func Has[T comparable](sl []T, target T) bool
- func Insert[T any](sl []T, index uint, ele T) []T
- func Position[T any](sl []T, predicate func(v T) bool) int
- func PositionLast[T any](sl []T, predicate func(v T) bool) int
- func Prepend[T any](sl []T, elements ...T) []T
- func Remove[T any](sl []T, i uint) []T
- func RemoveUnordered[T any](sl []T, index uint) []T
- type Deque
- func (d *Deque[T]) Append(elements ...T)
- func (d *Deque[T]) Clone() Deque[T]
- func (d *Deque[T]) Get(index uint) (v T, ok bool)
- func (d *Deque[T]) Insert(index uint, ele T)
- func (d *Deque[T]) Len() int
- func (d *Deque[T]) Pop() (v T, popped bool)
- func (d *Deque[T]) PopBack() (v T, popped bool)
- func (d *Deque[T]) PopFront() (v T, popped bool)
- func (d *Deque[T]) Prepend(elements ...T)
- func (d *Deque[T]) Push(v T)
- func (d *Deque[T]) PushBack(v T)
- func (d *Deque[T]) PushFront(v T)
- func (d *Deque[T]) Remove(index uint) T
- type Queue
- type Stack
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Eq ¶
func Eq[T comparable](left, right []T) bool
func Has ¶
func Has[T comparable](sl []T, target T) bool
func PositionLast ¶
func RemoveUnordered ¶
Types ¶
type Deque ¶
type Deque[T any] []T
Doubly ended queue. This is intentionally a simple slice wrapper, so that it can be converted into a slice with no cost.
The complexity of pushing front is typically O(N) where N is length of slice. If this cost needs to be avoided, use deque implementations backed by list or ring buffer. (for example, github.com/gammazero/deque.)
func (*Deque[T]) PopBack ¶
PopBack removes an element from tail of underlying slice, and then returns removed value. If slice is empty, returns zero of T and false.
func (*Deque[T]) PopFront ¶
PopFront removes an element from head of underlying slice, and then returns removed value. If slice is empty, returns zero of T and false.
func (*Deque[T]) PushBack ¶
func (d *Deque[T]) PushBack(v T)
PushBack adds an element to tail of underlying slice.
type Queue ¶
type Queue[T any] []T
FIFO queue.