LinkedList
A doubly-linked list.
Easily inserts and deletes arbitrarily without reordering. A reference to the entry to insert or delete at is required. References to the front and back of the list always exist. When inserting new entries, entry references are provided for convenient removal.
Types
Entry<T>
interface
Entry<T> {
remove:
(
)
→
(
)
}
An entry in a LinkedList.
Allows removing this entry from the list. This is a constant time operation.
Functions
new
LinkedList.
new
(
) →
(
)
Creates a new LinkedList.
Push
LinkedList:
Push
(
value:
T
) →
Entry
<
T
>
Pushes a new entry to the back of this list.
Unshift
LinkedList:
Unshift
(
value:
T
) →
Entry
<
T
>
Unshifts a new entry to the front of this list.
Shift
LinkedList:
Shift
(
) →
unknown
Shifts an entry off of the front of this list.
Pop
LinkedList:
Pop
(
) →
unknown
Pops an entry off of the back of this list.
Peek
LinkedList:
Peek
(
) →
unknown
Returns the value of the first element in the list without removing it.
PeekBack
LinkedList:
PeekBack
(
) →
unknown
Returns the value of the last element in the list without removing it.
PeekEntry
LinkedList:
PeekEntry
(
) →
Entry
<
unknown
>
?
Returns the first entry in the list without removing it.
PeekBackEntry
LinkedList:
PeekBackEntry
(
) →
Entry
<
unknown
>
?
Returns the last entry in the list without removing it.
iterating over LinkedList
for
T
,
Entry
<
T
>
in
LinkedList
do
Iterates over all entries in this list.
Iteration returns the value stored in each entry, followed by an Entry object which can be used to manipulate this entry in the list.
for value, entry in list do
if value == "foo" then
entry.remove()
end
end
IterReversed
LinkedList:
IterReversed
(
) →
(
T
,
--
The value stored in the entry
Entry
<
T
>
--
The entry object
)
Iterates over all entries in this list in reverse order.
Iteration returns the value stored in each entry, followed by an Entry object which can be used to manipulate this entry in the list.
for value, entry in list:IterReversed() do
if value == "foo" then
entry.remove()
end
end