evtq

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: CC0-1.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventQueue

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

EventQueue represents the queue

func New

func New() *EventQueue

New initializes an empty priority queue.

func (*EventQueue) Insert

func (p *EventQueue) Insert(v any, priority 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

func (*EventQueue) Pop

func (p *EventQueue) Pop() (any, vrtime.Time, int, error)

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

func (*EventQueue) Remove

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

remove an element

func (*EventQueue) UpdatePriority

func (p *EventQueue) UpdatePriority(evt_id int, newPriority vrtime.Time)

UpdatePriority 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