Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

SgNb8Iterator Class Reference

Iterator over all 8 neighbor points. More...

#include <SgNbIterator.h>

List of all members.

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]

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 128 of file SgNbIterator.h.


Constructor & Destructor Documentation

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.


Member Function Documentation

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.

References m_next, m_p, and s_nb8.

void SgNb8Iterator::operator++ (  ) 

Advance the state of the iteration to the next element.

Definition at line 139 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 164 of file SgNbIterator.h.

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

Definition at line 166 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 168 of file SgNbIterator.h.

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


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


Sun Mar 13 2011 Doxygen 1.7.1