Documentation ¶
Index ¶
- type Deque
- func (s *Deque) Append(item interface{}) bool
- func (s *Deque) Capacity() int
- func (s *Deque) Empty() bool
- func (s *Deque) First() interface{}
- func (s *Deque) Full() bool
- func (s *Deque) Last() interface{}
- func (s *Deque) Pop() interface{}
- func (s *Deque) Prepend(item interface{}) bool
- func (s *Deque) Shift() interface{}
- func (s *Deque) Size() int
- type Queue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deque ¶
Deque is a head-tail linked list data structure implementation. It is based on a doubly linked list container, so that every operations time complexity is O(1).
every operations over an instiated Deque are synchronized and safe for concurrent usage.
func NewCappedDeque ¶
NewCappedDeque creates a Deque with the specified capacity limit.
func (*Deque) Append ¶
Append inserts element at the back of the Deque in a O(1) time complexity, returning true if successful or false if the deque is at capacity.
func (*Deque) First ¶
func (s *Deque) First() interface{}
First returns the first value stored in the deque in a O(1) time complexity
func (*Deque) Last ¶
func (s *Deque) Last() interface{}
Last returns the last value stored in the deque in a O(1) time complexity
func (*Deque) Pop ¶
func (s *Deque) Pop() interface{}
Pop removes the last element of the deque in a O(1) time complexity
func (*Deque) Prepend ¶
Prepend inserts element at the Deques front in a O(1) time complexity, returning true if successful or false if the deque is at capacity.
type Queue ¶
type Queue struct {
*Deque
}
Queue is a FIFO (First in first out) data structure implementation. It is based on a deque container and focuses its API on core functionalities: Enqueue, Dequeue, Head, Size, Empty. Every operations time complexity is O(1).
As it is implemented using a Deque container, every operations over an instiated Queue are synchronized and safe for concurrent usage.
func NewCappedQueue ¶
func (*Queue) Dequeue ¶
func (q *Queue) Dequeue() interface{}
Dequeue removes and returns the front queue item