Documentation
¶
Overview ¶
Package queue provides FIFO queues and LIFO stacks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fifo ¶
type Fifo[E any] struct { // contains filtered or unexported fields }
A Fifo is a first-in, first-out queue. Its zero value is ready to use.
Front, Shift, and Len take O(1) time, and Unshift takes amortized O(1) time. DeleteOne takes time proportional to the distance between the value it removes and the nearer end of the queue, so O(n) at worst.
func (*Fifo[E]) DeleteOne ¶ added in v0.13.0
DeleteOne removes a value for which f returns true, if there is one, and reports whether it did. It checks values in pairs, one from each end, working toward the middle. If f returns true for more than one value, which one DeleteOne removes is unspecified.
func (*Fifo[E]) Front ¶
Front returns the first value without removing it, or a zero value and false if the queue is empty.
type Lifo ¶
type Lifo[E any] struct { // contains filtered or unexported fields }
A Lifo is a last-in, first-out stack. Its zero value is ready to use.
Pop and Len take O(1) time, and Push takes amortized O(1) time.