schedule

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Schedule

type Schedule[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Schedule tracks unique values ordered by time. It is not thread-safe.

func New

func New[K comparable, V any](hash func(V) K) *Schedule[K, V]

New creates a new Schedule. The hash function is used to determine a comparable key for a value.

func (Schedule[K, V]) Len

func (s Schedule[K, V]) Len() int

Len returns the number of values in the schedule.

func (Schedule[K, V]) Peek

func (s Schedule[K, V]) Peek() (V, time.Time)

Peek returns the value with the earliest time from the schedule.

func (Schedule[K, V]) Pop

func (s Schedule[K, V]) Pop() V

Pop removes the value with the earliest time from the schedule and returns it. It will panic if the schedule is empty.

func (Schedule[K, V]) Remove

func (s Schedule[K, V]) Remove(v V)

Remove removes a value from the schedule.

func (Schedule[K, V]) Set

func (s Schedule[K, V]) Set(v V, t time.Time)

Set adds or updates the time of a value.

Jump to

Keyboard shortcuts

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