Documentation ¶
Overview ¶
Package evtq creates and manages event queues
It depends upon container/heap to manage a heap structure
Index ¶
Constants ¶
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 (*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.