1. Attributes

Italics means private (in the sense that they shouldn't be set manually).

Attribute Description
head head of the list
tail tail of the list
temp temporary data slot
size the size of the list (read-only)

2. Methods

Method Description
new(o) constructor
push_front(obj) adds an object to the front of the list
push_back(obj) adds an object to the back of the list
front() returns the element at the front of the list, else nil
back() returns the element at the back of the list, else nil
pop_front() removes the front element from the list
pop_back() removes the back element from the list
clear() clears the list
iterator() returns an iterator for use in a generic for loop
update_all() updates all Object instances in the list
draw_all() draws all Object instances in the list

3. Usage

This class is designed with an interface similar to the STL::list class. While it happens to be named ObjectList, it can be used to store any data type.

Example: Example:
list = ObjectList:new()

list:push_back("world")
list:push_front("hello")
list:push_back(5)

--prints:
-- hello
-- world
-- 5
for x in list:iterator() do
  print(x)
end

list:push_back(MyObj:new())
list:draw_all() --draws the previously instantiated object only