Documentation ¶
Overview ¶
Package deque implements a generic deque using a doubly-linked-list as the underlying data structure.
Index ¶
- type Deque
- func (d *Deque[T]) AddFirst(data T)
- func (d *Deque[T]) AddLast(data T)
- func (d *Deque[T]) First() (T, bool)
- func (d *Deque[T]) IsEmpty() bool
- func (d *Deque[T]) Last() (T, bool)
- func (d *Deque[T]) RemoveFirst() (T, bool)
- func (d *Deque[T]) RemoveLast() (T, bool)
- func (d *Deque[T]) Size() int
- func (d *Deque[T]) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deque ¶
type Deque[T any] struct { // contains filtered or unexported fields }
func (*Deque[T]) AddFirst ¶
func (d *Deque[T]) AddFirst(data T)
AddFirst adds an element to the front of the deque. time-complexity: O(1)
func (*Deque[T]) AddLast ¶
func (d *Deque[T]) AddLast(data T)
AddLast adds an element to the end of the deque. time-complexity: O(1)
func (*Deque[T]) First ¶
First returns the first element in the deque. It returns false if the deque is empty. time-complexity: O(1)
func (*Deque[T]) IsEmpty ¶
IsEmpty returns true if the deque doesn't have any elements. time-complexity: O(1)
func (*Deque[T]) Last ¶
Last returns the last element in the deque. It returns false if the deque is empty. time-complexity: O(1)
func (*Deque[T]) RemoveFirst ¶
RemoveFirst removes the first element from the deque and returns it. It returns false if the deque is empty. time-complexity: O(1)
func (*Deque[T]) RemoveLast ¶
RemoveLast removes the last element from the deque and returns it. It returns false if the deque is empty. time-complexity: O(1)