evtq

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package evtq creates and manages event queues

It depends upon container/heap to manage a heap structure

Index

Constants

View Source
const InvalidEventID = 0

InvalidEventID will never be returned from EventQueue.Insert()

Variables

This section is empty.

Functions

This section is empty.

Types

type EventQueue

type EventQueue struct {
	MaxTime vrtime.Time // Largest vrtime.Time value pushed onto to the heap as yet
	// contains filtered or unexported fields
}

EventQueue represents the queue

func New

func New() *EventQueue

New is a constructor. Initializes an empty slice of events

func (*EventQueue) Insert

func (p *EventQueue) Insert(v any, time vrtime.Time) int

Insert inserts a new element into the queue. No action is performed on duplicate elements.

func (*EventQueue) Len

func (p *EventQueue) Len() int

Len returns the number of elements in the queue.

func (*EventQueue) MinTime

func (p *EventQueue) MinTime() vrtime.Time

MinTime returns the Time associated with the next event.

func (*EventQueue) Pop

func (p *EventQueue) Pop() any

Pop removes the element with the least time from the queue and returns it. In case of an empty queue, an error is returned.

func (*EventQueue) Remove

func (p *EventQueue) Remove(evtID int) bool

Remove an element. Returns true on success.

func (*EventQueue) UpdateTime

func (p *EventQueue) UpdateTime(evtID int, newTime vrtime.Time)

UpdateTime changes the priority of a given item. If the specified item is not present in the queue, no action is performed.

Jump to

Keyboard shortcuts

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