Help us shape the future of Go! Take the 2026 Go Developer Survey

queue

package
v1.20.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PriorityQueue

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

PriorityQueue is a priority queue of observerpb.GetFlowsResponse. It implements heap.Interface. GetFlowsResponse objects are ordered based on their timestamp value; the older the timestamp, the higher the priority.

This implementation is loosely based on the priority queue example in "container/heap".

func NewPriorityQueue

func NewPriorityQueue(n int) *PriorityQueue

NewPriorityQueue creates a new PriorityQueue with initial capacity n.

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

Len is the number of objects in the queue.

func (*PriorityQueue) Pop

Pop removes and returns the oldest object in the queue. Pop returns nil when the queue is empty.

func (*PriorityQueue) PopOlderThan

func (pq *PriorityQueue) PopOlderThan(t time.Time) []*observerpb.GetFlowsResponse

PopOlderThan removes and returns objects in the queue that are older than t. Objects in the returned list are sorted chronologically from the oldest to the more recent.

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(resp *observerpb.GetFlowsResponse)

Push adds object resp to the queue.

Jump to

Keyboard shortcuts

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