#ifndef __DYNAMIC_HPP #define __DYNAMIC_HPP template class DynElement { public: Item i; DynElement() {} DynElement& operator=(const Item &item) { i=item; return *this; } DynElement& operator=(const DynElement &d) { i=d.i; return *this; } static void *operator new(size_t s) { return StorageManager::alloc(s); } static void *operator new[](size_t s) { return StorageManager::alloc(s); } static void operator delete(void *p, size_t s) { StorageManager::free(p,s); } static void operator delete[](void *p, size_t s) { StorageManager::free(p,s); } }; template class Dynamic { public: Dynamic(); Dynamic(const Dynamic &d); virtual ~Dynamic(); Dynamic& operator=(const Dynamic &d); void clear(); void insert(const Item &); void insert(const Item &, unsigned before); void append(const Item &); void append(const Item &, unsigned after); void remove(unsigned at); void replace(unsigned at, const Item &); int isEmpty() const; unsigned length() const; const Item& first() const; const Item& last() const; const Item& itemAt(unsigned at) const; Item& itemAt(unsigned at); const Item& operator[](unsigned at) const { return itemAt(at); } Item& operator[](unsigned at) { return itemAt(at); } protected: DynElement *rep; unsigned chunkSize; unsigned allocated; unsigned start,items; void expandLeft(unsigned from); void expandRight(unsigned from); void shrinkLeft(unsigned from); void shrinkRight(unsigned from); void expand(); }; #include "dynamic.cpp" #endif