/* ....[@@@..[@@@..............[@.................. MUD++ is a written from ....[@..[@..[@..[@..[@..[@@@@@....[@......[@.... scratch multi-user swords and ....[@..[@..[@..[@..[@..[@..[@..[@@@@@..[@@@@@.. sorcery game written in C++. ....[@......[@..[@..[@..[@..[@....[@......[@.... This server is an ongoing ....[@......[@..[@@@@@..[@@@@@.................. development project. All ................................................ contributions are welcome. ....Copyright(C).1995.Melvin.Smith.............. Enjoy. ------------------------------------------------------------------------------ Melvin Smith (aka Fusion) msmith@hom.net MUD++ development mailing list mudpp-list@mailhost.net ------------------------------------------------------------------------------ vmnarray.h */ #ifndef _VMARRAY_H #define _VMARRAY_H class VMarray { public: int ref_count; int count; int size; vmtype type; vmptr * table; VMarray( vmtype t ) : ref_count(0), count(0), size(10),type(t) { table = new vmptr[size]; } VMarray( vmtype t, int s ) : ref_count(0), count(s), size(s), type(t) { table = new vmptr[size]; } ~VMarray() { int i; for (i=0; i < count; i++ ) vmtype_table[type].del(table[i]); delete [] table; } void reference() { ref_count++;} void dereference() { ref_count--; if (ref_count<=0) delete this; } // caller must take care of reference/dereference void add( vmptr val ) { if ( count >= size ) { vmptr * new_table = new vmptr[size << 1]; memcpy(new_table, table, count * sizeof(vmptr)); delete table; table = new_table; size <<= 1; } table[count] = val; count++; } }; #endif