Class LinkedDeque
A doubly-linked, double-ended Deque of items.
Implements a Deque as a LinkedList, providing the same performance characteristics as the LinkedList.
LinkedDeque implements all optional Deque, Queue, and Collection methods.
Implements: Deque, Queue, Collection, Enumerable
Functions
| LinkedDeque.new(collection) | Creates a new LinkedDeque. |
Methods
| LinkedDeque:Add(item) | Adds an item to the LinkedDeque. |
| LinkedDeque:AddAll(items) | Adds all provided items to the LinkedDeque. |
| LinkedDeque:Clear() | Removes everything from the LinkedDeque. |
| LinkedDeque:Contains(item) | Determines whether the LinkedDeque contains an item. |
| LinkedDeque:ContainsAll(items) | Determines whether the LinkedDeque contains all of the provided items. |
| LinkedDeque:ContainsAny(items) | Determines whether the LinkedDeque contains any of the provided items. |
| LinkedDeque:Count() | Gets the number of items in the LinkedDeque. |
| LinkedDeque:Empty() | Determines whether the LinkedDeque has no elements. |
| LinkedDeque:Enumerator() | Creates an enumerator for the LinkedDeque. |
| LinkedDeque:First() | Gets the item at the beginning of the LinkedDeque. |
| LinkedDeque:Last() | Gets the item at the end of the LinkedDeque. |
| LinkedDeque:Pop() | Gets an item from the end and removes that item from the LinkedDeque. |
| LinkedDeque:Push(item) | Adds an item to the end of the LinkedDeque. |
| LinkedDeque:Remove(item) | Removes the specified item from the LinkedDeque. |
| LinkedDeque:RemoveAll(items) | Removes all provided items from the LinkedDeque. |
| LinkedDeque:RetainAll(items) | Removes all items except those provided from the LinkedDeque. |
| LinkedDeque:Shift() | Gets an item from the beginning and removes that item from the LinkedDeque. |
| LinkedDeque:ToArray() | Creates a new array indexed table of this LinkedDeque. |
| LinkedDeque:ToTable() | Creates a new table of this LinkedDeque. |
| LinkedDeque:Unshift(item) | Adds an item to the beginning of the LinkedDeque. |
Functions
Methods- LinkedDeque.new(collection)
-
Creates a new LinkedDeque.
Creates a LinkedDeque copy of the provided Collection or array-indexed
table if one is provided, otherwise creates an empty LinkedDeque.
Parameters:
- collection the Collection or table to copy
Returns:
-
the new LinkedDeque
Methods
- LinkedDeque:Add(item)
-
Adds an item to the LinkedDeque.
Inherited from:
Parameters:
- item the item to add
Returns:
-
true always since the LinkedDeque is always changed
- LinkedDeque:AddAll(items)
-
Adds all provided items to the LinkedDeque.
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 LinkedDeque
Returns:
-
true always since the LinkedDeque is always changed
- LinkedDeque:Clear()
-
Removes everything from the LinkedDeque.
Inherited from:
- LinkedDeque:Contains(item)
-
Determines whether the LinkedDeque contains an item.
Inherited from:
Parameters:
- item the item to locate in the LinkedDeque
Returns:
-
true if the item is in the LinkedDeque, false otherwise
- LinkedDeque:ContainsAll(items)
-
Determines whether the LinkedDeque 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 LinkedDeque
Returns:
-
true if all items are in the LinkedDeque, false otherwise
- LinkedDeque:ContainsAny(items)
-
Determines whether the LinkedDeque 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 LinkedDeque
Returns:
-
true if any items are in the LinkedDeque, false otherwise
- LinkedDeque:Count()
-
Gets the number of items in the LinkedDeque.
Inherited from:
Returns:
-
the number of items
- LinkedDeque:Empty()
-
Determines whether the LinkedDeque has no elements.
Inherited from:
Returns:
-
true if the LinkedDeque empty, false otherwise
- LinkedDeque:Enumerator()
-
Creates an enumerator for the LinkedDeque.
The enumerator can be used directly in a generic for loop similar to pairs
or ipairs.
Inherited from:
Returns:
-
the enumerator generator
- LinkedDeque:First()
-
Gets the item at the beginning of the LinkedDeque.
Inherited from:
Returns:
-
the first item in the LinkedDeque
Raises:
if the LinkedDeque is empty - LinkedDeque:Last()
-
Gets the item at the end of the LinkedDeque.
Inherited from:
Returns:
-
the last item in the LinkedDeque
Raises:
if the LinkedDeque is empty - LinkedDeque:Pop()
-
Gets an item from the end and removes that item from the LinkedDeque.
Inherited from:
Returns:
-
the item in the LinkedDeque
Raises:
if the LinkedDeque is empty - LinkedDeque:Push(item)
-
Adds an item to the end of the LinkedDeque.
Inherited from:
Parameters:
- item the item to add
Returns:
-
true always since the LinkedDeque is always changed
- LinkedDeque:Remove(item)
-
Removes the specified item from the LinkedDeque.
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 LinkedDeque
Returns:
-
true if the LinkedDeque changed as a result, false otherwise
- LinkedDeque:RemoveAll(items)
-
Removes all provided items from the LinkedDeque.
Removes each instance of a provided item only once for each time provided.
If there are multiple of the same item in this LinkedDeque, it removes only
the first encountered for each provided.
Inherited from:
Parameters:
- items the Collection of items to remove from this LinkedDeque
Returns:
-
true if the LinkedDeque changed as a result, false otherwise
- LinkedDeque:RetainAll(items)
-
Removes all items except those provided from the LinkedDeque.
Retains only the items contained in the specified Collection regardless
of duplicates. If there are duplicates they are all kept.
Inherited from:
Parameters:
- items the Collection of items to retain in this LinkedDeque
Returns:
-
true if the LinkedDeque changed as a result, false otherwise
- LinkedDeque:Shift()
-
Gets an item from the beginning and removes that item from the LinkedDeque.
Shifts other elements to fill the gap left.
Inherited from:
Returns:
-
the item in the LinkedDeque
Raises:
if the LinkedDeque is empty - LinkedDeque:ToArray()
-
Creates a new array indexed table of this LinkedDeque.
The order of the array is the same as the order of the LinkedDeque. The first
element of the LinkedDeque will get index 1 and so on.
Inherited from:
Returns:
-
the array indexed table
See also:
- LinkedDeque:ToTable()
-
Creates a new table of this LinkedDeque.
LinkedDeques, 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:
- LinkedDeque:Unshift(item)
-
Adds an item to the beginning of the LinkedDeque.
Inherited from:
Parameters:
- item the item to add
Returns:
-
true always since the LinkedDeque is always changed