queue

package
v2.9.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2016 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package queue implements a generic queue using a ring buffer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// Len returns the number of elements available.
	Len() int
	// At returns the element at i.
	At(i int) interface{}
	// Set sets the element at i to x.
	// If x is nil, that element should be cleared.
	Set(i int, x interface{})
}

A type implementing Interface can be used to store elements in a Queue.

type Queue

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

A Queue wraps an Interface to provide queue operations.

func New

func New(q Interface, n int) *Queue

New creates a new queue that starts with n elements.

func (*Queue) Init

func (q *Queue) Init(r Interface, n int)

Init initializes a queue. The old queue is untouched.

func (*Queue) Len

func (q *Queue) Len() int

Len returns the length of the queue. This is different from the underlying interface's length.

func (*Queue) Peek

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

Peek returns the element at the front of the queue. If the queue is empty, Peek panics.

func (*Queue) Pop

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

Pop pops an element from the queue. If the queue is empty, Pop panics.

func (*Queue) Push

func (q *Queue) Push(x interface{}) bool

Push pushes an element on the queue. If the queue is full, Push returns false. If x is nil, Push panics.

Jump to

Keyboard shortcuts

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