queue

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

README

queue

-- import "github.com/vedhavyas/queue"

Usage

type Queue
type Queue struct {}

Queue represents the FIFO list of items

func (*Queue) Dequeue
func (q *Queue) Dequeue() (interface{}, error)

Dequeue returns the first item from queue: O(1)

Returns an error if queue empty/out of bounds

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

Enqueue add the item to the queue: O(1)

func (*Queue) Get
func (q *Queue) Get(i int) (interface{}, error)

Get returns the item at the given index from the list: O(n)

Returns an error if queue empty/out of bounds

func (*Queue) Len
func (q *Queue) Len() int

Len returns the items count in the queue

func (*Queue) Peak
func (q *Queue) Peak() (interface{}, error)

Peak returns the next value in queue but does not remove from queue: O(1)

Returns error if queue empty

func (*Queue) PeakAt
func (q *Queue) PeakAt(i int) (interface{}, error)

PeakAt returns the item at the index i from the queue: O(n)

Returns error if queue empty/out of bounds

func (*Queue) String
func (q *Queue) String() string

String dumps the queue in human readable format: O(n)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

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

Queue represents the FIFO list of items

func (*Queue) CutRangeItem added in v1.1.0

func (q *Queue) CutRangeItem()

CutRangeItem removes the current item in the range: O(1)

func (*Queue) Dequeue

func (q *Queue) Dequeue() (interface{}, error)

Dequeue returns the first item from queue: O(1). if queue is empty, returns an error

func (*Queue) Enqueue

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

Enqueue add the item to the queue: O(1)

func (*Queue) Get

func (q *Queue) Get(i int) (interface{}, error)

Get returns the item at the given index from the list: O(n) returns an error if queue empty/out of bounds

func (*Queue) Len

func (q *Queue) Len() int

Len returns the items count in the queue

func (*Queue) Next added in v1.1.0

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

Next will return the next item in queue Returns nil if the range reaches the end of the queue: O(n)

func (*Queue) Peak

func (q *Queue) Peak() (interface{}, error)

Peak returns the next value in queue but does not remove from queue: O(1) returns error if queue empty

func (*Queue) PeakAt

func (q *Queue) PeakAt(i int) (interface{}, error)

PeakAt returns the item at the index i from the queue: O(n) returns error if queue empty/out of bounds

func (*Queue) ResetRange added in v1.1.0

func (q *Queue) ResetRange()

ResetRange will set the seek to start: O(1)

func (*Queue) String

func (q *Queue) String() string

String dumps the queue in human readable format: O(n)

Jump to

Keyboard shortcuts

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