arraydeque

package
v0.0.0-...-955cc57 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultCapacity is the capacity assigned if no other is provided.
	DefaultCapacity = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayDeque

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

ArrayDeque represents a deque of elements of type T backed by an array. The zero value for ArrayDeque is an empty deque ready to use.

func New

func New[T any](opts ...Option) *ArrayDeque[T]

New creates an empty ArrayDeque whose initial size is 0.

func (*ArrayDeque[T]) Add

func (d *ArrayDeque[T]) Add(t T)

Add is an alias for AddBack

func (*ArrayDeque[T]) AddBack

func (d *ArrayDeque[T]) AddBack(t T)

AddBack adds the given element to the back of this deque.

func (*ArrayDeque[T]) AddFront

func (d *ArrayDeque[T]) AddFront(t T)

AddFront adds the given element to the front of this deque.

func (*ArrayDeque[T]) All

func (d *ArrayDeque[T]) All() iter.Seq[T]

All returns an iterator over all elements, going from front to back in this deque.

func (*ArrayDeque[T]) Backward

func (d *ArrayDeque[T]) Backward() iter.Seq[T]

Backward returns an iterator over all elements, going from back to front in this deque.

func (*ArrayDeque[T]) Clear

func (d *ArrayDeque[T]) Clear()

Clear removes all elements from this deque and releases any memory in use by this deque for garbage collection.

func (*ArrayDeque[T]) Empty

func (d *ArrayDeque[T]) Empty() bool

Empty returns true if this deque contains no elements. Otherwise, returns false.

func (*ArrayDeque[T]) Peek

func (d *ArrayDeque[T]) Peek() T

Peek is an alias for PeekFront

func (*ArrayDeque[T]) PeekBack

func (d *ArrayDeque[T]) PeekBack() T

PeekBack returns the element at the back of this deque. If this deque is empty, PeekBack panics.

func (*ArrayDeque[T]) PeekFront

func (d *ArrayDeque[T]) PeekFront() T

PeekFront returns the element at the front of this deque. If this deque is empty, PeekFront panics.

func (*ArrayDeque[T]) Pop

func (d *ArrayDeque[T]) Pop() T

Pop is an alias for RemoveFront

func (*ArrayDeque[T]) Push

func (d *ArrayDeque[T]) Push(t T)

Push is an alias for AddFront

func (*ArrayDeque[T]) Remove

func (d *ArrayDeque[T]) Remove() T

Remove is an alias for RemoveFront

func (*ArrayDeque[T]) RemoveBack

func (d *ArrayDeque[T]) RemoveBack() T

RemoveBack removes the given element at the back of this deque and returns it. If this deque is empty, RemoveBack panics.

func (*ArrayDeque[T]) RemoveFront

func (d *ArrayDeque[T]) RemoveFront() T

RemoveFront removes the given element at the front of this deque and returns it. If this deque is empty, RemoveFront panics.

func (*ArrayDeque[T]) Size

func (d *ArrayDeque[T]) Size() int

Size returns the number of elements in this deque.

func (*ArrayDeque[T]) String

func (d *ArrayDeque[T]) String() string

String returns a string representation of this deque.

type Config

type Config struct {
	Capacity int
}

Config holds the values for configuring a ArrayDeque.

type Option

type Option func(*Config)

Option configures a ArrayDeque config

Jump to

Keyboard shortcuts

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