Fixed some little errors with the drawing functions.
[luagame.git] / doc / class_objectlist.txt
blob78efe93369c68136cb8041538b225de9937ab5f1
1 = ObjectList Class Reference =
3 == Attributes ==
4 _Italics_ means private (in the sense that they shouldn't be set manually).
6 [grid="all"]
7 `--------------`--------------------
8 Attribute      Description
9 ------------------------------------
10 _head_         head of the list
11 _tail_         tail of the list
12 _temp_         temporary data slot
13 _size_         the size of the list (read-only)
14 ------------------------------------
17 == Methods == 
18 [grid="all"]
19 `--------------`--------------------
20 Method         Description
21 ------------------------------------
22 new(o)          constructor
23 push_front(obj) adds an object to the front of the list
24 push_back(obj)  adds an object to the back of the list
25 front()         returns the element at the front of the list, else nil
26 back()          returns the element at the back of the list, else nil
27 pop_front()     removes the front element from the list
28 pop_back()      removes the back element from the list
29 clear()         clears the list
30 iterator()      returns an iterator for use in a generic for loop
31 update(delta)   updates all Object instances in the list
32 draw()          draws all Object instances in the list
33 ------------------------------------
35 == Usage ==
36 This class is designed with an interface similar to the STL::list class. While
37 it happens to be named _ObjectList_, it can be used to store any data type.
39 .Example:
40 [lua]
41 source~~~~~~~~~~~~~~~~~~~~~~~~~
42 list = ObjectList:new()
44 list:push_back("world")
45 list:push_front("hello")
46 list:push_back(5)
48 --prints:
49 -- hello
50 -- world
51 -- 5
52 for x in list:iterator() do
53   print(x)
54 end
56 list:push_back(MyObj:new())
57 list:draw() --draws the previously instantiated object only
59 source~~~~~~~~~~~~~~~~~~~~~~~~~