arrayqueue

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: BSD-2-Clause, ISC Imports: 5 Imported by: 0

Documentation

Overview

Package arrayqueue implements a queue backed by array list.

Structure is not thread safe.

Reference: https://en.wikipedia.org/wiki/Queue_(abstract_data_type)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator

type Iterator[T any] struct {
	// contains filtered or unexported fields
}

Iterator holding the iterator's state

func (*Iterator[T]) DistanceTo added in v0.13.0

func (it *Iterator[T]) DistanceTo(other ds.OrderedIterator) int

DistanceTo implements ds.ReadWriteOrdCompBidRandCollIterator If other is of type IndexedIterator, IndexedIterator.Index() will be used, possibly executing in O(1)

func (*Iterator[T]) Get added in v0.13.0

func (it *Iterator[T]) Get() (value T, found bool)

Get implements ds.ReadWriteOrdCompBidRandCollIterator

func (*Iterator[T]) GetAt added in v0.13.0

func (it *Iterator[T]) GetAt(i int) (value T, found bool)

GetAt implements ds.ReadWriteOrdCompBidRandCollIterator

func (*Iterator[T]) Index

func (it *Iterator[T]) Index() (int, bool)

Index implements ds.ReadWriteOrdCompBidRandCollIterator

func (*Iterator[T]) IsAfter added in v0.13.0

func (it *Iterator[T]) IsAfter(other ds.OrderedIterator) bool

IsAfter implements ds.ReadWriteOrdCompBidRandCollIterator

func (*Iterator[T]) IsBefore added in v0.13.0

func (it *Iterator[T]) IsBefore(other ds.OrderedIterator) bool

IsBefore implements ds.ReadWriteOrdCompBidRandCollIterator

func (*Iterator[T]) IsBegin added in v0.13.0

func (it *Iterator[T]) IsBegin() bool

IsBegin implements ds.ReadWriteOrdCompBidRandCollIterator

func (*Iterator[T]) IsEnd added in v0.13.0

func (it *Iterator[T]) IsEnd() bool

IsEnd implements ds.ReadWriteOrdCompBidRandCollIterator

func (*Iterator[T]) IsEqual added in v0.13.0

func (it *Iterator[T]) IsEqual(other ds.ComparableIterator) bool

IsEqual implements ds.ReadWriteOrdCompBidRandCollIterator

func (*Iterator[T]) IsFirst added in v0.13.0

func (it *Iterator[T]) IsFirst() bool

IsFirst implements ds.ReadWriteOrdCompBidRandCollIterator

func (*Iterator[T]) IsLast added in v0.13.0

func (it *Iterator[T]) IsLast() bool

IsLast implements ds.ReadWriteOrdCompBidRandCollIterator

func (*Iterator[T]) IsValid added in v0.13.0

func (it *Iterator[T]) IsValid() bool

IsValid implements ds.ReadWriteOrdCompBidRandCollIterator

func (*Iterator[T]) MoveBy added in v0.13.0

func (it *Iterator[T]) MoveBy(n int)

MoveBy implements ds.ReadWriteOrdCompBidRandCollIterator

func (*Iterator[T]) MoveTo added in v0.13.0

func (it *Iterator[T]) MoveTo(i int) bool

MoveTo implements ds.ReadWriteOrdCompBidRandCollIterator

func (*Iterator[T]) Next

func (it *Iterator[T]) Next()

Next implements ds.ReadWriteOrdCompBidRandCollIterator

func (*Iterator[T]) NextN added in v0.13.0

func (it *Iterator[T]) NextN(i int)

NextN implements ds.ReadWriteOrdCompBidRandCollIterator

func (*Iterator[T]) Previous added in v0.13.0

func (it *Iterator[T]) Previous()

Previous implements ds.ReadWriteOrdCompBidRandCollIterator

func (*Iterator[T]) PreviousN added in v0.13.0

func (it *Iterator[T]) PreviousN(n int)

PreviousN implements ds.ReadWriteOrdCompBidRandCollIterator

func (*Iterator[T]) Set added in v0.13.0

func (it *Iterator[T]) Set(value T) bool

Set implements ds.ReadWriteOrdCompBidRandCollIterator

func (*Iterator[T]) SetAt added in v0.13.0

func (it *Iterator[T]) SetAt(i int, value T) bool

