galdar496 / QiGameEngine

Realtime Game Engine designed with C++ and OpenGL.
http://qiengine.blogspot.com/
1 stars 0 forks source link

Create an iterator for use in the Qi container classes #29

Open galdar496 opened 9 years ago

galdar496 commented 9 years ago

Iterators are simple references to objects within the containers. Each container should support a being/end iterator and the iterator should support the ++ and -- operators. De-referencing the iterator will give access to the underlying type (just like in STL).

galdar496 commented 9 years ago

Create a base iterator class with functions for overloading. There will probably only be two types of random-access iterators, one for iterating over linear memory and one for iterating over memory that is random access (like a linked list or a map). Since we don't have to worry about random access (Qi likely won't ever support this for performance reasons), maybe the base class is irrelevant and we can just have one iterator class in use for all containers (since they'll want to be stored linearly anyways).

See the last comment here for an example of the functions to include: http://stackoverflow.com/questions/3582608/how-to-correctly-implement-custom-iterators-and-const-iterators