specialized

package
v0.0.0-...-00e7cc2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRequeueingQueue

func NewRequeueingQueue() collection.Stack

NewRequeueingQueue for a queue that never loses elements, they are just added back onto the end of the queue on pop. Useful for when you don't want to keep track of an array and an index on an object.

func NewStringRequeuingQueue

func NewStringRequeuingQueue() collection.StringStack

NewStringRequeuingQueue that is empty and ready to use.

Types

type HashPriority

type HashPriority interface {
	Priority
	GetHash() interface{}
}

HashPriority exposes both a priority function and Hash function.

type HashPriorityQueue

type HashPriorityQueue interface {
	// Size of this queue
	Size() int
	// Push the passed element onto this queue if it does not already exist in
	// the queue.
	Push(element HashPriority)
	// Pop the highest priority element off the queue
	Pop() (HashPriority, bool)
	// Peek at the highest priority element without modifying the queue
	Peek() (HashPriority, bool)
}

HashPriorityQueue prevents duplicate prioritized entries in a queue.

func NewHashPriorityQueue

func NewHashPriorityQueue() HashPriorityQueue

NewHashPriorityQueue for queueing unique elements by priority.

type Priority

type Priority interface {
	// GetPriority of this element as an int where lower priority < higher priority
	GetPriority() int
}

Priority is for use in collections that require elements to resolve their own priority.

type PriorityQueue

type PriorityQueue interface {
	// Size of this queue
	Size() int
	// Push the passed element onto this queue
	Push(element Priority)
	// Pop the highest priority element off the queue
	Pop() (Priority, bool)
	// Peek at the highest priority element without modifying the queue
	Peek() (Priority, bool)
}

PriorityQueue for queueing elements that implement priority and returning elements in the order of highest to lowest priority.

func NewPriorityQueue

func NewPriorityQueue() PriorityQueue

NewPriorityQueue for queueing elements according to their priority

type RateHashPriorityQueue

type RateHashPriorityQueue interface {
	HashPriorityQueue
	// NoLimitPop the highest priority element off the queue ignoring the rate limit
	// for the purpose of batching commands
	NoLimitPop() (HashPriority, bool)
	// Channel that can be used instead of Pop
	Channel() <-chan HashPriority
	// Stop this RateHashPriorityQueue so that it can be garbage collected.
	Stop()
}

RateHashPriorityQueue allows prioritized unique elements to be emitted at a specific rate.

func NewRateHashPriorityQueue

func NewRateHashPriorityQueue(n int, rate time.Duration) RateHashPriorityQueue

NewRateHashPriorityQueue that will return at max 'n' elements per 'rate' duration.

Jump to

Keyboard shortcuts

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