queue

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

type Queue struct {
	EnqueueCallback func(interface{})
	DequeueCallback func()
	// contains filtered or unexported fields
}

Queue is a wrapper around container/list. Queue is atomic

func NewQueue

func NewQueue() *Queue

NewQueue returns a new Queue

func (*Queue) Dequeue

func (c *Queue) Dequeue()

Dequeue atomically removes the back element of l. If the queue is empty, Dequeue waits for a new element to be enqueued and then removes it

func (*Queue) Empty

func (c *Queue) Empty() bool

Empty atomically returns whether there's no elements in c

func (*Queue) Enqueue

func (c *Queue) Enqueue(v interface{})

Enqueue atomically inserts a new element e with value v to the back of queue c

func (*Queue) Front

func (c *Queue) Front() interface{}

Front atomically fetch the front element of c

func (*Queue) GetElements

func (c *Queue) GetElements() (elements []interface{})

GetElements atomically returns all the elements of c in a slice

func (*Queue) Pop

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

Pop atomically removes the back element of l and returns it. If the queue is empty, Pop waits for a new element to be enqueued, removes it and returns the value

func (*Queue) Remove

func (c *Queue) Remove(Predicate func(v interface{}) bool) interface{}

Remove atomically removes and returns the first element that Predicate(element.Value) returns true

func (*Queue) Size

func (c *Queue) Size() int

Size atomically returns the number of elements in c

Jump to

Keyboard shortcuts

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