lux.datastruct.List a LUX prototype
LUX’s list class. This is a linked list implementation in Lua.
Functions
-
List:__construct ()
- The list’s constructor may take a sequence of values to initialize the list with.
-
List:empty ()
-
Tells if the list is empty.
Returns:
-
any
True if and only if the list is empty.
-
List:size ()
-
Tells the size of the list.
Returns:
-
any
The number of elements in the list.
-
List:pushBack (value, ...)
-
Pushes elements at the end of the list.
Parameters:
-
any
value
First pushed element.
-
any
...
Other elements to be pushed.
Returns:
-
any
The list itself.
-
any
value
-
List:pushFront (...)
-
Pushes elements at the begining of the list.
Parameters:
-
any
...
Elements to be pushed.
Returns:
-
any
The list itself
-
any
...
-
List:front ()
-
Gives the first element of the list.
Returns:
-
any
The first element of the list.
-
List:back ()
-
Gives the last element of the list.
Returns:
-
any
The last element of the list.
-
List:popBack (n, ...)
-
Pops elements from the end of the list.
Parameters:
-
any
n
Number of elements to pop.
-
any
...
For internal use.
Returns:
-
any
The popped elemnts.
-
any
n
-
List:popFront (n, t)
-
Pops elements from the the begining of the list.
Parameters:
-
any
n
Number of elements to pop.
-
any
t
For internal use.
Returns:
-
any
The popped elements.
-
any
n
-
List:each ()
-
Iterate through the list.
The iteration variable is an accessor function:
l = list:new{…}
for v in l:each() do print(v()) end
Returns:
-
any
Iterator function.