msmazes::NBitPattern<> Class Template Reference
[Core Pattern Layer]

#include <msmazes/core/pattern/n_bit.hpp>

List of all members.


Detailed Description

template<>
class msmazes::NBitPattern<>

A Pattern whose cells are bitsets. All cells have the same number of bits, though this number is configurable during initialization. Two cells are connected to each other if and only if exactly one bit differs between them. The index of the bit in the cells is treated as the direction from each of the cells to the other. The entrance and exit cells have additional constraints; each is allowed exactly one connection only, dictated by the directional parameters; furthermore, they cannot be directly connected to each other.

     msmazes::NBitPattern pattern;
     pattern.initialize(
         msmazes::init_bit_count_arg = 4
       , msmazes::init_entrance_cell_arg = 0
       , msmazes::init_exit_cell_arg = 15
       , msmazes::init_entrance_direction_arg = 1
       , msmazes::init_exit_direction_arg = 3
     );
 

The code above will yield the following cells and their connections in adjacency list notation:

     0000 <--> 0010
     0001 <--> 0011 0101 1001
     0010 <--> 0000 0011 0110 1010
     0011 <--> 0001 0010 0111 1011
     0100 <--> 0101 0110 1100
     0101 <--> 0001 0100 0111 1101
     0110 <--> 0010 0100 0111 1110
     0111 <--> 0011 0101 0110 1111
     1000 <--> 1001 1010 1100
     1001 <--> 0001 1000 1011 1101
     1010 <--> 0010 1000 1011 1110
     1011 <--> 0011 1001 1010
     1100 <--> 0100 1000 1101 1110
     1101 <--> 0101 1001 1100
     1110 <--> 0110 1010 1100
     1111 <--> 0111
 

All programs using this class template must define BOOST_PARAMETER_MAX_ARITY as 5 or more.


Template parameters

Parameter Description Default
CellContainerSelector The type that will represent whether the cell container is a std::vector (in which case this type is boost::vecS) or a std::deque (in which case this type is boost::dequeS). boost::vecS
Block The integer type in which the bits of each cell are stored. unsigned long
Allocator The allocator type used for memory management of each cell. std::allocator<Block>


Model of


Type requirements



Public Types

typedef implementation_defined Cell
typedef implementation_defined CellEqualityPolicy
typedef implementation_defined Graph
typedef implementation_defined CellIndex
typedef implementation_defined EdgeDirectedCategory
typedef implementation_defined Direction
typedef implementation_defined OutDegree
typedef implementation_defined HasIndexableEndpointCells

Public Member Functions

 NBitPattern ()
 The default constructor.
virtual ~NBitPattern ()
 The destructor.
void initialize (const unsigned long init_bit_count_arg, const unsigned long init_entrance_cell_arg, const unsigned long init_exit_cell_arg, const unsigned long init_entrance_direction_arg, const unsigned long init_exit_direction_arg)
template<typename Params>
void initialize_with_named_params (Params &p)
const GraphgetGraph () const
CellIndex getCellCount () const
const CellgetCell (const CellIndex index) const
const CellgetEntranceCell () const
const CellgetSourceCell () const
const CellgetTargetCell () const
const CellgetExitCell () const
Direction getEdgeDirection (const CellIndex source_index, const CellIndex target_index) const
OutDegree getMaxOutDegree () const


Member Typedef Documentation

typedef implementation_defined msmazes::NBitPattern<>::Cell
 

The type of the objects to be connected together, as defined in the Pattern concept.

typedef implementation_defined msmazes::NBitPattern<>::CellEqualityPolicy
 

The type of the function object that determines equality between any two cells, as defined in the Pattern concept.

typedef implementation_defined msmazes::NBitPattern<>::Graph
 

The type of the underlying object that represents the manner in which the cells are connected together, as defined in the Pattern concept.

typedef implementation_defined msmazes::NBitPattern<>::CellIndex
 

An unsigned integral type for representing either the index of a cell or the number of such cells, as defined in the Pattern concept.

typedef implementation_defined msmazes::NBitPattern<>::EdgeDirectedCategory
 

The type that represents whether the edges in the underlying graph are undirected, directed, or bidirectional, as defined in the Pattern concept.

typedef implementation_defined msmazes::NBitPattern<>::Direction
 

The type that represents the course or bearing that is followed when traversing an edge in the underlying graph, as defined in the Pattern concept.

