| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#ifndef __itemstack_h__ |
| 21 |
#define __itemstack_h__ |
| 22 |
|
| 23 |
class ITEM; |
| 24 |
class MOB; |
| 25 |
|
| 26 |
#define PTRSTACK_MINSIZE 20 |
| 27 |
|
| 28 |
template <typename PTR> |
| 29 |
class PTRSTACK |
| 30 |
{ |
| 31 |
public: |
| 32 |
PTRSTACK(); |
| 33 |
~PTRSTACK(); |
| 34 |
|
| 35 |
void append(PTR item); |
| 36 |
|
| 37 |
|
| 38 |
void reverse(); |
| 39 |
|
| 40 |
|
| 41 |
void clear(); |
| 42 |
|
| 43 |
|
| 44 |
void collapse(); |
| 45 |
|
| 46 |
PTR operator()(int idx) const; |
| 47 |
int entries() const; |
| 48 |
|
| 49 |
void set(int idx, PTR item); |
| 50 |
|
| 51 |
void setEntries(int entries); |
| 52 |
|
| 53 |
private: |
| 54 |
PTR *myExtraList; |
| 55 |
int myEntries; |
| 56 |
int myExtraSize; |
| 57 |
PTR myLocal[PTRSTACK_MINSIZE]; |
| 58 |
}; |
| 59 |
|
| 60 |
typedef PTRSTACK<ITEM *> ITEMSTACK; |
| 61 |
typedef PTRSTACK<MOB *> MOBSTACK; |
| 62 |
|
| 63 |
|
| 64 |
#include "itemstack.cpp" |
| 65 |
|
| 66 |
#endif |