queue

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: Apache-2.0 Imports: 3 Imported by: 39

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BytesQueue

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

BytesQueue is a non-thread safe queue type of fifo based on bytes array. For every push operation index of entry is returned. It can be used to read the entry later

func NewBytesQueue

func NewBytesQueue(initialCapacity int, maxCapacity int, verbose bool) *BytesQueue

NewBytesQueue initialize new bytes queue. Initial capacity is used in bytes array allocation When verbose flag is set then information about memory allocation are printed

func (*BytesQueue) Capacity

func (q *BytesQueue) Capacity() int

Capacity returns number of allocated bytes for queue

func (*BytesQueue) CheckGet added in v1.2.1

func (q *BytesQueue) CheckGet(index int) error

CheckGet checks if an entry can be read from index

func (*BytesQueue) Get

func (q *BytesQueue) Get(index int) ([]byte, error)

Get reads entry from index

func (*BytesQueue) Len

func (q *BytesQueue) Len() int

Len returns number of entries kept in queue

func (*BytesQueue) Peek

func (q *BytesQueue) Peek() ([]byte, error)

Peek reads the oldest entry from list without moving head pointer

func (*BytesQueue) Pop

func (q *BytesQueue) Pop() ([]byte, error)

Pop reads the oldest entry from queue and moves head pointer to the next one

func (*BytesQueue) Push

func (q *BytesQueue) Push(data []byte) (int, error)

Push copies entry at the end of queue and moves tail pointer. Allocates more space if needed. Returns index for pushed data or error if maximum size queue limit is reached.

func (*BytesQueue) Reset

func (q *BytesQueue) Reset()

Reset removes all entries from queue

Jump to

Keyboard shortcuts

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