Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgSortedMoves< MOVE, VALUE, SIZE > Class Template Reference

#include <SgSortedMoves.h>

List of all members.


Detailed Description

template<typename MOVE, typename VALUE, int SIZE>
class SgSortedMoves< MOVE, VALUE, SIZE >

Small array with moves sorted by their value.

Definition at line 21 of file SgSortedMoves.h.

Public Member Functions

 SgSortedMoves (int maxNuMoves)
void CheckOverflow ()
void Clear ()
void DeleteEqual ()
 delete all but one of equal-valued moves
void Delete (int index)
 Delete move at index.
void Insert (const MOVE &move, VALUE value)
 Insert move with given value in table.
bool GetMove (const MOVE &move, VALUE &value, int &index) const
void GetMoves (SgVector< MOVE > *moves) const
void SetMinValue (const MOVE &move, VALUE value)
 If move in table: increase its value.
void SetMove (int i, const MOVE &move)
void SetValue (int i, VALUE value)
void SetMaxMoves (int nu)
 Adjust number of moves: throw out all moves whose value has become less than the value of m_move[m_maxNuMoves - 1].
void SetMaxNuMoves (int max)
 Limit number of moves.
void SetLowerBound (VALUE bound)
 Lower bound for accepting moves.
void SetInitLowerBound (VALUE bound)
 See m_initLowerBound.
int LowerBound () const
int NuMoves () const
int MaxNuMoves () const
const MOVE & Move (int i) const
 Get move at given index i.
const MOVE & BestMove () const
 The best move is sorted first in the table.
VALUE Value (int i) const
VALUE BestValue () const
void DecNuMoves ()
void AssertIndexRange (int i) const
 Assert i is an index within the table.
void Shuffle ()
 randomly shuffle all the moves of equal value.

Static Public Attributes

static const bool CHECKMOVES = SG_CHECK
 check move table before and after each operation

Private Member Functions

void CheckMoves () const
void ShuffleInterval (int from, int to)
 Randomly shuffle all moves in interval.

Private Attributes

int m_maxNuMoves
int m_nuMoves
VALUE m_lowerBound
 Lower bound for accepting moves.
VALUE m_initLowerBound
 Initial value of m_lowerBound after a Clear().
bool m_checkOverflow
bool m_considerEqual
MOVE m_move [SIZE]
VALUE m_value [SIZE]


Constructor & Destructor Documentation

template<typename MOVE, typename VALUE, int SIZE>
SgSortedMoves< MOVE, VALUE, SIZE >::SgSortedMoves ( int  maxNuMoves  )  [explicit]

Definition at line 160 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::Clear(), and SG_ASSERT.


Member Function Documentation

template<typename MOVE, typename VALUE, int SIZE>
void SgSortedMoves< MOVE, VALUE, SIZE >::AssertIndexRange ( int  i  )  const

Assert i is an index within the table.

Definition at line 118 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, SG_ASSERTRANGE, and SG_DEBUG_ONLY.

Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::Move(), SgSortedMoves< MOVE, VALUE, SIZE >::SetMove(), SgSortedMoves< MOVE, VALUE, SIZE >::SetValue(), SgSortedMoves< MOVE, VALUE, SIZE >::ShuffleInterval(), and SgSortedMoves< MOVE, VALUE, SIZE >::Value().

template<typename MOVE, typename VALUE, int SIZE>
const MOVE& SgSortedMoves< MOVE, VALUE, SIZE >::BestMove (  )  const

The best move is sorted first in the table.

Definition at line 98 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::Move().

template<typename MOVE, typename VALUE, int SIZE>
VALUE SgSortedMoves< MOVE, VALUE, SIZE >::BestValue (  )  const

Definition at line 104 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_value, and SG_ASSERT.

template<typename MOVE, typename VALUE, int SIZE>
void SgSortedMoves< MOVE, VALUE, SIZE >::CheckMoves (  )  const [private]

Definition at line 220 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::m_lowerBound, SgSortedMoves< MOVE, VALUE, SIZE >::m_maxNuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_value, and SG_ASSERT.

Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), and SgSortedMoves< MOVE, VALUE, SIZE >::Insert().

template<typename MOVE, typename VALUE, int SIZE>
void SgSortedMoves< MOVE, VALUE, SIZE >::CheckOverflow (  ) 

