Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

FinderField Class Reference

Inheritance diagram for FinderField:

Inheritance graph
[legend]
Collaboration diagram for FinderField:

Collaboration graph
[legend]

Detailed Description

Array of closed nodes used for finding.

Definition at line 11 of file FinderField.h.

Public Member Functions

 FinderField (int w, int h)
 Two dimensional array of booleans.
virtual ~FinderField ()
void reset ()
 Erase all marks.
void markClosed (const V2 &loc)
 Mark given place as closed.
bool isClosed (const V2 &loc) const
 Returns true when place is closed.


Constructor & Destructor Documentation

FinderField::FinderField int  w,
int  h
 

Two dimensional array of booleans.

Definition at line 19 of file FinderField.cpp.

00020 {
00021     m_w = w;
00022     m_h = h;
00023 
00024     //NOTE: [y][x] indexes
00025     m_closed = new bool*[m_h];
00026     for (int y = 0; y < m_h; ++y) {
00027         m_closed[y] = new bool[m_w];
00028         memset(m_closed[y], false, sizeof(bool) * m_w);
00029     }
00030 }

FinderField::~FinderField  )  [virtual]
 

Definition at line 32 of file FinderField.cpp.

00033 {
00034     for (int y = 0; y < m_h; ++y) {
00035         delete[] m_closed[y];
00036     }
00037     delete[] m_closed;
00038 }


Member Function Documentation

bool FinderField::isClosed const V2 loc  )  const
 

Returns true when place is closed.

NOTE: all places outside array are marked as closed

Definition at line 70 of file FinderField.cpp.

00071 {
00072     int x = loc.getX();
00073     int y = loc.getY();
00074 
00075     bool result = true;
00076     if ((0 <= x && x < m_w) && (0 <= y && y < m_h)) {
00077         result = m_closed[y][x];
00078     }
00079     return result;
00080 }

void FinderField::markClosed const V2 loc  ) 
 

Mark given place as closed.

Definition at line 55 of file FinderField.cpp.

00056 {
00057     int x = loc.getX();
00058     int y = loc.getY();
00059 
00060     if ((0 <= x && x < m_w) && (0 <= y && y < m_h)) {
00061         m_closed[y][x] = true;
00062     }
00063 }

void FinderField::reset  ) 
 

Erase all marks.

Definition at line 44 of file FinderField.cpp.

00045 {
00046     for (int y = 0; y < m_h; ++y) {
00047         memset(m_closed[y], false, sizeof(bool) * m_w);
00048     }
00049 }


The documentation for this class was generated from the following files:
Generated on Wed Jun 1 09:55:06 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2