#include "T2MatterArray.h" T2MatterArray::T2MatterArray(unsigned int jobType, unsigned int validRange, unsigned int startID) : T2ObjectArray(startID) { mJobType = jobType; mValidRange = validRange; for (unsigned int i = 0; i < kGroupSize; i++) mMatter[i].mMatterID = mStartID + i; } void T2MatterArray::SetValidRange(unsigned int validRange) { if (validRange <= kGroupSize) mValidRange = validRange; } T2Matter* T2MatterArray::FindUnusedMatter(unsigned int arg) { for (unsigned int i = 0; i < mValidRange; i++) { if (!mMatter[i].IsUsed()) return &mMatter[i]; } if (arg > 0) { unsigned int start = mValidRange; unsigned int end = mValidRange + arg; if (end > kGroupSize) end = kGroupSize; mValidRange = end; for (unsigned int i = start; i < mValidRange; i++) { if (!mMatter[i].IsUsed()) return &mMatter[i]; } } return NULL; }