Definition at line 30 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::m_checkOverflow.

template<typename MOVE, typename VALUE, int SIZE>
void SgSortedMoves< MOVE, VALUE, SIZE >::Clear (  ) 

Definition at line 170 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::m_initLowerBound, SgSortedMoves< MOVE, VALUE, SIZE >::m_lowerBound, SgSortedMoves< MOVE, VALUE, SIZE >::m_maxNuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, and SG_ASSERT.

Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::SgSortedMoves().

template<typename MOVE, typename VALUE, int SIZE>
void SgSortedMoves< MOVE, VALUE, SIZE >::DecNuMoves (  ) 

Definition at line 111 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, and SG_ASSERT.

template<typename MOVE, typename VALUE, int SIZE>
void SgSortedMoves< MOVE, VALUE, SIZE >::Delete ( int  index  ) 

Delete move at index.

Shift remaining moves forward and adjust lower bound if necessary.

Definition at line 179 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::CheckMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::CHECKMOVES, SgSortedMoves< MOVE, VALUE, SIZE >::m_initLowerBound, SgSortedMoves< MOVE, VALUE, SIZE >::m_lowerBound, SgSortedMoves< MOVE, VALUE, SIZE >::m_maxNuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_move, SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_value, and SG_ASSERT.

Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::DeleteEqual(), and SgSortedMoves< MOVE, VALUE, SIZE >::SetMinValue().

template<typename MOVE, typename VALUE, int SIZE>
void SgSortedMoves< MOVE, VALUE, SIZE >::DeleteEqual (  ) 

delete all but one of equal-valued moves

Definition at line 202 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), SgRandom::Global(), SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_value, and SG_ASSERT.

template<typename MOVE, typename VALUE, int SIZE>
bool SgSortedMoves< MOVE, VALUE, SIZE >::GetMove ( const MOVE &  move,
VALUE &  value,
int &  index 
) const

Definition at line 286 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::m_move, SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, and SgSortedMoves< MOVE, VALUE, SIZE >::m_value.

Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::SetMinValue().

template<typename MOVE, typename VALUE, int SIZE>
void SgSortedMoves< MOVE, VALUE, SIZE >::GetMoves ( SgVector< MOVE > *  moves  )  const

Definition at line 331 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::m_move, and SgVector< T >::PushBack().

template<typename MOVE, typename VALUE, int SIZE>
void SgSortedMoves< MOVE, VALUE, SIZE >::Insert ( const MOVE &  move,
VALUE  value 
)

Insert move with given value in table.

Update m_nuMoves, m_lowerBound of table if necessary.

Definition at line 234 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::CheckMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::CHECKMOVES, SgSortedMoves< MOVE, VALUE, SIZE >::m_checkOverflow, SgSortedMoves< MOVE, VALUE, SIZE >::m_considerEqual, SgSortedMoves< MOVE, VALUE, SIZE >::m_lowerBound, SgSortedMoves< MOVE, VALUE, SIZE >::m_maxNuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_move, SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_value, and SG_ASSERT.

Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::SetMinValue().

template<typename MOVE, typename VALUE, int SIZE>
int SgSortedMoves< MOVE, VALUE, SIZE >::LowerBound (  )  const

Definition at line 86 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::m_lowerBound.

template<typename MOVE, typename VALUE, int SIZE>
int SgSortedMoves< MOVE, VALUE, SIZE >::MaxNuMoves (  )  const

Definition at line 92 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::m_maxNuMoves.

template<typename MOVE, typename VALUE, int SIZE>
const MOVE& SgSortedMoves< MOVE, VALUE, SIZE >::Move ( int  i  )  const

Get move at given index i.

Definition at line 95 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::AssertIndexRange(), and SgSortedMoves< MOVE, VALUE, SIZE >::m_move.

Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::BestMove(), and operator<<().

template<typename MOVE, typename VALUE, int SIZE>
int SgSortedMoves< MOVE, VALUE, SIZE >::NuMoves (  )  const

Definition at line 89 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves.

Referenced by operator<<().

template<typename MOVE, typename VALUE, int SIZE>
void SgSortedMoves< MOVE, VALUE, SIZE >::SetInitLowerBound ( VALUE  bound  ) 

