keyedqueue

package
v0.0.0-...-fe13f99 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2018 License: Apache-2.0 Imports: 2 Imported by: 5

Documentation

Overview

Package keyedqueue provides a queue with keyed elements allowing elements already on the queue to be easily replaced.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element interface {
	// Key returns the key of this element. Returned key must support
	// equality.
	Key() interface{}
}

Element represents a queue element.

type Queue

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

Queue represents a queue of elements. Queue instances are safe to use with multiple goroutines.

func New

func New() *Queue

New returns a brand new, empty queue.

func (*Queue) Add

func (q *Queue) Add(elementToAdd Element)

Add replaces the element in the queue with key matching elementToAdd with elementToAdd. elementToAdd gets the same position in the queue as the element it replaced. If no element with a matching key exists in the queue, Add places elementToAdd at the end of the queue.

func (*Queue) Len

func (q *Queue) Len() int

Len returns the length of this queue

func (*Queue) Remove

func (q *Queue) Remove() Element

Remove removes the element at the front of the queue. If queue is empty, Remove blocks.

Jump to

Keyboard shortcuts

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