| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 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 |
|
| 27 |
|
| 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 |
|
| 35 |
void reverse(); |
| 36 |
|
| 37 |
|
| 38 |
void clear(); |
| 39 |
|
| 40 |
|
| 41 |
void constant(PTR ptr); |
| 42 |
|
| 43 |
|
| 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 |
|
| 54 |
|
| 55 |
void removePtr(PTR item); |
| 56 |
|
| 57 |
|
| 58 |
void removeAt(int idx); |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
PTR pop(); |
| 63 |
|
| 64 |
|
| 65 |
void swapEntries(int i1, int i2); |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
PTR top(int idx = 0) const { return (*this)(entries()-1-idx); } |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
PTR removeFirst(); |
| 75 |
|
| 76 |
|
| 77 |
int find(PTR item) const; |
| 78 |
|
| 79 |
|
| 80 |
void collapse(); |
| 81 |
|
| 82 |
|
| 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 |
|
| 93 |
#include "ptrlist.cpp" |
| 94 |
|
| 95 |
#endif |
| 96 |
|