Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

BoardIterator Class Reference

Iterates on an array of HexPoints. More...

#include <BoardIterator.hpp>

Inheritance diagram for BoardIterator:
SafeBool< BoardIterator >

List of all members.

Public Member Functions

 BoardIterator ()
 Empty iterator.
 ~BoardIterator ()
 Destructor.
 BoardIterator (const HexPoint *start)
 Iterates over the vector of points begining with start.
 BoardIterator (const std::vector< HexPoint > &start)
 Iterates over the vector of points.
HexPoint operator* () const
 Returns the HexPoint at the current location.
BoardIteratoroperator++ ()
 Move to the next point in the list.
bool boolean_test () const
 Used by the SafeBool Idiom.
 operator bool_type () const

Protected Types

typedef void(SafeBool::* bool_type )() const

Protected Member Functions

void this_type_does_not_support_comparisons () const

Protected Attributes

const HexPointm_point

Detailed Description

Iterates on an array of HexPoints.

The array must end with INVALID_POINT, otherwise BoardIterator will just keep on truckin'.

BoardIterator implements the bool operator, so we can do stuff like this:

 for (BoardIterator i(brd.cells()); i; ++i) {...} 

(note the "i" test for validity). operator bool() returns false if the iterator is currently pointing at INVALID_POINT and true otherwise.

Because BoardIterator uses operator bool(), comparisons like

  if (x == y) 

will do very different things that you would think. To disallow iterator comparisons like the above (instead use

 if (*x == *y) 

), we have employed the Safe Bool Idiom. Comparing two BoardIterators will result in a compilation error.

Definition at line 37 of file BoardIterator.hpp.


Member Typedef Documentation

typedef void(SafeBool::* SafeBool< BoardIterator >::bool_type)() const [protected, inherited]

Definition at line 22 of file SafeBool.hpp.


Constructor & Destructor Documentation

BoardIterator::BoardIterator (  )  [inline]

Empty iterator.

Definition at line 67 of file BoardIterator.hpp.

BoardIterator::~BoardIterator (  )  [inline]

Destructor.

Definition at line 82 of file BoardIterator.hpp.

BoardIterator::BoardIterator ( const HexPoint start  )  [inline]

Iterates over the vector of points begining with start.

Definition at line 72 of file BoardIterator.hpp.

BoardIterator::BoardIterator ( const std::vector< HexPoint > &  start  )  [inline]

Iterates over the vector of points.

Definition at line 77 of file BoardIterator.hpp.


Member Function Documentation

bool BoardIterator::boolean_test (  )  const [inline]

Used by the SafeBool Idiom.

Definition at line 91 of file BoardIterator.hpp.

References INVALID_POINT, and m_point.

SafeBool< BoardIterator >::operator bool_type (  )  const [inline, inherited]

Definition at line 26 of file SafeBool.hpp.

HexPoint BoardIterator::operator* (  )  const [inline]

Returns the HexPoint at the current location.

Definition at line 86 of file BoardIterator.hpp.

References m_point.

BoardIterator & BoardIterator::operator++ (  )  [inline]

Move to the next point in the list.

Incrementing past an INVALID_POINT gives undefined behavoir.

Definition at line 96 of file BoardIterator.hpp.

References m_point.

void SafeBool< BoardIterator >::this_type_does_not_support_comparisons (  )  const [inline, protected, inherited]

Definition at line 23 of file SafeBool.hpp.


Member Data Documentation

const HexPoint* BoardIterator::m_point [protected]

Definition at line 64 of file BoardIterator.hpp.

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


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


6 Jan 2011 Doxygen 1.6.3