Burger::LinkedListObjects::Object *Burger::LinkedListObjects::GetObject(Word uIndex) const { Object *pObject = NULL; if (uIndex<m_uCount) { // Invalid count? pObject = m_pRoot; // Get the first entry if (uIndex) { // Should I traverse? do { pObject = pObject->GetNext(); // Follow the list } while (--uIndex); // All done? } } return pObject; }
void *Burger::LinkedListObjects::GetData(Word uIndex) const { void *pResult = NULL; if (uIndex<m_uCount) { // Invalid count? Object *pObject = m_pRoot; // Get the first entry if (uIndex) { // Should I traverse? do { pObject = pObject->GetNext(); // Follow the list } while (--uIndex); // All done? } pResult = pObject->GetData(); // Found it! } return pResult; }
Word Burger::LinkedListObjects::GetStringIndex(const char *pString) const { Word uResult = static_cast<Word>(-1); Object *pObject = m_pRoot; // Get the first entry if (pObject) { // Should I traverse? Word uCount = m_uCount; do { if (!StringCaseCompare(static_cast<const char *>(pObject->GetData()),pString)) { uResult = m_uCount-uCount; // Determine the index number break; } pObject = pObject->GetNext(); // Follow the list } while (--uCount); // All done? } return uResult; }
Burger::LinkedListObjects::Object *Burger::LinkedListObjects::GetStringObject(const char *pString) const { Object *pResult = m_pRoot; // Get the first entry if (pResult) { // Should I traverse? Word uCount = m_uCount; Object *pObject = pResult; do { if (!StringCaseCompare(static_cast<const char *>(pObject->GetData()),pString)) { pResult = pObject; break; } pObject = pObject->GetNext(); // Follow the list } while (--uCount); // All done? } return pResult; }
Burger::LinkedListObjects::Object *Burger::LinkedListObjects::GetObject(void *pData) const { Object *pResult = m_pRoot; // Get the first entry if (pResult) { // Should I traverse? Word uCount = m_uCount; Object *pObject = pResult; do { if (pObject->GetData()==pData) { pResult = pObject; break; } pObject = pObject->GetNext(); // Follow the list } while (--uCount); // All done? } return pResult; }
Burger::LinkedListObjects::Object *Burger::LinkedListObjects::IterateForward(ProcAction pProc) { Object *pFirst = m_pRoot; // Is there a list? if (pFirst) { Object *pObject = pFirst; do { Word uResult = pProc(pObject->GetData()); // Call the function Object *pNext = pObject->GetNext(); // Get the next entry if (uResult&DELETEOBJECT) { // Dispose of the entry? DestroyObject(pObject); } if (uResult&ABORT) { // Abort the traversal? pFirst = pObject; break; } pObject = pNext; // Next entry please... } while (pObject!=pFirst); // More left? } return pFirst; // Entry I stopped on }