1 //========================================================================
5 // Copyright 2001-2003 Glyph & Cog, LLC
7 //========================================================================
14 #ifdef USE_GCC_PRAGMAS
20 //------------------------------------------------------------------------
22 //------------------------------------------------------------------------
27 // Create an empty list.
30 // Create an empty list with space for <size1> elements.
33 // Destructor - does not free pointed-to objects.
38 // Get the number of elements.
39 int getLength() { return length; }
41 //----- ordered list support
43 // Return the <i>th element.
44 // Assumes 0 <= i < length.
45 void *get(int i) { return data[i]; }
47 // Append an element to the end of the list.
50 // Append another list to the end of this one.
51 void append(GList *list);
53 // Insert an element at index <i>.
54 // Assumes 0 <= i <= length.
55 void insert(int i, void *p);
57 // Deletes and returns the element at index <i>.
58 // Assumes 0 <= i < length.
63 // Set allocation increment to <inc>. If inc > 0, that many
64 // elements will be allocated every time the list is expanded.
65 // If inc <= 0, the list will be doubled in size.
66 void setAllocIncr(int incA) { inc = incA; }
73 void **data; // the list elements
74 int size; // size of data array
75 int length; // number of elements on list
76 int inc; // allocation increment
79 #define deleteGList(list, T) \
81 GList *_list = (list); \
84 for (_i = 0; _i < _list->getLength(); ++_i) { \
85 delete (T*)_list->get(_i); \