typedef implementation_defined msmazes::NBitPattern<>::OutDegree
 

The type that represents the number of edges from a source vertex in the underlying graph, as defined in the Pattern concept.

typedef implementation_defined msmazes::NBitPattern<>::HasIndexableEndpointCells
 

The type that indicates that the entrance and exit cells are indexable, as defined in the Pattern concept.


Constructor & Destructor Documentation

msmazes::NBitPattern<>::NBitPattern  )  [inline]
 

Constructs a new NBitPattern. Remember to use initialize() to build the underlying structure!

virtual msmazes::NBitPattern<>::~NBitPattern  )  [inline, virtual]
 

Destroys this NBitPattern.


Member Function Documentation

void msmazes::NBitPattern<>::initialize const unsigned long  init_bit_count_arg,
const unsigned long  init_entrance_cell_arg,
const unsigned long  init_exit_cell_arg,
const unsigned long  init_entrance_direction_arg,
const unsigned long  init_exit_direction_arg
 

Initializes this NBitPattern. Violation of the specified preconditions will result in either compile-time errors or failed assertions unless otherwise noted.

Parameter Name Description Preconditions Default
init_bit_count_arg The number of bits contained in each cell.
  • init_bit_count_arg < sizeof(Block) (This limitation is imposed by the implementation; in practice, even a low bit count of 6 can result in a maze of ample difficulty.)
init_entrance_cell_arg The value of the entrance cell.
  • init_entrance_cell_arg < ( 1 << init_bit_count_arg )
init_exit_cell_arg The value of the exit cell.
  • init_exit_cell_arg < ( 1 << init_bit_count_arg )
  • ( init_entrance_cell_arg != init_exit_cell_arg )
  • The entrance and exit cells cannot be directly connected to each other.
init_entrance_direction_arg The index of the bit that differs between the entrance and source cells.
  • ( init_entrance_direction_arg < init_bit_count_arg )
init_exit_direction_arg The index of the bit that differs between the target and exit cells.
  • ( init_exit_direction_arg < init_bit_count_arg )

You can also pass the arguments by name. (In this case, it is recommended that you do so; otherwise, the arguments may be indistinguishable from each other.) Use the parameter table above to look up the parameter names. Remember that each parameter name resides in the msmazes namespace.

template<typename Params>
void msmazes::NBitPattern<>::initialize_with_named_params Params &  p  )  [inline]
 

Initializes this NBitPattern via the specified Argument Pack object. See the initialize() function documentation for acceptable parameters.

const Graph& msmazes::NBitPattern<>::getGraph  )  const [inline]
 

Returns a const reference to the underlying object that represents the manner in which the cells are connected together in this NBitPattern, as defined in the Pattern concept.

CellIndex msmazes::NBitPattern<>::getCellCount  )  const [inline]
 

Returns the number of cells in this NBitPattern, as defined in the Pattern concept.

const Cell& msmazes::NBitPattern<>::getCell const CellIndex  index  )  const [inline]
 

Returns a const reference to the cell in this NBitPattern to which the specified index refers, as defined in the Pattern concept.

const Cell& msmazes::NBitPattern<>::getEntranceCell  )  const [inline]
 

Returns a const reference to the entrance cell in the solution path of an overlying maze, as defined in the Pattern concept.

const Cell& msmazes::NBitPattern<>::getSourceCell  )  const [inline]
 

Returns a const reference to the cell that topologically follows the entrance cell in the solution path of an overlying maze, as defined in the Pattern concept.

const Cell& msmazes::NBitPattern<>::getTargetCell  )  const [inline]
 

Returns a const reference to the cell that topologically precedes the exit cell in the solution path of an overlying maze, as defined in the Pattern concept.

const Cell& msmazes::NBitPattern<>::getExitCell  )  const [inline]
 

Returns a const reference to the exit cell in the solution path of an overlying maze, as defined in the Pattern concept.

Direction msmazes::NBitPattern<>::getEdgeDirection const CellIndex  source_index,
const CellIndex  target_index
const [inline]
 

Returns a representation of the course or bearing that is followed when traversing the corresponding edge in the underlying graph, as defined in the Pattern concept.

OutDegree msmazes::NBitPattern<>::getMaxOutDegree  )  const [inline]
 

Returns the maximum number of edges from any source vertex in the underlying graph, as defined in the Pattern concept.


Multi-State Mazes in C++ is hosted by SourceForge.net. Use the Table of Contents for navigation.