container

package
Version: v0.0.0-...-5cbc542 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2017 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

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 NewDeque

func NewDeque(cap int) *Deque

NewDeque returns a new Deque object.

func (*Deque) At

func (q *Deque) At(idx int) interface{}

At returns the element at index idx.

func (*Deque) Back

func (q *Deque) Back() interface{}

Back returns the Last element in the Deque.

func (*Deque) Begin

func (q *Deque) Begin() common.Iterator

Begin returns an Iterator pointing to the first element of the Deque.

func (*Deque) Clear

func (q *Deque) Clear()

Clear removes everything from the Deque.

func (*Deque) Empty

func (q *Deque) Empty() bool

Empty returns true if Deque is empty.

func (*Deque) End

func (q *Deque) End() common.Iterator

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) MaxSize

func (q *Deque) MaxSize() int

MaxSize returns the current capacity of Deque.

func (*Deque) PopBack

func (q *Deque) PopBack()

PopBack removes an element from the end of 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

func (q *Deque) Rbegin() common.Iterator

Rbegin returns an Iterator poiting to the last element of the Deque, which moves in reverse direction.

func (*Deque) Rend

func (q *Deque) Rend() common.Iterator

Rend returns the Iterator pointing to a theoretical elemtn before-the-start of Deque.

func (*Deque) Resize

func (q *Deque) Resize(newCap int)

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().

func (*Deque) Size

func (q *Deque) Size() int

Size returns the number of elements stored in Deque.

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 NewList

func NewList() (list *List)

NewList creates a new doubly linked list (List).

func (List) Back

func (list List) Back() interface{}

Back returns the last object in List. Complexity: O(1).

func (*List) Begin

func (list *List) Begin() common.Iterator

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) Empty

func (list List) Empty() bool

Empty returns true if List is empty. Complexity: O(1).

func (*List) End

func (list *List) End() common.Iterator

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

func (list *List) Rbegin() common.Iterator

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

func (list *List) Rend() common.Iterator

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

func (List) Size

func (list List) Size() int

Size returns the number of objects in List. Complexity: O(1).

func (*List) Swap

func (lhs *List) Swap(rhs *List) error

Swap swaps two Lists. Complexity: O(1).

type ListIterator

type ListIterator struct {
	// contains filtered or unexported fields
}

func (*ListIterator) Equals

func (lhs *ListIterator) Equals(r common.Iterator) bool

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{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL