Documentation
¶
Index ¶
- Constants
- type ArrayDeque
- func (d *ArrayDeque[T]) Add(t T)
- func (d *ArrayDeque[T]) AddBack(t T)
- func (d *ArrayDeque[T]) AddFront(t T)
- func (d *ArrayDeque[T]) All() iter.Seq[T]
- func (d *ArrayDeque[T]) Backward() iter.Seq[T]
- func (d *ArrayDeque[T]) Clear()
- func (d *ArrayDeque[T]) Empty() bool
- func (d *ArrayDeque[T]) Peek() T
- func (d *ArrayDeque[T]) PeekBack() T
- func (d *ArrayDeque[T]) PeekFront() T
- func (d *ArrayDeque[T]) Pop() T
- func (d *ArrayDeque[T]) Push(t T)
- func (d *ArrayDeque[T]) Remove() T
- func (d *ArrayDeque[T]) RemoveBack() T
- func (d *ArrayDeque[T]) RemoveFront() T
- func (d *ArrayDeque[T]) Size() int
- func (d *ArrayDeque[T]) String() string
- type Config
- type Option
Constants ¶
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]) 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]) 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]) 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.