My Project
bitXmask.h
Go to the documentation of this file.
1/* bitXmask.h
2 */
3#ifndef OSL_BITXMASK_H
4#define OSL_BITXMASK_H
5
6#include "osl/basic_type.h"
7#include <iosfwd>
8
9namespace osl
10{
11 namespace container
12 {
17 {
18 int mask;
19 public:
20 BitXmask() : mask(0) {}
21 void clearAll() { mask = 0; }
22 void set(int x) { mask |= (1 << x); }
23 void clear(int x) { mask &= ~(1 << x); }
24
25 void set(Square position) { set(position.x()); }
26 void clear(Square position) { clear(position.x()); }
27
28 bool isSet(int x) const { return mask & (1<<x); }
29
30 int intValue() const { return mask; }
31 };
32
33 inline bool operator==(BitXmask l, BitXmask r)
34 {
35 return l.intValue() == r.intValue();
36 }
37 inline bool operator!=(BitXmask l, BitXmask r)
38 {
39 return ! (l == r);
40 }
41 inline bool operator<(BitXmask l, BitXmask r)
42 {
43 return l < r;
44 }
45
46 std::ostream& operator<<(std::ostream&,const BitXmask);
47 } // namespace container
48 using container::BitXmask;
49} // namespace osl
50
51#endif /* OSL_BITXMASK_H */
52// ;;; Local Variables:
53// ;;; mode:c++
54// ;;; c-basic-offset:2
55// ;;; coding:utf-8
56// ;;; End:
int x() const
将棋としてのX座標を返す.
Definition basic_type.h:563
X座標のbitset.
Definition bitXmask.h:17
void set(Square position)
Definition bitXmask.h:25
bool isSet(int x) const
Definition bitXmask.h:28
void clear(Square position)
Definition bitXmask.h:26
bool operator==(BitXmask l, BitXmask r)
Definition bitXmask.h:33
bool operator!=(BitXmask l, BitXmask r)
Definition bitXmask.h:37
std::ostream & operator<<(std::ostream &, const BitXmask)
Definition bitXmask.cc:6
bool operator<(BitXmask l, BitXmask r)
Definition bitXmask.h:41