Protected Attributes | List of all members
cwchess::MoveIterator Class Reference

Non-mutable iterator over all moves of a given chess piece. More...

#include <MoveIterator.h>

Inheritance diagram for cwchess::MoveIterator:
Inheritance graph

Public Member Functions

 MoveIterator (void)
 Construct a one-past-the-end MoveIterator. More...
 MoveIterator (MoveIterator const& iter)
 MoveIterator (ChessPosition const* chess_position, Index const& index)
 Construct a fully initialized MoveIterator. More...
Assignment operator
MoveIterator&  operator= (MoveIterator const& iter)
 Assignment operator.
Comparision operators
bool operator== (MoveIterator const& iter) const
bool operator!= (MoveIterator const& iter) const
Move const&  operator* () const
Move const*  operator-> (void) const
Increment and decrement operators
MoveIterator&  operator++ ()
MoveIterator operator++ (int)
MoveIterator&  operator-- ()
MoveIterator operator-- (int)

Protected Attributes

ChessPosition const*  M_chess_position
 The underlaying chess position.
BitBoard M_targets
 The targets that this piece can move to.
Move M_current_move
 The actual move that is returned when dereferenced.

Detailed Description

Non-mutable iterator over all moves of a given chess piece.

This iterator generates the Move objects while advancing to the next move, storing the result in a member variable. The lifetime of the reference or pointer to the Move is therefore equal to the lifetime of the iterator: calling the increment or decrement operators overwrites the previous move.

Usage example:

for (MoveIterator move_iter = chess_position.move_begin(index); move_iter != chess_position.move_end(); ++move_iter)
Move const& move(*move_iter);
// Use 'move'.

Definition at line 63 of file MoveIterator.h.

Constructor & Destructor Documentation

cwchess::MoveIterator::MoveIterator ( void  )

Construct a one-past-the-end MoveIterator.

See also

Definition at line 78 of file MoveIterator.h.

Referenced by MoveIterator().

cwchess::MoveIterator::MoveIterator ( ChessPosition const*   chess_position,
Index const&   index 

Construct a fully initialized MoveIterator.

chess_position: The ChessPosition that we're generating moves for.
index: The index of the piece that we're generating moves for.
See also
ChessPosition::move_begin(Index const&)

Definition at line 34 of file MoveIterator.inl.

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

Copyright © 2006 - 2010 Carlo Wood.  All rights reserved.