寻路基本工具类定义 Path.h

 1 #ifndef __PATH__H
 2 #define __PATH__H
 3 
 4 #include <list>
 5 #include "Point.h"
 6 
 7 class Path
 8 {
 9 public:
10     typedef std::list<PointI> PathList;
11     typedef PathList::const_iterator Iterator;
12 public:
13     Path():m_find(false),m_step(0),m_dis(0.0f){}
14     Path(bool find, float dis):m_find(find),m_step(0),m_dis(dis){}
15     explicit Path(const Path &path)
16     {
17         m_find = path.m_find;
18         m_step = path.m_step;
19         m_dis = path.m_dis;
20         Iterator iter;
21         for(iter = path.m_path.begin(); iter != path.m_path.end(); ++iter)
22         {
23             m_path.push_back(*iter);
24         }
25     }
26     inline void push_back(PointI point){m_path.push_back(point);m_step += 1;}
27     inline void push_front(PointI point){m_path.push_front(point);m_step += 1;}
28     inline void setDis(float dis){m_dis = dis;}
29 
30     inline bool getFind()const{return m_find;}
31     inline int getStep()const{return m_step;}
32     inline float getDis()const{return m_dis;}
33     inline Iterator begin(){return m_path.begin();}
34     inline Iterator end(){return m_path.end();}
35 public:
36     bool    m_find;
37     int        m_step;
38     float   m_dis;
39 private:
40     PathList m_path;
41 };
42 
43 #endif

 

posted @ 2013-11-23 01:20  liusijian  阅读(315)  评论(0编辑  收藏  举报