Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgNb8Iterator Class Reference

#include <SgNbIterator.h>

List of all members.


Detailed Description

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 132 of file 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.
SgNb8Iteratoroperator= (const SgNb8Iterator &)
 Not implemented.

Private Attributes

int m_next
SgPoint m_p

Static Private Attributes

static const int s_nb8 [8]


Constructor & Destructor Documentation

SgNb8Iterator::SgNb8Iterator ( SgPoint  p  ) 

Definition at line 135 of file SgNbIterator.h.

References SgPointUtil::InBoardRange(), and SG_ASSERT.

SgNb8Iterator::SgNb8Iterator ( const SgNb8Iterator  )  [private]

Not implemented.


Member Function Documentation

static int SgNb8Iterator::Direction ( int  i  )  [static]

Definition at line 161 of file SgNbIterator.h.

References s_nb8, and SG_ASSERTRANGE.

SgPoint SgNb8Iterator::operator * (  )  const

Return the value of the current element.

Definition at line 150 of file SgNbIterator.h.

References m_next, m_p, and s_nb8.

SgNb8Iterator::operator bool (  )  const

Return true if iteration is valid, otherwise false.

Definition at line 156 of file SgNbIterator.h.

References m_next.

void SgNb8Iterator::operator++ (  ) 

Advance the state of the iteration to the next element.

Definition at line 143 of file SgNbIterator.h.

References m_next, and SG_ASSERT.

SgNb8Iterator& SgNb8Iterator::operator= ( const SgNb8Iterator  )  [private]

Not implemented.


Member Data Documentation

int SgNb8Iterator::m_next [private]

Definition at line 168 of file SgNbIterator.h.

Referenced by operator *(), operator bool(), and operator++().

SgPoint SgNb8Iterator::m_p [private]

Definition at line 170 of file SgNbIterator.h.

Referenced by operator *().

const int SgNb8Iterator::s_nb8 [static, private]

Initial value:

 {
    -SG_NS - SG_WE,
    -SG_NS,
    -SG_NS + SG_WE,
    -SG_WE,
    +SG_WE,
    +SG_NS - SG_WE,
    +SG_NS,
    +SG_NS + SG_WE
}

Definition at line 172 of file SgNbIterator.h.

Referenced by Direction(), and operator *().


The documentation for this class was generated from the following files:


17 Jun 2010 Doxygen 1.4.7