containers

package
v0.0.0-...-ea35677 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

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

Jump to

Keyboard shortcuts

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