queue

package
v0.0.0-...-47ccaec Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2016 License: Apache-2.0 Imports: 3 Imported by: 0

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, 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) 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

Push copies entry at the end of queue and moves tail pointer. Allocates more space if needed. Returns index for pushed data

Jump to

Keyboard shortcuts

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