Documentation ¶
Index ¶
- type Deque
- func (q *Deque) At(idx int) interface{}
- func (q *Deque) Back() interface{}
- func (q *Deque) Begin() common.Iterator
- func (q *Deque) Clear()
- func (q *Deque) Empty() bool
- func (q *Deque) End() common.Iterator
- func (q *Deque) Front() interface{}
- func (q *Deque) MaxSize() int
- func (q *Deque) PopBack()
- func (q *Deque) PopFront()
- func (q *Deque) PushBack(v interface{})
- func (q *Deque) PushFront(v interface{})
- func (q *Deque) Rbegin() common.Iterator
- func (q *Deque) Rend() common.Iterator
- func (q *Deque) Resize(newCap int)
- func (q *Deque) ShrinkToFit()
- func (q *Deque) Size() int
- type DequeIterator
- type ForwardList
- func (list *ForwardList) Begin() common.Iterator
- func (list *ForwardList) Clear()
- func (list *ForwardList) Empty() bool
- func (list *ForwardList) End() common.Iterator
- func (list *ForwardList) Front() interface{}
- func (list *ForwardList) PopFront()
- func (list *ForwardList) PushFront(v interface{})
- func (list *ForwardList) Reverse()
- func (list *ForwardList) Size() int
- type ForwardListIterator
- type IteratorDirection
- type List
- func (list List) Back() interface{}
- func (list *List) Begin() common.Iterator
- func (list *List) Clear()
- func (list List) Empty() bool
- func (list *List) End() common.Iterator
- func (list List) Front() interface{}
- func (list *List) PopBack()
- func (list *List) PopFront()
- func (list *List) PushBack(v interface{})
- func (list *List) PushFront(v interface{})
- func (list *List) Rbegin() common.Iterator
- func (list *List) Rend() common.Iterator
- func (list *List) Reverse()
- func (list List) Size() int
- func (lhs *List) Swap(rhs *List) error
- type ListIterator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deque ¶
type Deque struct {
// contains filtered or unexported fields
}
Deque is a double ended queue. Deque supports push and pop from both ends.
func (*Deque) End ¶
End returns the Iterator pointing to a theoretical element past-the-end of Deque.
func (*Deque) Front ¶
func (q *Deque) Front() interface{}
Front returns the first elemnt in the Deque.
func (*Deque) PopFront ¶
func (q *Deque) PopFront()
PopFront removes an element from the start of the Deque.
func (*Deque) PushBack ¶
func (q *Deque) PushBack(v interface{})
PushBack adds v to the end of the Deque.
func (*Deque) PushFront ¶
func (q *Deque) PushFront(v interface{})
PushFront adds v to the start of the Deque.
func (*Deque) Rbegin ¶
Rbegin returns an Iterator poiting to the last element of the Deque, which moves in reverse direction.
func (*Deque) Rend ¶
Rend returns the Iterator pointing to a theoretical elemtn before-the-start of Deque.
func (*Deque) Resize ¶
Resize changes the capacity of Deque. MaxSize is affected after Resize. Size remains the same. If new Cap is less than the current MaxSize of then Deque is truncated to newCap.
func (*Deque) ShrinkToFit ¶
func (q *Deque) ShrinkToFit()
ShrinkToFit resizes the Deque to Deque.Size().
type DequeIterator ¶
type DequeIterator struct {
// contains filtered or unexported fields
}
Iterator for Deque.
func (*DequeIterator) Equals ¶
func (lhs *DequeIterator) Equals(r common.Iterator) bool
Equals returns true if both the Iterators are pointing to the same element.
func (*DequeIterator) Next ¶
func (itr *DequeIterator) Next() common.Iterator
Next returns an Iterator pointing to the next element in Deque.
func (*DequeIterator) Value ¶
func (itr *DequeIterator) Value() interface{}
Value returns the element pointed by Iterator.
type ForwardList ¶
type ForwardList struct {
// contains filtered or unexported fields
}
ForwardList type implements singly linked list. It allows constant time insert and erase operations anywhere within the list. As the names suggests, ForwardLists can be ieterated only in forward direction. ForwardLists do not provide direct access to the elements.
func NewForwardList ¶
func NewForwardList() *ForwardList
NewForwardList creates a new ForwardList and returns a pointer to the same.
func (*ForwardList) Begin ¶
func (list *ForwardList) Begin() common.Iterator
Begin returns an ForwardListIterator pointing to the first node of the ForwardList.
func (*ForwardList) Clear ¶
func (list *ForwardList) Clear()
Clear removes all the nodes from the ForwardList.
func (*ForwardList) Empty ¶
func (list *ForwardList) Empty() bool
Empty return true if the ForwardList is empty.
func (*ForwardList) End ¶
func (list *ForwardList) End() common.Iterator
End returns an ForwardListIterator pointing to the node past-the-end of the ForwardList.
func (*ForwardList) Front ¶
func (list *ForwardList) Front() interface{}
Front returns the values stores in the first node of the ForwardList if it is not empty.
func (*ForwardList) PopFront ¶
func (list *ForwardList) PopFront()
PopFront removed the first node from the ForwardList.
func (*ForwardList) PushFront ¶
func (list *ForwardList) PushFront(v interface{})
PushFront creates a new node containing value v and adds it to the start of the ForwardList.
func (*ForwardList) Reverse ¶
func (list *ForwardList) Reverse()
Reverse reverses the ForwardList in place.
func (*ForwardList) Size ¶
func (list *ForwardList) Size() int
Size returns the number of nodes in the ForwardList.
type ForwardListIterator ¶
type ForwardListIterator struct {
// contains filtered or unexported fields
}
Iterator for ForwardList.
func (*ForwardListIterator) Equals ¶
func (lhs *ForwardListIterator) Equals(r common.Iterator) bool
Equals returns true if both ForwardListIterators are pointing to the same node.
func (*ForwardListIterator) Next ¶
func (itr *ForwardListIterator) Next() common.Iterator
Next moves the ForwardListIterator to the next node.
func (*ForwardListIterator) Value ¶
func (itr *ForwardListIterator) Value() interface{}
Value returns the value stored in the node pointed by the ForwardListIterator.
type IteratorDirection ¶
type IteratorDirection uint8
const ( FORWARD IteratorDirection = iota + 1 BACKWARD BOTH NONE )
type List ¶
type List struct {
// contains filtered or unexported fields
}
List type implements doubly linked list. It can perform constant time insert and erase operations anywhere in the list. Lists can be iterated in both directions. Lists however cannot provide direct access to elements using index.
func (List) Back ¶
func (list List) Back() interface{}
Back returns the last object in List. Complexity: O(1).
func (*List) Begin ¶
Begin returns a ListIterator pointing to the first object of List. It is a bidirectional ListIterator. Complexity: O(1).
func (*List) Clear ¶
func (list *List) Clear()
Clear removes all the elements from List. Complexity: Linear in size of List
func (*List) End ¶
End returns a ListIterator pointing to a theoretical object after the end of the List. This function is used with Begin Complexity: O(1).
func (List) Front ¶
func (list List) Front() interface{}
Front returns the first object in List. Complexity: O(1).
func (*List) PopBack ¶
func (list *List) PopBack()
PopBack removes the last object from List. Complexity: O(1).
func (*List) PopFront ¶
func (list *List) PopFront()
PopFront removes the first object from List. Complexity: O(1).
func (*List) PushBack ¶
func (list *List) PushBack(v interface{})
PushBack adds an object at the end of List. Complexity: O(1)
func (*List) PushFront ¶
func (list *List) PushFront(v interface{})
PushFront adds an object at the start of List. Complexity: O(1).
func (*List) Rbegin ¶
Rbegin returns a ListIterator pointing to a theoretical object before the first object of the List. It is a bidirectional reverse ListIterator Complexity: O(1)
func (*List) Rend ¶
Rend returns a ListIterator pointing to before-the-first object of List. This function is used with Rbegin Complexity: O(1).
func (*List) Reverse ¶
func (list *List) Reverse()
Reverse reverses the List. Complexity: Linear in size of List
type ListIterator ¶
type ListIterator struct {
// contains filtered or unexported fields
}
func (*ListIterator) Next ¶
func (it *ListIterator) Next() common.Iterator
func (*ListIterator) String ¶
func (it *ListIterator) String() string
func (*ListIterator) Value ¶
func (it *ListIterator) Value() interface{}