queue

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2015 License: MIT, MIT Imports: 0 Imported by: 0

README

Queue

Build Status GoDoc Code of Conduct

A fast Golang queue using a ring-buffer, based on the version suggested by Dariusz Górecki. Using this instead of other, simpler, queue implementations (slice+append or linked list) provides substantial memory and time benefits, and fewer GC pauses.

The queue implemented here is as fast as it is in part because it is not thread-safe.

Follows semantic versioning using https://gopkg.in/ - import from gopkg.in/eapache/queue.v1 for guaranteed API stability.

Documentation

Overview

Package queue provides a fast, ring-buffer queue based on the version suggested by Dariusz Górecki. Using this instead of other, simpler, queue implementations (slice+append or linked list) provides substantial memory and time benefits, and fewer GC pauses.

The queue implemented here is as fast as it is for an additional reason: it is *not* thread-safe.

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 a single instance of the queue data structure.

func New

func New() *Queue

New constructs and returns a new Queue.

func (*Queue) Add

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

Add puts an element on the end of the queue.

func (*Queue) Get

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

Get returns the element at index i in the queue. If the index is invalid, the call will panic.

func (*Queue) Length

func (q *Queue) Length() int

Length returns the number of elements currently stored in the queue.

func (*Queue) Peek

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

Peek returns the element at the head of the queue. This call panics if the queue is empty.

func (*Queue) Remove

func (q *Queue) Remove()

Remove removes the element from the front of the queue. If you actually want the element, call Peek first. This call panics if the queue is empty.

Jump to

Keyboard shortcuts

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