Debian Codegraph @

ptrlist.h

raw symbols SCIP
1 /*
2 * Licensed under BSD license. See LICENCE.TXT
3 *
4 * Produced by: Jeff Lait
5 *
6 * 7DRL Development
7 *
8 * NAME: ptrlist.h ( Letter Hunt Library, C++ )
9 *
10 * COMMENTS:
11 * Implements a simple list of pointers.
12 * The observent will notice similarities to ptrstack defined
13 * itemstack.
14 */
15
16 #ifndef __ptrlist_h__
17 #define __ptrlist_h__
18
19 template <typename PTR>
20 class PTRLIST
21 {
22 public:
23 PTRLIST();
24 ~PTRLIST();
25
26 // No copy constructors as you should be passing by reference to build!
27 // That is a noble sentiment, but we live in a corrupt world
28 PTRLIST(const PTRLIST<PTR> &ref);
29 PTRLIST<PTR> &operator=(const PTRLIST<PTR> &ref);
30
31 void append(PTR item);
32 void append(const PTRLIST<PTR> &list);
33
34 // Reverses the order of the stack.
35 void reverse();
36
37 // Empties the stack
38 void clear();
39
40 // Sets array to constant value
41 void constant(PTR ptr);
42
43 // Sets entries to the given size.
44 void resize(int size);
45
46 PTR operator()(int idx) const;
47 int entries() const;
48
49 void set(int idx, PTR item);
50
51 void insert(int idx, PTR item);
52
53 // Removes all instances of "item" from
54 // this list.
55 void removePtr(PTR item);
56
57 // Removes a given index
58 void removeAt(int idx);
59
60 // Returns the last item on this list and decreases
61 // the length.
62 PTR pop();
63
64 // Swaps two entries
65 void swapEntries(int i1, int i2);
66
67 // Returns the last element.
68 // The index allows you to specify N elements from the end, where
69 // 0 is the last element and 1 second last.
70 PTR top(int idx = 0) const { return (*this)(entries()-1-idx); }
71
72 // Returns the first item from this list and
73 // removes it.
74 PTR removeFirst();
75
76 // Finds the given item, returns -1 if fails.
77 int find(PTR item) const;
78
79 // Deletes all zero entries.
80 void collapse();
81
82 // I shouldn ot have to explain why you should never call this.
83 PTR *rawptr(int idx=0) const { return &myList[idx]; }
84
85 private:
86 PTR *myList;
87 int myStartPos;
88 int myEntries;
89 int mySize;
90 };
91
92 // For crappy platforms:
93 #include "ptrlist.cpp"
94
95 #endif
96