Class LinkedQueue

A doubly-linked Queue of items.

Implements a Queue as a LinkedList, providing the same performance characteristics as the LinkedList.

LinkedQueue implements all optional Queue and Collection methods.

Implements: Queue, Collection, Enumerable

Functions

LinkedQueue.new(collection) Creates a new LinkedQueue.

Methods

LinkedQueue:Add(item) Adds an item to the LinkedQueue.
LinkedQueue:AddAll(items) Adds all provided items to the LinkedQueue.
LinkedQueue:Clear() Removes everything from the LinkedQueue.
LinkedQueue:Contains(item) Determines whether the LinkedQueue contains an item.
LinkedQueue:ContainsAll(items) Determines whether the LinkedQueue contains all of the provided items.
LinkedQueue:ContainsAny(items) Determines whether the LinkedQueue contains any of the provided items.
LinkedQueue:Count() Gets the number of items in the LinkedQueue.
LinkedQueue:Empty() Determines whether the LinkedQueue contains no elements.
LinkedQueue:Enumerator() Creates an enumerator for the LinkedQueue.
LinkedQueue:First() Gets the item at the beginning of the LinkedQueue.
LinkedQueue:Push(item) Adds an item to the end of the LinkedQueue.
LinkedQueue:Remove(item) Removes the specified item from the LinkedQueue.
LinkedQueue:RemoveAll(items) Removes all provided items from the LinkedQueue.
LinkedQueue:RetainAll(items) Removes all items except those provided from the LinkedQueue.
LinkedQueue:Shift() Gets an item from the beginning and removes that item from the LinkedQueue.
LinkedQueue:ToArray() Creates a new array indexed table of this LinkedQueue.
LinkedQueue:ToTable() Creates a new table of this LinkedQueue.


Functions

Methods
LinkedQueue.new(collection)
Creates a new LinkedQueue. Creates a LinkedQueue copy of the provided Collection or array-indexed table if one is provided, otherwise creates an empty LinkedQueue.

Parameters:

Returns:

    the new LinkedQueue

Methods

LinkedQueue:Add(item)
Adds an item to the LinkedQueue.

Inherited from:

Parameters:

  • item the item to add

Returns:

    true always since the LinkedQueue is always changed
LinkedQueue:AddAll(items)
Adds all provided items to the LinkedQueue. Adds items provided in another Collection in an arbitrary, deterministic order. The order is the same as the order of enumeration.

Inherited from:

Parameters:

  • items the Collection of items to add to this LinkedQueue

Returns:

    true always, since the LinkedQueue is always changed
LinkedQueue:Clear()
Removes everything from the LinkedQueue.

Inherited from:

LinkedQueue:Contains(item)
Determines whether the LinkedQueue contains an item.

Inherited from:

Parameters:

  • item the item to locate in the LinkedQueue

Returns:

    true if the item is in the LinkedQueue, false otherwise
LinkedQueue:ContainsAll(items)
Determines whether the LinkedQueue contains all of the provided items. Checks for items provided in another Collection in an arbitrary, deterministic order. The order is the same as the order of enumeration.

Inherited from:

Parameters:

  • items the Collection of items to locate in this LinkedQueue

Returns:

    true if all items are in the LinkedQueue, false otherwise
LinkedQueue:ContainsAny(items)
Determines whether the LinkedQueue contains any of the provided items. Checks for items provided in another Collection in an arbitrary, deterministic order. The order is the same as the order of enumeration.

Inherited from:

Parameters:

  • items the Collection of items to locate in this LinkedQueue

Returns:

    true if any items are in the LinkedQueue, false otherwise
LinkedQueue:Count()
Gets the number of items in the LinkedQueue.

Inherited from:

Returns:

    the number of items
LinkedQueue:Empty()
Determines whether the LinkedQueue contains no elements.

Inherited from:

Returns:

    true if the LinkedQueue empty, false otherwise
LinkedQueue:Enumerator()
Creates an enumerator for the LinkedQueue. The enumerator can be used directly in a generic for loop similar to pairs or ipairs.

Inherited from:

Returns:

    the enumerator generator
LinkedQueue:First()
Gets the item at the beginning of the LinkedQueue.

Inherited from:

Returns:

    the first item in the LinkedQueue

Raises:

if the LinkedQueue is empty
LinkedQueue:Push(item)
Adds an item to the end of the LinkedQueue.

Inherited from:

Parameters:

  • item the item to add

Returns:

    true always since the LinkedQueue is always changed
LinkedQueue:Remove(item)
Removes the specified item from the LinkedQueue. Removes only a single item. If there are multiple of the same item, it removes only the first encountered.

When an item is removed any others are shifted to fill the gap left at the index of removal.

Inherited from:

Parameters:

  • item the item to remove from the LinkedQueue

Returns:

    true if the LinkedQueue changed as a result, false otherwise
LinkedQueue:RemoveAll(items)
Removes all provided items from the LinkedQueue. Removes each instance of a provided item only once for each time provided. If there are multiple of the same item in this LinkedQueue, it removes only the first encountered for each provided.

Inherited from:

Parameters:

  • items the Collection of items to remove from this LinkedQueue

Returns:

    true if the LinkedQueue changed as a result, false otherwise
LinkedQueue:RetainAll(items)
Removes all items except those provided from the LinkedQueue. Retains only the items contained in the specified Collection. If there are duplicates they are all kept.

Inherited from:

Parameters:

  • items the Collection of items to retain in this LinkedQueue

Returns:

    true if the LinkedQueue changed as a result, false otherwise
LinkedQueue:Shift()
Gets an item from the beginning and removes that item from the LinkedQueue. Shifts other elements to fill the gap left.

Inherited from:

Returns:

    the item in the LinkedQueue

Raises:

if the LinkedQueue is empty
LinkedQueue:ToArray()
Creates a new array indexed table of this LinkedQueue. The order of the array is the same as the order of the LinkedQueue. The first element of the LinkedQueue will get index 1 and so on.

Inherited from:

Returns:

    the array indexed table

See also:

LinkedQueue:ToTable()
Creates a new table of this LinkedQueue. LinkedQueues, being ordered and linear, need no indices that are not array indices, so this provides a table with all the same array indices as ToArray.

Inherited from:

Returns:

    the table

See also:

generated by LDoc 1.4.6 Last updated 2022-03-30 00:04:00