figo

package module
v0.0.0-...-dfeff85 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2014 License: MIT Imports: 2 Imported by: 1

README

figo - A FIFO queue for Go

figo is a FIFO for Go (Thanks @Corey_Latislaw for the name!). It is possible to iterate through the queue, if necessary.

There is additionally a thread safe version. Since it adds a bit of overhead, only use it if you need it.

figo has an MIT license and can be viewed in the LICENSE file.

Example Usage

import "github.com/jasocox/figo"

q := figo.New()
q.Push(1)
q.Push(2)

for elem := q.Front(); elem != nil; elem = q.Next(elem) {
	fmt.Printf("%d ", elem.Value)
}

q.Pop()
q.Pop()

To make a thread safe version:

q := figo.NewAsync()

Documentation

Can be found here: godocs

Documentation

Overview

Package queue is a FIFO queue using the circularly linked list package in Go's standard library. There is also a thread safe version.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncQueue

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

A thread safe version of Queue.

func NewAsync

func NewAsync() AsyncQueue

Returns an initialized SyncQueue

func (AsyncQueue) Front

func (q AsyncQueue) Front() *list.Element

Same as Front for Queue, except it is thread safe.

func (AsyncQueue) IsEmpty

func (q AsyncQueue) IsEmpty() bool

Same as IsEmpty for Queue, except it is thread safe.

func (AsyncQueue) Len

func (q AsyncQueue) Len() int

Same as Len for Queue, except it is thread safe.

func (AsyncQueue) Next

func (q AsyncQueue) Next(e *list.Element) *list.Element

Same as Next for Queue, except it is thread safe.

func (AsyncQueue) Pop

func (q AsyncQueue) Pop() interface{}

Same as Pop for Queue, except it is thread safe.

func (AsyncQueue) Push

func (q AsyncQueue) Push(o interface{})

Same as Push for Queue, except it is thread safe.

type Queue

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

Queue represents the FIFO queue.

func New

func New() Queue

Returns an initialized Queue.

func (Queue) Front

func (q Queue) Front() *list.Element

Returns the item at the front of the Queue or nil. The item is a *list.Element from the 'container/list' package.

func (Queue) IsEmpty

func (q Queue) IsEmpty() bool

Checks to see if the Queue is empty.

func (Queue) Len

func (q Queue) Len() int

Returns the current length of the Queue.

func (Queue) Next

func (q Queue) Next(e *list.Element) *list.Element

Returns the item after e or nil it is the last item or nil. The item is a *list.Element from the 'container/list' package. Even though it is possible to call e.Next() directly, don't. This behavior may not be supported moving forward.

func (Queue) Pop

func (q Queue) Pop() interface{}

Removes an item from the front of the Queue and returns it's value or nil.

func (Queue) Push

func (q Queue) Push(o interface{})

Pushes a new item to the back of the Queue.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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