deque

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package deque provides a slice-backed double-ended queue.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deque

type Deque[Elem any] struct {
	// contains filtered or unexported fields
}

Deque is a slice-backed double-ended queue.

func (Deque[Elem]) Append

func (d Deque[Elem]) Append(ee ...Elem) Deque[Elem]

Append adds elements tot he end of the deque.

func (Deque[Elem]) DropEnd

func (d Deque[Elem]) DropEnd(n int) Deque[Elem]

DropEnd removes n elements from the end of the deque. If n is negative, there is no change. If n is larger than the deque's size, the result is empty.

func (Deque[Elem]) DropEndWhile

func (d Deque[Elem]) DropEndWhile(pred func(Elem) bool) Deque[Elem]

DropEndWhile removes elements from the end of the deque until the predicate returns false. The pointer passed to the predicate is a view into the deque's memory.

func (Deque[Elem]) GrowEnd

func (d Deque[Elem]) GrowEnd(n int) Deque[Elem]

GrowEnd ensures there is space to [Append] at least n elements.

func (Deque[Elem]) GrowFront

func (d Deque[Elem]) GrowFront(n int) Deque[Elem]

GrowFront ensures there is space to [Prepend] at least n elements.

func (Deque[Elem]) Len

func (d Deque[Elem]) Len() int

Len returns the number of elements in the deque.

func (Deque[Elem]) Prepend

func (d Deque[Elem]) Prepend(ee ...Elem) Deque[Elem]

Prepend adds elements to the front of the deque.

func (Deque[Elem]) Reset

func (d Deque[Elem]) Reset() Deque[Elem]

Reset removes all elements from the deque.

func (Deque[Elem]) Slice

func (d Deque[Elem]) Slice() []Elem

Slice returns a view into the deque's memory. Elements prepended to the deque appear at the beginning of the slice.

Jump to

Keyboard shortcuts

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