queue2

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 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 Queue

type Queue struct {
	// contains filtered or unexported fields
}

Queue represents a single instance of the queue data structure.

func New

func New() *Queue

New constructs and returns a new Queue.

func (*Queue) Add

func (q *Queue) Add(elem interface{})

Add puts an element on the end of the queue.

func (*Queue) Get

func (q *Queue) Get(i int) interface{}

Get returns the element at index i in the queue. If the index is invalid, the call will panic. This method accepts both positive and negative index values. Index 0 refers to the first element, and index -1 refers to the last.

func (*Queue) Length

func (q *Queue) Length() int

Length returns the number of elements currently stored in the queue.

func (*Queue) Peek

func (q *Queue) Peek() interface{}

Peek returns the element at the head of the queue. This call panics if the queue is empty.

func (*Queue) Remove

func (q *Queue) Remove() interface{}

Remove removes and returns the element from the front of the queue. If the queue is empty, the call will panic.

type SyncQueue

type SyncQueue struct {
	// contains filtered or unexported fields
}

SyncQueue Synchronous FIFO queue

func NewSyncQueue

func NewSyncQueue() *SyncQueue

NewSyncQueue Create a new SyncQueue

func (*SyncQueue) Close

func (q *SyncQueue) Close()

func (*SyncQueue) Len

func (q *SyncQueue) Len() (l int)

Len Get the length of SyncQueue

func (*SyncQueue) Pop

func (q *SyncQueue) Pop() (v interface{})

Pop Pop an item from SyncQueue, will block if SyncQueue is empty

func (*SyncQueue) Push

func (q *SyncQueue) Push(v interface{})

Push Push an item to SyncQueue. Always returns immediately without blocking

func (*SyncQueue) TryPop

func (q *SyncQueue) TryPop() (v interface{}, ok bool)

TryPop Try to pop an item from SyncQueue, will return immediately with bool=false if SyncQueue is empty

Jump to

Keyboard shortcuts

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