#include "T2MatterArray.h" #include "T2MatterArrayList.h" T2MatterArrayList::T2MatterArrayList() : LArray(sizeof(T2MatterArray *)) { T2MatterArray *theArray = new T2MatterArray(0, T2MatterArray::kGroupSize, 1); Add(theArray); } /*virtual*/ T2MatterArrayList::~T2MatterArrayList() { LArrayIterator iterator(*this); T2MatterArray *theArray; while (iterator.Next(&theArray)) delete theArray; } void T2MatterArrayList::Add(T2MatterArray* inArray) { InsertItemsAt(1, mItemCount + 1, &inArray); } unsigned int T2MatterArrayList::GetItemCount() { return GetCount(); } T2MatterArray* T2MatterArrayList::GetItemAt(long inIndex) { T2MatterArray *theArray; if (FetchItemAt(inIndex, &theArray)) return theArray; return NULL; } T2Matter* T2MatterArrayList::FindUnusedMatter(unsigned int inJobType, unsigned int inValidRange) { LArrayIterator iterator(*this); unsigned int lastStartID = 1; T2MatterArray *theArray; while (iterator.Next(&theArray)) { if (theArray->GetJobType() == inJobType) { T2Matter *theMatter = theArray->FindUnusedMatter(inValidRange); if (theMatter) return theMatter; lastStartID = theArray->mStartID; } } if (inValidRange > 0) { theArray = new T2MatterArray(inJobType, inValidRange, lastStartID + T2MatterArray::kGroupSize); if (theArray) { Add(theArray); return theArray->FindUnusedMatter(0); } return NULL; } return NULL; }