Skip to contents

[Experimental]

Implements the queue abstract data type. The last element added to this queue is the last one to be returned from it.

Methods


Method push()

Adds another element to this queue.

Usage

Queue$push(new_elements)

Arguments

new_elements

the elements to be added to this queue

Returns

invisibly self


Method pop()

Returns the first added element to this queue and removes it from this queue.

Usage

Queue$pop()

Returns

the first added element to this queue or NULL if this queue is empty


Method empty()

Removes all elements from this queue.

Usage

Queue$empty()

Returns

invisibly self


Method size()

Returns the number of elements in this queue.

Usage

Queue$size()

Returns

the number of elements in this queue


Method get()

Returns an array of elements in this queue. The order of elements is chronological: the first elements in the returned array is the oldest element added to this queue.

Usage

Queue$get(reversed = FALSE)

Arguments

reversed

(logical)
if TRUE then returns the First-In-First-Out order; otherwise returns the Last-In-First-Out order. Default: FALSE

Returns

the array of elements in this queue


Method remove()

Removes the eldest occurrence of elements from this queue. Relies on implicit conversions of R types to compare a removed element with elements in this queue.

Usage

Queue$remove(elements)

Arguments

elements

the elements to remove from this queue

Returns

invisibly self


Method print()

Prints this queue.

Usage

Queue$print(...)

Arguments

...

the additional arguments to this method, ignored

Returns

invisibly self


Method clone()

The objects of this class are cloneable with this method.

Usage

Queue$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.