SetAt implements ds.ReadWriteOrdCompBidRandCollIterator

func (*Iterator[T]) Size added in v0.13.0

func (it *Iterator[T]) Size() int

Size implements ds.ReadWriteOrdCompBidRandCollIterator

type Queue

type Queue[T any] struct {
	// contains filtered or unexported fields
}

Queue holds elements in an array-list

func New

func New[T any](items ...T) *Queue[T]

New instantiates a new empty queue

func NewFromIterator added in v0.13.0

func NewFromIterator[T any](it ds.ReadCompForIterator[T]) *Queue[T]

NewFromIterator instantiates a new queue containing the elements provided by the passed iterator.

func NewFromIterators added in v0.13.0

func NewFromIterators[T any](first ds.ReadCompForIterator[T], end ds.ComparableIterator) *Queue[T]

NewFromIterators instantiates a new queue containing the elements provided by first, until it is equal to end. end is a sentinel and not included.

func NewFromSlice added in v0.13.0

func NewFromSlice[T any](slice []T) *Queue[T]

func (*Queue[T]) Begin added in v0.13.0

func (queue *Queue[T]) Begin() ds.ReadWriteOrdCompBidRandCollIterator[int, T]

Begin returns an initialized iterator, which points to one element before it's first. Unless Next() is called, the iterator is in an invalid state.

func (*Queue[T]) Clear

func (queue *Queue[T]) Clear()

Clear removes all elements from the queue.

func (*Queue[T]) Dequeue

func (queue *Queue[T]) Dequeue() (value T, ok bool)

Dequeue removes first element of the queue and returns it, or nil if queue is empty. Second return parameter is true, unless the queue was empty and there was nothing to dequeue.

func (*Queue[T]) End added in v0.13.0

func (queue *Queue[T]) End() ds.ReadWriteOrdCompBidRandCollIterator[int, T]

End returns an initialized iterator, which points to one element afrer it's last. Unless Previous() is called, the iterator is in an invalid state.

func (*Queue[T]) Enqueue

func (queue *Queue[T]) Enqueue(value T)

Enqueue adds a value to the end of the queue

func (*Queue[T]) First added in v0.13.0

func (queue *Queue[T]) First() ds.ReadWriteOrdCompBidRandCollIterator[int, T]

First returns an initialized iterator, which points to it's first element.

func (*Queue[T]) FromJSON

func (queue *Queue[T]) FromJSON(data []byte) error

FromJSON populates the queue from the input JSON representation.

func (*Queue[T]) GetValues added in v0.3.0

func (queue *Queue[T]) GetValues() []T

Values returns all elements in the queue (FIFO order).

func (*Queue[T]) IsEmpty added in v0.3.0

func (queue *Queue[T]) IsEmpty() bool

Empty returns true if queue does not contain any elements.

func (*Queue[T]) Last added in v0.13.0

func (queue *Queue[T]) Last() ds.ReadWriteOrdCompBidRandCollIterator[int, T]

Last returns an initialized iterator, which points to it's last element.

func (*Queue[T]) MarshalJSON

func (queue *Queue[T]) MarshalJSON() ([]byte, error)

MarshalJSON @implements json.Marshaler

func (*Queue[T]) NewIterator added in v0.13.0

func (list *Queue[T]) NewIterator(list_ *Queue[T], index int) *Iterator[T]

NewIterator returns a stateful iterator whose values can be fetched by an index.

func (*Queue[T]) Peek

func (queue *Queue[T]) Peek() (value T, ok bool)

Peek returns first element of the queue without removing it, or nil if queue is empty. Second return parameter is true, unless the queue was empty and there was nothing to peek.

func (*Queue[T]) Size

func (queue *Queue[T]) Size() int

Size returns number of elements within the queue.

func (*Queue[T]) ToJSON

func (queue *Queue[T]) ToJSON() ([]byte, error)

ToJSON outputs the JSON representation of the queue.

func (*Queue[T]) ToString added in v0.3.0

func (queue *Queue[T]) ToString() string

String returns a string representation of container

func (*Queue[T]) UnmarshalJSON

func (queue *Queue[T]) UnmarshalJSON(bytes []byte) error

UnmarshalJSON @implements json.Unmarshaler

Jump to

Keyboard shortcuts

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