OpenClonk
C4ObjectList::iterator Class Reference

#include <C4ObjectList.h>

Public Member Functions

 ~iterator ()
 
iteratoroperator++ ()
 
iterator operator++ (int)
 
 iterator (const iterator &iter)
 
C4Objectoperator* ()
 
bool operator== (const iterator &iter) const
 
bool operator!= (const iterator &iter) const
 
bool find (C4Object *target)
 
bool atEnd () const
 
bool advance ()
 
bool reset ()
 
iteratoroperator= (const iterator &iter)
 

Friends

class C4ObjectList
 

Detailed Description

Definition at line 58 of file C4ObjectList.h.

Constructor & Destructor Documentation

◆ ~iterator()

C4ObjectList::iterator::~iterator ( )

Definition at line 1154 of file C4ObjectList.cpp.

1155 {
1156  List.RemoveIter(this);
1157 }
void RemoveIter(iterator *iter) const

◆ iterator()

C4ObjectList::iterator::iterator ( const iterator iter)

Definition at line 1149 of file C4ObjectList.cpp.

1149  :
1150  List(iter.List), link(iter.link), Next(), reverse(iter.reverse)
1151 {
1152  Next=List.AddIter(this);
1153 }
iterator * AddIter(iterator *iter) const

References C4ObjectList::AddIter().

Here is the call graph for this function:

Member Function Documentation

◆ advance()

bool C4ObjectList::iterator::advance ( )

Definition at line 1214 of file C4ObjectList.cpp.

1215 {
1216  (*this)++;
1217  return !atEnd();
1218 }

◆ atEnd()

bool C4ObjectList::iterator::atEnd ( ) const

Definition at line 1202 of file C4ObjectList.cpp.

1203 {
1204  return link.Obj == nullptr;
1205 }
C4Object * Obj
Definition: C4ObjectList.h:28

References C4ObjectLink::Obj.

◆ find()

bool C4ObjectList::iterator::find ( C4Object target)

Definition at line 1186 of file C4ObjectList.cpp.

1187 {
1188  while (link.Obj)
1189  {
1190  if (link.Obj == target)
1191  {
1192  return true;
1193  }
1194  else
1195  {
1196  (*this)++;
1197  }
1198  }
1199  return false;
1200 }

References C4ObjectLink::Obj.

◆ operator!=()

bool C4ObjectList::iterator::operator!= ( const iterator iter) const

Definition at line 1181 of file C4ObjectList.cpp.

1182 {
1183  return !(*this == iter);
1184 }

◆ operator*()

C4Object * C4ObjectList::iterator::operator* ( )

Definition at line 1170 of file C4ObjectList.cpp.

1171 {
1172  return link.Obj;
1173 }

References C4ObjectLink::Obj.

◆ operator++() [1/2]

C4ObjectList::iterator & C4ObjectList::iterator::operator++ ( )

Definition at line 1158 of file C4ObjectList.cpp.

1159 {
1160  C4ObjectLink* advance = reverse ? link.Prev : link.Next;
1161  link = advance ? *advance : NULL_LINK;
1162  return *this;
1163 }
C4ObjectLink * Prev
Definition: C4ObjectList.h:29
C4ObjectLink * Next
Definition: C4ObjectList.h:29

References C4ObjectLink::Next, C4ObjectLink::Prev, and C4ObjectList::reverse().

Referenced by operator++().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator++() [2/2]

C4ObjectList::iterator C4ObjectList::iterator::operator++ ( int  )

Definition at line 1164 of file C4ObjectList.cpp.

1165 {
1166  iterator old = *this;
1168  return old;
1169 }
iterator(const iterator &iter)

References operator++().

Here is the call graph for this function:

◆ operator=()

C4ObjectList::iterator & C4ObjectList::iterator::operator= ( const iterator iter)

Definition at line 1220 of file C4ObjectList.cpp.

1221 {
1222  // Can only assign iterators into the same list
1223  assert(&iter.List == &List);
1224 
1225  link = iter.link;
1226  reverse = iter.reverse;
1227  return *this;
1228 }

References C4ObjectList::reverse().

Here is the call graph for this function:

◆ operator==()

bool C4ObjectList::iterator::operator== ( const iterator iter) const

Definition at line 1174 of file C4ObjectList.cpp.

1175 {
1176  return
1177  &iter.List == &List &&
1178  iter.link.Obj == link.Obj /* checking for same object should be enough */ &&
1179  iter.reverse == reverse;
1180 }

References C4ObjectLink::Obj, and C4ObjectList::reverse().

Here is the call graph for this function:

◆ reset()

bool C4ObjectList::iterator::reset ( )

Definition at line 1207 of file C4ObjectList.cpp.

1208 {
1209  C4ObjectLink* l = reverse ? List.Last : List.First;
1210  link = l ? *l : NULL_LINK;
1211  return !atEnd();
1212 }
C4ObjectLink * First
Definition: C4ObjectList.h:51
C4ObjectLink * Last
Definition: C4ObjectList.h:51

References C4ObjectList::reverse().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ C4ObjectList

friend class C4ObjectList
friend

Definition at line 85 of file C4ObjectList.h.


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