#ifndef T2DLL_LARRAY_H #define T2DLL_LARRAY_H #include "../common.h" #include "LComparator.h" class AFX_CLASS_EXPORT LArray { public: LArray(); LArray(int size, LComparator* comparator = NULL, BOOL keepSorted = false); void init(int size, LComparator* comparator, BOOL keepSorted); ~LArray(); virtual int GetCount() const; protected: void Expand(int amount); public: void AdjustAllocation(int amount); void SetKeepSorted(BOOL keepSorted); virtual void InsertItemsAt(int count, int where, const void* data); virtual void RemoveItemsAt(int count, int where); virtual void Remove(const void* item); virtual int FetchIndexOf(const void* item) const; virtual BOOL FetchItemAt(int index, void* outItem) const; virtual void AssignItemsAt(int count, int where, void* data); virtual void Add(const void* item); void SetComparator(LComparator* comparator); virtual void ReadAsWord(T2Archive& archive); virtual void WriteAsWord(T2Archive& archive); virtual void ReadAsDWord(T2Archive& archive); virtual void WriteAsDWord(T2Archive& archive); virtual void ReadAsChar(T2Archive& archive); virtual void WriteAsChar(T2Archive& archive); protected: BOOL mOwnsComparator; int mItemSize; int mItemCount; void *mBuffer; int mExpandSize; LComparator *mComparator; BOOL mKeepSorted; }; class AFX_CLASS_EXPORT LArrayIterator { public: LArrayIterator(const LArray& array, int index = 1); LArrayIterator(const LArrayIterator& iter); ~LArrayIterator(); void ResetTo(int index); void Rewind(); void Seek(const LArrayIterator& iter); BOOL Next(void* item); BOOL Previous(void* item); void Reset() { ResetTo(1); } int GetCurrentIndex() { return mCurrentIndex; } private: const LArray *mArray; int mNextIndex; int mCurrentIndex; }; #endif