1 //========================================================================
5 // Copyright 2001-2002 Glyph & Cog, LLC
7 //========================================================================
18 //------------------------------------------------------------------------
20 //------------------------------------------------------------------------
25 // Create an empty list.
28 // Create an empty list with space for <size1> elements.
31 // Destructor - does not free pointed-to objects.
36 // Get the number of elements.
37 int getLength() { return length; }
39 //----- ordered list support
41 // Return the <i>th element.
42 // Assumes 0 <= i < length.
43 void *get(int i) { return data[i]; }
45 // Append an element to the end of the list.
48 // Append another list to the end of this one.
49 void append(GList *list);
51 // Insert an element at index <i>.
52 // Assumes 0 <= i <= length.
53 void insert(int i, void *p);
55 // Deletes and returns the element at index <i>.
56 // Assumes 0 <= i < length.
61 // Set allocation increment to <inc>. If inc > 0, that many
62 // elements will be allocated every time the list is expanded.
63 // If inc <= 0, the list will be doubled in size.
64 void setAllocIncr(int incA) { inc = incA; }
71 void **data; // the list elements
72 int size; // size of data array
73 int length; // number of elements on list
74 int inc; // allocation increment
77 #define deleteGList(list, T) \
79 GList *_list = (list); \
82 for (_i = 0; _i < _list->getLength(); ++_i) { \
83 delete (T*)_list->get(_i); \