void *Burger::LinkedListObjects::GetLastData(void) const { Object *pRoot = m_pRoot; // Get the root pointer void *pResult = NULL; // Assume no data if (pRoot) { // Valid pointer? pRoot = pRoot->GetPrevious(); // Go to the last entry (Could be itself if only one entry) pResult = pRoot->GetData(); // Obtain the data pointer } // Return with the data or NULL return pResult; }
Burger::LinkedListObjects::Object *Burger::LinkedListObjects::GetLast(void) const { // Get the root pointer Object *pResult = m_pRoot; if (pResult) { // Step back one (Could be the same one!) pResult = pResult->GetPrevious(); } // Return the object pointer return pResult; }
Burger::LinkedListObjects::Object *Burger::LinkedListObjects::IterateReverse(ProcAction pProc) { Object *pFirst = m_pRoot; // Is there a list? if (pFirst) { // Start at the last entry pFirst = pFirst->GetPrevious(); Object *pObject = pFirst; do { Word uResult = pProc(pObject->GetData()); // Call the function Object *pPrevious = pObject->GetPrevious(); // Get the next entry if (uResult&DELETEOBJECT) { // Dispose of the entry? DestroyObject(pObject); } if (uResult&ABORT) { // Abort the traversal? pFirst = pObject; break; } pObject = pPrevious; // Next entry please... } while (pObject!=pFirst); // More left? } return pFirst; // Entry I stopped on }