container

package
v0.0.0-...-406fbc5 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2015 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PQueue

type PQueue []entry

PQueue implements a heap-based priority queue

func (*PQueue) Len

func (h *PQueue) Len() int

Len returns the number of elements in the queue

func (*PQueue) Pop

func (h *PQueue) Pop() interface{}

Pop returns the first element in the queue. Make sure to check the queue size to ensure it has at least one item.

func (*PQueue) Push

func (h *PQueue) Push(item interface{}, priority int)

Push inserts an element in the queue with the given priority

type Queue

type Queue struct {
	*list.List
}

Queue implements a FIFO data structure, holding arbitrary data types

func NewQueue

func NewQueue() *Queue

NewQueue creates an empty queue

func (*Queue) Len

func (q *Queue) Len() int

Len returns the queue size

func (*Queue) Peek

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

Pop returns the front item in the queue, or nil if the queue is empty.

func (*Queue) Pop

func (q *Queue) Pop() interface{}

Pop returns the front item in the queue, or nil if the queue is empty. Unlike Peek(), the item is removed from the queue

func (*Queue) Push

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

Push inserts a new item in the queue

type Stack

type Stack struct {
	*list.List
}

Stack implements a LIFO data structure, holding arbitrary data types

func NewStack

func NewStack() *Stack

NewStack creates an empty stack

func (*Stack) Len

func (stack *Stack) Len() int

Len returns the stack size

func (*Stack) Peek

func (stack *Stack) Peek() interface{}

Pop returns the front item in the stack, or nil if the stack is empty.

func (*Stack) Pop

func (stack *Stack) Pop() interface{}

Pop returns the front item in the stack, or nil if the stack is empty. Unlike Peek(), the item is removed from the stack

func (*Stack) Push

func (stack *Stack) Push(item interface{})

Push inserts a new item in the stack

Jump to

Keyboard shortcuts

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