NLS Engine  v0.1
The Next Logical Step in game engine design.
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Defines
PointList.h
Go to the documentation of this file.
00001 
00006 #pragma once
00007 
00008 #include <map>
00009 #include <string>
00010 #include <vector>
00011 
00012 struct Point {
00013   int x,y;
00014   bool operator<(const Point& c) const {
00015     return ((x != c.x) ? (x < c.x) : (y < c.y));
00016   }
00017   Point() : x(-1), y(-1) { }
00018 };
00019 
00020 class PointList {
00021 public:
00022   PointList();
00023   ~PointList();
00024 
00025   void AddPoint(Point); // Adds the point to the list.
00026   void RemovePoint(Point); // Removes the point from the list
00027   bool PointExists(Point); // Returns if the point is in the list
00028   void Clear(); // Clears all points from the list
00029 
00030   // Movement through the list via internal index
00031   Point FirstPoint(); // Moves to and returns the first point in the list.
00032   Point NextPoint(); // Moves forward in the list and then returns the current point.
00033   Point PeekNextPoint(); // Returns the next point, without moving forward.
00034   Point CurrentPoint(); // Returns the current point in the list.
00035   Point IndexPoint(unsigned int i); // Moves to and returns the point at index i in the list. (0 based)
00036   Point GotoPoint(Point p); // Moves to and returns the point at point p in the list.
00037   Point PrevPoint(); // Moves backward in the list and then returns the current point.
00038   Point PeekPrevPoint(); // Returns the previous point, without moving backward.
00039   Point LastPoint(); // Moves to and returns the last point in the list.
00040 
00041 
00042   // Movement through the list through iterator
00043   std::vector<Point>::iterator BeginPoint(); // Returns an iterator to the first point in the list.
00044   std::vector<Point>::iterator NthPoint(unsigned int n); // Returns an iterator to the Nth point in the list. (0 based)
00045   std::vector<Point>::iterator EndPoint(); // Returns an iterator to the last point in the list.
00046   unsigned int Size(); // Returns the number of points in the list.
00047 
00048   void AddRef() { }
00049   void Release() { }
00050 
00051   void Loop(bool loop);
00052 
00053 private:
00054   std::vector<Point> points;
00055   unsigned int index;
00056   bool loop; // Determine if it should loop back to the start (true), stop at the end (false)
00057 };