slice

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2022 License: Apache-2.0 Imports: 0 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Find added in v0.0.3

func Find[T any](sl []T, predicate func(v T) bool) (v T, found bool)

func FindLast added in v0.0.3

func FindLast[T any](sl []T, predicate func(v T) bool) (v T, found bool)

func Has added in v0.0.3

func Has[T comparable](sl []T, target T) bool

func Position added in v0.0.7

func Position[T any](sl []T, predicate func(v T) bool) int

func PositionLast added in v0.0.7

func PositionLast[T any](sl []T, predicate func(v T) bool) int

Types

type Deque

type Deque[T any] []T

Doubly ended queueu.

func (*Deque[T]) Len

func (d *Deque[T]) Len() int

Len returns length of underlying slice.

func (*Deque[T]) Pop

func (d *Deque[T]) Pop() (v T, popped bool)

Pop is an alias for PopBack.

func (*Deque[T]) PopBack

func (d *Deque[T]) PopBack() (v T, popped bool)

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

func (d *Deque[T]) PopFront() (v T, popped bool)

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]) Push

func (d *Deque[T]) Push(v T)

Push is an alias for PushBack.

func (*Deque[T]) PushBack

func (d *Deque[T]) PushBack(v T)

PushBack adds an element to tail of underlying slice.

func (*Deque[T]) PushFront

func (d *Deque[T]) PushFront(v T)

PushFront adds an element to head of underlying slice.

type Queue

type Queue[T any] []T

FIFO queue.

func (*Queue[T]) Len

func (q *Queue[T]) Len() int

Len returns length of underlying slice.

func (*Queue[T]) Pop

func (q *Queue[T]) Pop() (v T, popped bool)

Pop removes an element from head of underlying slice, and then returns removed value. If slice is empty, returns zero of T and false.

func (*Queue[T]) Push

func (q *Queue[T]) Push(v T)

Push adds an element to tail of underlying slice.

type Stack

type Stack[T any] []T

LIFO stack

func (*Stack[T]) Len

func (s *Stack[T]) Len() int

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() (v T, popped bool)

Pop removes an element from tail of underlying slice, and then returns removed value. If slice is empty, returns zero of T and false.

func (*Stack[T]) Push

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

Push adds an element to tail of underlying slice.

Jump to

Keyboard shortcuts

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