#include "mem_block.h" class ptr_list { private: mem_block_t data; int count; protected: void * get_raw_ptr() {return data.get_ptr();} public: ptr_list() {count=0;} int get_count() const {return count;} void * get_item(int n) const { if (n>=0 && n=0;} void remove_item(void * ptr) { int idx = find_item(ptr); if (idx>=0) remove_by_idx(idx); } void * remove_by_idx(int idx) { void * ptr = 0; if (idx>=0 && idxcount || idx<0) idx = count; count++; data.check_size(count); int n; for(n=count-1;n>idx;n--) { data[n]=data[n-1]; } data[idx] = ptr; return idx; } void * operator[](int idx) const {return get_item(idx);} }; template class ptr_list_t : protected ptr_list { public: int get_count() const {return ptr_list::get_count();} T * get_item(int n) const {return static_cast(ptr_list::get_item(n));} int add_item(T * ptr) {return ptr_list::add_item(static_cast(ptr));} int find_item(T * ptr) {return ptr_list::find_item(static_cast(ptr));} bool have_item(T * ptr) {return ptr_list::have_item(static_cast(ptr));} void remove_item(T * ptr) {ptr_list::remove_item(static_cast(ptr));} T * remove_by_idx(int idx) {return static_cast(ptr_list::remove_by_idx(idx));} void remove_all() {ptr_list::remove_all();} void * operator[](int idx) const {return get_item(idx);} int insert_item(int idx,T* ptr) {return ptr_list::insert_item(idx,static_cast(ptr));} void delete_item(T * ptr) { remove_item(ptr); delete ptr; } void delete_by_idx(int idx) { T * ptr = remove_by_idx(idx); if (ptr) delete ptr; } void delete_all() { int n,max=get_count(); for(n=0;n