See m_initLowerBound.

Definition at line 83 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::m_initLowerBound.

template<typename MOVE, typename VALUE, int SIZE>
void SgSortedMoves< MOVE, VALUE, SIZE >::SetLowerBound ( VALUE  bound  ) 

Lower bound for accepting moves.

Definition at line 80 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::m_lowerBound.

template<typename MOVE, typename VALUE, int SIZE>
void SgSortedMoves< MOVE, VALUE, SIZE >::SetMaxMoves ( int  nu  ) 

Adjust number of moves: throw out all moves whose value has become less than the value of m_move[m_maxNuMoves - 1].

Definition at line 365 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::m_considerEqual, SgSortedMoves< MOVE, VALUE, SIZE >::m_lowerBound, SgSortedMoves< MOVE, VALUE, SIZE >::m_maxNuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_value, and SgSortedMoves< MOVE, VALUE, SIZE >::SetMaxNuMoves().

template<typename MOVE, typename VALUE, int SIZE>
void SgSortedMoves< MOVE, VALUE, SIZE >::SetMaxNuMoves ( int  max  ) 

Limit number of moves.

Definition at line 357 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::m_maxNuMoves, and SG_ASSERT.

Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::SetMaxMoves().

template<typename MOVE, typename VALUE, int SIZE>
void SgSortedMoves< MOVE, VALUE, SIZE >::SetMinValue ( const MOVE &  move,
VALUE  value 
)

If move in table: increase its value.

otherwise insert (move,value)

Definition at line 338 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), SgSortedMoves< MOVE, VALUE, SIZE >::GetMove(), and SgSortedMoves< MOVE, VALUE, SIZE >::Insert().

template<typename MOVE, typename VALUE, int SIZE>
void SgSortedMoves< MOVE, VALUE, SIZE >::SetMove ( int  i,
const MOVE &  move 
)

Definition at line 58 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::AssertIndexRange(), and SgSortedMoves< MOVE, VALUE, SIZE >::m_move.

template<typename MOVE, typename VALUE, int SIZE>
void SgSortedMoves< MOVE, VALUE, SIZE >::SetValue ( int  i,
VALUE  value 
)

Definition at line 65 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::AssertIndexRange(), and SgSortedMoves< MOVE, VALUE, SIZE >::m_value.

template<typename MOVE, typename VALUE, int SIZE>
void SgSortedMoves< MOVE, VALUE, SIZE >::Shuffle (  ) 

randomly shuffle all the moves of equal value.

Definition at line 317 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_value, and SgSortedMoves< MOVE, VALUE, SIZE >::ShuffleInterval().

template<typename MOVE, typename VALUE, int SIZE>
void SgSortedMoves< MOVE, VALUE, SIZE >::ShuffleInterval ( int  from,
int  to 
) [private]

Randomly shuffle all moves in interval.

They must be of equal value

Definition at line 300 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::AssertIndexRange(), SgRandom::Global(), SgSortedMoves< MOVE, VALUE, SIZE >::m_move, SgSortedMoves< MOVE, VALUE, SIZE >::m_value, and SG_ASSERT.

Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::Shuffle().

template<typename MOVE, typename VALUE, int SIZE>
VALUE SgSortedMoves< MOVE, VALUE, SIZE >::Value ( int  i  )  const

Definition at line 101 of file SgSortedMoves.h.

References SgSortedMoves< MOVE, VALUE, SIZE >::AssertIndexRange(), and SgSortedMoves< MOVE, VALUE, SIZE >::m_value.

Referenced by operator<<().


Member Data Documentation

template<typename MOVE, typename VALUE, int SIZE>
const bool SgSortedMoves< MOVE, VALUE, SIZE >::CHECKMOVES = SG_CHECK [static]

check move table before and after each operation

Definition at line 25 of file SgSortedMoves.h.

Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), and SgSortedMoves< MOVE, VALUE, SIZE >::Insert().

template<typename MOVE, typename VALUE, int SIZE>
bool SgSortedMoves< MOVE, VALUE, SIZE >::m_checkOverflow [private]

Definition at line 141 of file SgSortedMoves.h.

Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::CheckOverflow(), and SgSortedMoves< MOVE, VALUE, SIZE >::Insert().

