OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4ObjectListIterator Class Reference

#include <C4ObjectList.h>

Public Member Functions

 C4ObjectListIterator (C4ObjectList &rList)
 
C4ObjectGetNext (int32_t *piCount)
 

Detailed Description

Definition at line 189 of file C4ObjectList.h.

Constructor & Destructor Documentation

C4ObjectListIterator::C4ObjectListIterator ( C4ObjectList rList)
inline

Definition at line 198 of file C4ObjectList.h.

198 : rList(rList), pCurr(rList.end()), pCurrID(rList.begin()) {} // ctor
const iterator end() const
iterator begin() const

Member Function Documentation

C4Object * C4ObjectListIterator::GetNext ( int32_t *  piCount)

Definition at line 757 of file C4ObjectList.cpp.

References C4ObjectList::end().

Referenced by C4ObjectMenu::DoRefillInternal().

758 {
759  // end reached?
760  if (pCurrID == rList.end()) return nullptr;
761  // not yet started?
762  if (pCurr == rList.end())
763  // then start at first ID list head
764  pCurr = pCurrID;
765  else
766  // next item
767  if (++pCurr == rList.end()) return nullptr;
768  // next ID section reached?
769  if ((*pCurr)->id != (*pCurrID)->id)
770  pCurrID = pCurr;
771  else
772  {
773  // otherwise, it must be checked, whether this is a duplicate item already iterated
774  // if so, advance the list
775  for (C4ObjectList::iterator pCheck = pCurrID; pCheck != pCurr; ++pCheck)
776  if ((*pCheck)->CanConcatPictureWith(*pCurr))
777  {
778  // next object of matching category
779  if (++pCurr == rList.end()) return nullptr;
780  // next ID chunk reached?
781  if ((*pCurr)->id != (*pCurrID)->id)
782  {
783  // then break here
784  pCurrID = pCurr;
785  break;
786  }
787  // restart check for next object
788  pCheck = pCurrID;
789  }
790  }
791  if (piCount)
792  {
793  // default count
794  *piCount = 1;
795  // add additional objects of same ID to the count
796  C4ObjectList::iterator pCheck(pCurr);
797  for (++pCheck; pCheck != rList.end() && (*pCheck)->id == (*pCurr)->id; ++pCheck)
798  if ((*pCheck)->CanConcatPictureWith(*pCurr))
799  ++*piCount;
800  }
801  // return found object
802  return *pCurr;
803 }
const iterator end() const

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files: