Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Movements Class Reference

This class represents a sequence of moves. More...

#include <movements.h>

List of all members.

Public Methods

 Movements ()
 Movements (std::vector< Move > const &moves)
 Movements (QDataStream &stream)
 Movements (QPoint keeper_start, QStringList &lines)
bool isEmpty () const
int numberOfMoves () const
void setToFirstPosition ()
void setToLastPosition ()
bool hasNextMove () const
Move peekNextMove () const
Move nextMove ()
bool hasPrevMove () const
Move peekPrevMove () const
Move prevMove ()
Move const & move (int index) const
void addMove (Move const &move)
void addMovements (Movements const &moves)
void truncateToCurrent ()
int movePointer () const
void setMovePointer (int move_pointer)
void reverse ()
Movements gemMovesToKeeperMoves (QPoint const &keeper, bool retro_mode=false) const
QString toText () const
void writeToStream (QDataStream &stream) const
int moves () const
int pushes () const
int linearPushes () const
int gemChanges () const
bool operator== (Movements const &other_moves) const
bool operator!= (Movements const &other_moves) const

Private Attributes

std::vector< Move > m_moves
size_t m_pos

Static Private Attributes

QRegExp s_moves_regexp


Detailed Description

This class represents a sequence of moves.

You can use this class in the spirit of a bidirectional iterator or a vector.

Author:
Ralf Schmelter (ralfs@pc2a.chemie.uni-dortmund.de).
Version:
0.1
See also:
move


Constructor & Destructor Documentation

Movements::Movements (  ) 
 

Creates an empty Movements object.

Movements::Movements (  std::vector< Move > const & moves ) 
 

Constructs the object with the given moves.

The move pointer points to the first move.

Parameters:
moves   A vector containing the moves.

Movements::Movements (  QDataStream & stream ) 
 

Constructs the object from a data stream.

The move pointer points to the first move.

Parameters:
stream   The stream to use.

Movements::Movements (  QPoint keeper_start,
QStringList & lines
) 
 

Constructs the movements from lines in sokogen format.

Removes all lines from the QStringList, which were taken for building up the moves.

Parameters:
keeper_start   The start position of the keeper.
lines   The lines holding the moves.


Member Function Documentation

void Movements::addMove (  Move const & move ) 
 

Adds a move.

If the next move and the move to add are identical, nothing happens, apart from the fact, the we jump to the next move. If not, the added move is also the last move.

Parameters:
move   The move to add.

void Movements::addMovements (  Movements const & moves ) 
 

Adds moves.

The last move of the added move is also the last move.

Parameters:
move   The moves to add.

int Movements::gemChanges (  )  const
 

Returns the number of gem changes (the number of times a different gem has been pushed).

Movements Movements::gemMovesToKeeperMoves (  QPoint const & keeper,
bool retro_mode = false
)  const
 

Converts a sequence of gems moves to a sequence of keeper moves.

This assumes, the current moves are gem moves (holding the positions of the moves gem instead of the keeper).

Note that the moves must be atomic!

Parameters:
keeper   The start position of the keeper.
retro_mode   If true, we are in retro mode.

bool Movements::hasNextMove (  )  const
 

Returns true, if there is a next move.

bool Movements::hasPrevMove (  )  const
 

Returns true, if there is a previous move.

bool Movements::isEmpty (  )  const
 

Returns true, if there are no moves.

int Movements::linearPushes (  )  const
 

Returns the number of linear pushes.

Move const& Movements::move (  int index )  const
 

Returns the move with the given index.

Parameters:
index   The index of the move.

int Movements::movePointer (  )  const
 

Returns the move pointer as an index.

int Movements::moves (  )  const
 

Returns the number of moves.

Move Movements::nextMove (  ) 
 

Returns the next move and increments the move pointer.

This allows you traverse the movements forwards.

int Movements::numberOfMoves (  )  const
 

The number of moves.

bool Movements::operator!= (  Movements const & other_moves )  const
 

Return true, if two movements are different.

bool Movements::operator== (  Movements const & other_moves )  const
 

Return false, if two movements are different.

Move Movements::peekNextMove (  )  const
 

Returns the next move, but unlike nextMove() does not changes the move pointer.

Move Movements::peekPrevMove (  )  const
 

Returns the previous move, but unlike prevMove() does not changes the move pointer.

Move Movements::prevMove (  ) 
 

Returns the previous move and decrements the move pointer.

This allows you traverse the movements backwards.

int Movements::pushes (  )  const
 

Returns the number of pushes.

void Movements::reverse (  ) 
 

Reverses the moves.

The last move is the first move and so on.

Note that the moves itself are the same (so from() of the first move will be from() of the last move).

void Movements::setMovePointer (  int move_pointer ) 
 

Sets the mover pointer.

The pointer must be in the range [0:numberOfMoves()[.

Parameters:
move_pointer   The new move pointer.

void Movements::setToFirstPosition (  ) 
 

Sets the move pointer to the first move.

This means, that hasPrevMove() will return false after this call.

void Movements::setToLastPosition (  ) 
 

Sets the move pointer to the last move.

This means, that hasNextMove() will return false after this call.

QString Movements::toText (  )  const
 

Returns a sokogen compatible form of the moves.

Note that all moves must be atomic.

void Movements::truncateToCurrent (  ) 
 

Truncates the movements up to the current move.

This means, hasNextMove() will return false.

void Movements::writeToStream (  QDataStream & stream )  const
 

Writes the movements to a stream.

Parameters:
stream   The stream to use.


Member Data Documentation

std::vector<Move> Movements::m_moves [private]
 

The movements.

size_t Movements::m_pos [private]
 

The pointer to the next move.

QRegExp Movements::s_moves_regexp [static, private]
 

The regexp for a valid sokogen moves lines.


The documentation for this class was generated from the following file:
Generated at Sun Jan 6 18:49:12 2002 for EasySok by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001