1 //========================================================================
5 // Copyright 2001-2003 Glyph & Cog, LLC
7 //========================================================================
9 //========================================================================
11 // Modified under the Poppler project - http://poppler.freedesktop.org
13 // All changes made under the Poppler project to this file are licensed
14 // under GPL version 2 or later
16 // Copyright (C) 2012 Albert Astals Cid <aacid@kde.org>
18 // To see a description of the changes please see the Changelog file that
19 // came with your tarball or type make ChangeLog if you are building from git
21 //========================================================================
26 #ifdef USE_GCC_PRAGMAS
32 //------------------------------------------------------------------------
34 //------------------------------------------------------------------------
39 // Create an empty list.
42 // Create an empty list with space for <size1> elements.
45 // Destructor - does not free pointed-to objects.
50 // Get the number of elements.
51 int getLength() { return length
; }
53 // Returns a (shallow) copy of this list.
56 //----- ordered list support
58 // Return the <i>th element.
59 // Assumes 0 <= i < length.
60 void *get(int i
) { return data
[i
]; }
62 // Replace the <i>th element.
63 // Assumes 0 <= i < length.
64 void put(int i
, void *p
) { data
[i
] = p
; }
66 // Append an element to the end of the list.
69 // Append another list to the end of this one.
70 void append(GooList
*list
);
72 // Insert an element at index <i>.
73 // Assumes 0 <= i <= length.
74 void insert(int i
, void *p
);
76 // Deletes and returns the element at index <i>.
77 // Assumes 0 <= i < length.
80 // Sort the list accoring to the given comparison function.
81 // NB: this sorts an array of pointers, so the pointer args need to
82 // be double-dereferenced.
83 void sort(int (*cmp
)(const void *ptr1
, const void *ptr2
));
90 // Set allocation increment to <inc>. If inc > 0, that many
91 // elements will be allocated every time the list is expanded.
92 // If inc <= 0, the list will be doubled in size.
93 void setAllocIncr(int incA
) { inc
= incA
; }
96 GooList(const GooList
&other
);
97 GooList
& operator=(const GooList
&other
);
102 void **data
; // the list elements
103 int size
; // size of data array
104 int length
; // number of elements on list
105 int inc
; // allocation increment
108 #define deleteGooList(list, T) \
110 GooList *_list = (list); \
113 for (_i = 0; _i < _list->getLength(); ++_i) { \
114 delete (T*)_list->get(_i); \