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 756 of file C4ObjectList.cpp.

References C4ObjectList::end().

Referenced by C4ObjectMenu::DoRefillInternal().

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