summaryrefslogtreecommitdiff
path: root/noncore/unsupported/qpdf/goo/GList.h
Unidiff
Diffstat (limited to 'noncore/unsupported/qpdf/goo/GList.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/unsupported/qpdf/goo/GList.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/noncore/unsupported/qpdf/goo/GList.h b/noncore/unsupported/qpdf/goo/GList.h
new file mode 100644
index 0000000..cc23731
--- a/dev/null
+++ b/noncore/unsupported/qpdf/goo/GList.h
@@ -0,0 +1,89 @@
1//========================================================================
2//
3// GList.h
4//
5// Copyright 2001 Derek B. Noonburg
6//
7//========================================================================
8
9#ifndef GLIST_H
10#define GLIST_H
11
12#ifdef __GNUC__
13#pragma interface
14#endif
15
16#include "gtypes.h"
17
18//------------------------------------------------------------------------
19// GList
20//------------------------------------------------------------------------
21
22class GList {
23public:
24
25 // Create an empty list.
26 GList();
27
28 // Create an empty list with space for <size1> elements.
29 GList(int sizeA);
30
31 // Destructor - does not free pointed-to objects.
32 ~GList();
33
34 //----- general
35
36 // Get the number of elements.
37 int getLength() { return length; }
38
39 //----- ordered list support
40
41 // Return the <i>th element.
42 // Assumes 0 <= i < length.
43 void *get(int i) { return data[i]; }
44
45 // Append an element to the end of the list.
46 void append(void *p);
47
48 // Append another list to the end of this one.
49 void append(GList *list);
50
51 // Insert an element at index <i>.
52 // Assumes 0 <= i <= length.
53 void insert(int i, void *p);
54
55 // Deletes and returns the element at index <i>.
56 // Assumes 0 <= i < length.
57 void *del(int i);
58
59 //----- control
60
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; }
65
66private:
67
68 void expand();
69 void shrink();
70
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
75};
76
77#define deleteGList(list, T) \
78 do { \
79 GList *_list = (list); \
80 { \
81 int _i; \
82 for (_i = 0; _i < _list->getLength(); ++_i) { \
83 delete (T*)_list->get(_i); \
84 } \
85 delete _list; \
86 } \
87 } while (0)
88
89#endif