template<typename MOVE, typename VALUE, int SIZE>
bool SgSortedMoves< MOVE, VALUE, SIZE >::m_considerEqual [private]

Definition at line 144 of file SgSortedMoves.h.

Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::Insert(), and SgSortedMoves< MOVE, VALUE, SIZE >::SetMaxMoves().

template<typename MOVE, typename VALUE, int SIZE>
VALUE SgSortedMoves< MOVE, VALUE, SIZE >::m_initLowerBound [private]

Initial value of m_lowerBound after a Clear().

Definition at line 138 of file SgSortedMoves.h.

Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::Clear(), SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), and SgSortedMoves< MOVE, VALUE, SIZE >::SetInitLowerBound().

template<typename MOVE, typename VALUE, int SIZE>
VALUE SgSortedMoves< MOVE, VALUE, SIZE >::m_lowerBound [private]

Lower bound for accepting moves.

Definition at line 135 of file SgSortedMoves.h.

Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::CheckMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::Clear(), SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), SgSortedMoves< MOVE, VALUE, SIZE >::Insert(), SgSortedMoves< MOVE, VALUE, SIZE >::LowerBound(), SgSortedMoves< MOVE, VALUE, SIZE >::SetLowerBound(), and SgSortedMoves< MOVE, VALUE, SIZE >::SetMaxMoves().

template<typename MOVE, typename VALUE, int SIZE>
int SgSortedMoves< MOVE, VALUE, SIZE >::m_maxNuMoves [private]

Definition at line 129 of file SgSortedMoves.h.

Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::CheckMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::Clear(), SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), SgSortedMoves< MOVE, VALUE, SIZE >::Insert(), SgSortedMoves< MOVE, VALUE, SIZE >::MaxNuMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::SetMaxMoves(), and SgSortedMoves< MOVE, VALUE, SIZE >::SetMaxNuMoves().

template<typename MOVE, typename VALUE, int SIZE>
MOVE SgSortedMoves< MOVE, VALUE, SIZE >::m_move[SIZE] [private]

Definition at line 147 of file SgSortedMoves.h.

Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), SgSortedMoves< MOVE, VALUE, SIZE >::GetMove(), SgSortedMoves< MOVE, VALUE, SIZE >::GetMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::Insert(), SgSortedMoves< MOVE, VALUE, SIZE >::Move(), SgSortedMoves< MOVE, VALUE, SIZE >::SetMove(), and SgSortedMoves< MOVE, VALUE, SIZE >::ShuffleInterval().

template<typename MOVE, typename VALUE, int SIZE>
int SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves [private]

Definition at line 132 of file SgSortedMoves.h.

Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::AssertIndexRange(), SgSortedMoves< MOVE, VALUE, SIZE >::BestValue(), SgSortedMoves< MOVE, VALUE, SIZE >::CheckMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::Clear(), SgSortedMoves< MOVE, VALUE, SIZE >::DecNuMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), SgSortedMoves< MOVE, VALUE, SIZE >::DeleteEqual(), SgSortedMoves< MOVE, VALUE, SIZE >::GetMove(), SgSortedMoves< MOVE, VALUE, SIZE >::Insert(), SgSortedMoves< MOVE, VALUE, SIZE >::NuMoves(), and SgSortedMoves< MOVE, VALUE, SIZE >::Shuffle().

template<typename MOVE, typename VALUE, int SIZE>
VALUE SgSortedMoves< MOVE, VALUE, SIZE >::m_value[SIZE] [private]

Definition at line 150 of file SgSortedMoves.h.

Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::BestValue(), SgSortedMoves< MOVE, VALUE, SIZE >::CheckMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), SgSortedMoves< MOVE, VALUE, SIZE >::DeleteEqual(), SgSortedMoves< MOVE, VALUE, SIZE >::GetMove(), SgSortedMoves< MOVE, VALUE, SIZE >::Insert(), SgSortedMoves< MOVE, VALUE, SIZE >::SetMaxMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::SetValue(), SgSortedMoves< MOVE, VALUE, SIZE >::Shuffle(), SgSortedMoves< MOVE, VALUE, SIZE >::ShuffleInterval(), and SgSortedMoves< MOVE, VALUE, SIZE >::Value().


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


17 Jun 2010 Doxygen 1.4.7