Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SliceQueue ¶
type SliceQueue[T any] struct { // C is a signal for non-empty queue. // A consumer can select for C and then Pop // as many elements as possible in a for-select // loop. // Refer to an example in TestSliceQueueConcurrentWriteAndRead. C chan struct{} // contains filtered or unexported fields }
SliceQueue is a FIFO queue implemented by a Go slice.
func NewSliceQueue ¶
func NewSliceQueue[T any]() *SliceQueue[T]
NewSliceQueue creates a new SliceQueue.
func (*SliceQueue[T]) Peek ¶
func (q *SliceQueue[T]) Peek() (retVal T, ok bool)
Peek returns the first element of the queue if exits.
func (*SliceQueue[T]) Pop ¶
func (q *SliceQueue[T]) Pop() (T, bool)
Pop removes the first element from queue and returns it, if it exists
func (*SliceQueue[T]) Push ¶
func (q *SliceQueue[T]) Push(elem T)
Push pushes element to the end of the queue
func (*SliceQueue[T]) Size ¶
func (q *SliceQueue[T]) Size() int
Size returns the element count in the queue
Click to show internal directories.
Click to hide internal directories.