Iterator over all 8 neighbor points. More...
#include <SgNbIterator.h>
Public Member Functions | |
SgNb8Iterator (SgPoint p) | |
void | operator++ () |
Advance the state of the iteration to the next element. | |
SgPoint | operator* () const |
Return the value of the current element. | |
operator bool () const | |
Return true if iteration is valid, otherwise false. | |
Static Public Member Functions | |
static int | Direction (int i) |
Private Member Functions | |
SgNb8Iterator (const SgNb8Iterator &) | |
Not implemented. | |
SgNb8Iterator & | operator= (const SgNb8Iterator &) |
Not implemented. | |
Private Attributes | |
int | m_next |
SgPoint | m_p |
Static Private Attributes | |
static const int | s_nb8 [8] |
Iterator over all 8 neighbor points.
Iterates in sorted order. Does not filter points off board, that would need access to current board
Produces the neighbors of a point in all eight compass directions, in numerically ascending order. Directions 1, 3, 4 and 6 are vertical/horizontal, other are diagonal.
0 1 2 \ | / 3 -p- 4 e.g. next[1] = -NS / | \ 5 6 7
Definition at line 128 of file SgNbIterator.h.
SgNb8Iterator::SgNb8Iterator | ( | SgPoint | p | ) |
Definition at line 131 of file SgNbIterator.h.
References SgPointUtil::InBoardRange(), and SG_ASSERT.
SgNb8Iterator::SgNb8Iterator | ( | const SgNb8Iterator & | ) | [private] |
Not implemented.
static int SgNb8Iterator::Direction | ( | int | i | ) | [static] |
Definition at line 157 of file SgNbIterator.h.
References s_nb8, and SG_ASSERTRANGE.
SgNb8Iterator::operator bool | ( | ) | const |
Return true if iteration is valid, otherwise false.
Definition at line 152 of file SgNbIterator.h.
References m_next.
SgPoint SgNb8Iterator::operator* | ( | ) | const |
Return the value of the current element.
Definition at line 146 of file SgNbIterator.h.
void SgNb8Iterator::operator++ | ( | ) |
Advance the state of the iteration to the next element.
Definition at line 139 of file SgNbIterator.h.
SgNb8Iterator& SgNb8Iterator::operator= | ( | const SgNb8Iterator & | ) | [private] |
Not implemented.
int SgNb8Iterator::m_next [private] |
Definition at line 164 of file SgNbIterator.h.
Referenced by operator bool(), operator*(), and operator++().
SgPoint SgNb8Iterator::m_p [private] |
Definition at line 166 of file SgNbIterator.h.
Referenced by operator*().
const int SgNb8Iterator::s_nb8 [static, private] |
Definition at line 168 of file SgNbIterator.h.
Referenced by Direction(), and operator*().