MicroMouse Maze Library  3703225
公開型 | 公開メンバ関数 | 静的公開メンバ関数 | 静的公開変数類 | フレンド | 全メンバ一覧
MazeLib::Direction クラス

迷路上の方向を表す。 [詳解]

#include <Maze.h>

公開型

enum  AbsoluteDirection : int8_t {
  East , NorthEast , North , NorthWest ,
  West , SouthWest , South , SouthEast
}
 絶対方向の列挙型。 0-7 の整数 [詳解]
 
enum  RelativeDirection : int8_t {
  Front , Left45 , Left , Left135 ,
  Back , Right135 , Right , Right45
}
 相対方向の列挙型。 0-7 の整数 [詳解]
 

公開メンバ関数

constexpr Direction (const AbsoluteDirection d=East)
 デフォルトコンストラクタ。絶対方向をそのまま格納。 [詳解]
 
constexpr Direction (const int8_t d)
 整数を引数としたコンストラクタ。 [詳解]
 
constexpr operator int8_t () const
 整数へのキャスト。相対方向などの演算に使える。 [詳解]
 
bool isAlong () const
 壁沿い方向かどうかの判定 [詳解]
 
bool isDiag () const
 斜め方向かどうかの判定 [詳解]
 
char toChar () const
 表示用char型へのキャスト [詳解]
 

静的公開メンバ関数

static constexpr const std::array< Direction, 4 > Along4 ()
 斜めではない4方向の配列 (for文などで使用) [詳解]
 
static constexpr const std::array< Direction, 4 > Diag4 ()
 斜めの4方向の配列 (for文などで使用) [詳解]
 

静的公開変数類

static constexpr const int8_t Max = 8
 方向の総数。for文などで使える。 [詳解]
 

フレンド

std::ostream & operator<< (std::ostream &os, const Direction d)
 stream 表示 [詳解]
 

詳解

迷路上の方向を表す。

実体は 8bit の整数。 絶対方向 or 相対方向の8方位を表現することができる。 コンストラクタにより8方位(0-7)に自動的に収められるので、 加法、減法により相対方向を計算することができる。

+-----------+-------+-----------+
+ + + +
| West X East |
+ + + +
+-----------+-------+-----------+
+-----------+-------+-----------+
+ + + +
| Back X Front |
+ + + +
+-----------+-------+-----------+
AbsoluteDirection
絶対方向の列挙型。 0-7 の整数
Definition: Maze.h:150
@ North
Definition: Maze.h:153
@ NorthWest
Definition: Maze.h:154
@ NorthEast
Definition: Maze.h:152
@ East
Definition: Maze.h:151
@ West
Definition: Maze.h:155
RelativeDirection
相対方向の列挙型。 0-7 の整数
Definition: Maze.h:163
@ Back
Definition: Maze.h:168
@ Left45
Definition: Maze.h:165
@ Right45
Definition: Maze.h:171
@ Right135
Definition: Maze.h:169
@ Right
Definition: Maze.h:170
@ Left
Definition: Maze.h:166
@ Front
Definition: Maze.h:164
@ Left135
Definition: Maze.h:167

列挙型メンバ詳解

◆ AbsoluteDirection

絶対方向の列挙型。 0-7 の整数

列挙値
East 
NorthEast 
North 
NorthWest 
West 
SouthWest 
South 
SouthEast 
150  : int8_t {
151  East,
152  NorthEast,
153  North,
154  NorthWest,
155  West,
156  SouthWest,
157  South,
158  SouthEast,
159  };
@ SouthEast
Definition: Maze.h:158
@ South
Definition: Maze.h:157
@ SouthWest
Definition: Maze.h:156

◆ RelativeDirection

相対方向の列挙型。 0-7 の整数

列挙値
Front 
Left45 
Left 
Left135 
Back 
Right135 
Right 
Right45 
163  : int8_t {
164  Front,
165  Left45,
166  Left,
167  Left135,
168  Back,
169  Right135,
170  Right,
171  Right45,
172  };

構築子と解体子

◆ Direction() [1/2]

constexpr MazeLib::Direction::Direction ( const AbsoluteDirection  d = East)
inlineconstexpr

デフォルトコンストラクタ。絶対方向をそのまま格納。

184 : d(d) {}

◆ Direction() [2/2]

constexpr MazeLib::Direction::Direction ( const int8_t  d)
inlineconstexpr

整数を引数としたコンストラクタ。

相対方向などの計算結果を 0-7 の整数に直して格納する。

引数
d相対方向などの演算結果の整数
190 : d(d & 7) {}

関数詳解

◆ Along4()

static constexpr const std::array<Direction, 4> MazeLib::Direction::Along4 ( )
inlinestaticconstexpr

斜めではない4方向の配列 (for文などで使用)

216  {
217  return {
222  };
223  }

◆ Diag4()

static constexpr const std::array<Direction, 4> MazeLib::Direction::Diag4 ( )
inlinestaticconstexpr

斜めの4方向の配列 (for文などで使用)

227  {
228  return {
233  };
234  }

◆ isAlong()

bool MazeLib::Direction::isAlong ( ) const
inline

壁沿い方向かどうかの判定

198 { return !(d & 1); }

◆ isDiag()

bool MazeLib::Direction::isDiag ( ) const
inline

斜め方向かどうかの判定

202 { return (d & 1); }

◆ operator int8_t()

constexpr MazeLib::Direction::operator int8_t ( ) const
inlineconstexpr

整数へのキャスト。相対方向などの演算に使える。

194 { return d; }

◆ toChar()

char MazeLib::Direction::toChar ( ) const
inline

表示用char型へのキャスト

206 { return ">'^`<,v.X"[d]; }

フレンドと関連関数の詳解

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Direction  d 
)
friend

stream 表示

210  {
211  return os << d.toChar();
212  }

メンバ詳解

◆ Max

constexpr const int8_t MazeLib::Direction::Max = 8
staticconstexpr

方向の総数。for文などで使える。

Direction 型ではなく int8_t 型なことに注意。 (Direction 型は 0-7 の整数)


このクラス詳解は次のファイルから抽出されました: