collections

package
v0.0.0-...-108421c Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2017 License: MIT Imports: 2 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataStructureEmptyError

type DataStructureEmptyError struct{}

func (DataStructureEmptyError) Error

func (s DataStructureEmptyError) Error() string

type LinkedList

type LinkedList struct {
	Head *Node
}

func SliceToLinkedList

func SliceToLinkedList(values []interface{}) *LinkedList

func (*LinkedList) AddNode

func (l *LinkedList) AddNode(val interface{}) *Node

func (*LinkedList) AddNodeToFront

func (l *LinkedList) AddNodeToFront(val interface{}) *Node

func (*LinkedList) AddNodesBySlice

func (l *LinkedList) AddNodesBySlice(values []interface{})

func (*LinkedList) DeleteNodeByRef

func (l *LinkedList) DeleteNodeByRef(n *Node)

Caveat: Node must be part of list. It should not be a rogue node otherwise things will be messy

func (*LinkedList) Equals

func (l *LinkedList) Equals(l1 *LinkedList) bool

func (*LinkedList) Last

func (l *LinkedList) Last() *Node

Returns last node of list l If head is nil then it returns nil.

func (*LinkedList) Length

func (l *LinkedList) Length() int

func (*LinkedList) String

func (l *LinkedList) String() string

type Node

type Node struct {
	Value interface{}
	Next  *Node
	Prev  *Node
}

type Queue

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

func (*Queue) Add

func (q *Queue) Add(item interface{})

func (*Queue) IsEmpty

func (q *Queue) IsEmpty() bool

func (*Queue) Length

func (q *Queue) Length() int

func (*Queue) Peek

func (q *Queue) Peek() (interface{}, *DataStructureEmptyError)

func (*Queue) Remove

func (q *Queue) Remove() (interface{}, *DataStructureEmptyError)

type Stack

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

func (*Stack) IsEmpty

func (s *Stack) IsEmpty() bool

func (*Stack) Length

func (s *Stack) Length() int

func (*Stack) Peek

func (s *Stack) Peek() (interface{}, *DataStructureEmptyError)

Returns the top element of stack. If stack is empty then returns error of type StackEmptyError

func (*Stack) Pop

func (s *Stack) Pop() (interface{}, *DataStructureEmptyError)

func (*Stack) Push

func (s *Stack) Push(val interface{})

Directories

Path Synopsis
Min heap implementation for integers.
Min heap implementation for integers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL