diff options
author | Ash Wolf <ninji@wuffs.org> | 2023-06-28 22:22:32 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2023-06-28 22:22:32 +0100 |
commit | c0c336500955a23e344651e5412c9d9d441ef4ee (patch) | |
tree | 790769c748db307cf3314f6e896e2f61c68561a2 /src/T2DLL/T2MatterArrayList.cpp | |
parent | 37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff) | |
download | t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip |
first pass of T2DLL
Diffstat (limited to 'src/T2DLL/T2MatterArrayList.cpp')
-rw-r--r-- | src/T2DLL/T2MatterArrayList.cpp | 54 |
1 files changed, 44 insertions, 10 deletions
diff --git a/src/T2DLL/T2MatterArrayList.cpp b/src/T2DLL/T2MatterArrayList.cpp index d53785e..5611373 100644 --- a/src/T2DLL/T2MatterArrayList.cpp +++ b/src/T2DLL/T2MatterArrayList.cpp @@ -1,25 +1,59 @@ +#include "T2MatterArray.h" #include "T2MatterArrayList.h" -T2MatterArrayList::T2MatterArrayList(const T2MatterArrayList&) { -} - -T2MatterArrayList& T2MatterArrayList::operator=(const T2MatterArrayList&) { -} - -T2MatterArrayList::T2MatterArrayList() { +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*) { +void T2MatterArrayList::Add(T2MatterArray* inArray) { + InsertItemsAt(1, mItemCount + 1, &inArray); } unsigned int T2MatterArrayList::GetItemCount() { + return GetCount(); } -T2MatterArray* T2MatterArrayList::GetItemAt(long) { +T2MatterArray* T2MatterArrayList::GetItemAt(long inIndex) { + T2MatterArray *theArray; + if (FetchItemAt(inIndex, &theArray)) + return theArray; + return NULL; } -T2Matter* T2MatterArrayList::FindUnusedMatter(unsigned int, unsigned int) { +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; } |