/usr/include/osl/bits/pieceMask.h is in libosl-dev 0.8.0-1.4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | #ifndef _PIECE_MASK_H
#define _PIECE_MASK_H
#include "osl/config.h"
#include "osl/bits/ptypeTraits.h"
static_assert(OSL_WORDSIZE == 64, "word size");
#include "osl/bits/pieceMask64.h"
#include <iosfwd>
namespace osl
{
typedef PieceMask64 PieceMaskBase;
/**
* 駒番号のビットセット.
* 64bitのMask64を一つもしくは,32bitのMask32を2枚で表現する.
* 各メソッドの変数名は num は駒番号に,
* index はマスクのID(0-1)に用いられている.
*/
class PieceMask : public PieceMaskBase
{
public:
PieceMask() {}
PieceMask(const PieceMaskBase& base) : PieceMaskBase(base) {}
static const mask_t numToMask(int num) {
return mask_t::makeDirect(1) << PieceMask::numToOffset(num);
}
void setMask(int index,mask_t val) {
mutableMask(index)=val;
}
private:
mask_t& mutableMaskNum(int num) {
return mutableMask(numToIndex(num));
}
const mask_t getMaskNum(int num) const {
return getMask(numToIndex(num));
}
public:
void xorMask(int index,mask_t val) {
mutableMask(index)^=val;
}
void orMask(int index,mask_t val) {
mutableMask(index)|=val;
}
bool test(int num) const {
return (getMaskNum(num)&numToMask(num)).any();
}
void set(int num) {
mutableMaskNum(num)|=numToMask(num);
}
void flip(int num) {
mutableMaskNum(num)^=numToMask(num);
}
void reset(int num) {
mutableMaskNum(num)&= ~numToMask(num);
}
bool any() const { return ! none(); }
const mask_t getMask(int num) const { return PieceMaskBase::getMask(num); }
/** unpromote(PTYPE) の駒のbit を*含む*mask_tを取り出す */
template <Ptype PTYPE>
const mask_t getMask() const { return getMask(PtypeFuns<PTYPE>::indexNum); }
/** unpromote(PTYPE) の駒のbit だけ取り出す */
template <Ptype PTYPE>
const mask_t selectBit() const
{
mask_t mask = getMask<PTYPE>();
mask &= mask_t::makeDirect(PtypeFuns<PtypeFuns<PTYPE>::basicType>::indexMask);
return mask;
}
/** unpromote(PTYPE) の駒のbit を消す */
template <Ptype PTYPE>
void clearBit()
{
mask_t& mask = mutableMask(PtypeFuns<PTYPE>::indexNum);
mask &= ~mask_t::makeDirect(PtypeFuns<PtypeFuns<PTYPE>::basicType>::indexMask);
}
/** unpromote(PTYPE) の駒のbit を立てる */
template <Ptype PTYPE>
void setBit()
{
mask_t& mask = mutableMask(PtypeFuns<PTYPE>::indexNum);
mask |= mask_t::makeDirect(PtypeFuns<PtypeFuns<PTYPE>::basicType>::indexMask);
}
};
inline const PieceMask operator&(const PieceMask &m1, const PieceMask &m2) {
return PieceMask64(m1.getMask(0)&m2.getMask(0));
}
inline const PieceMask operator|(const PieceMask &m1, const PieceMask &m2) {
return PieceMask64(m1.getMask(0)|m2.getMask(0));
}
inline const PieceMask operator~(const PieceMask &m1) {
return PieceMask64(~m1.getMask(0));
}
inline bool operator==(const PieceMask &m1, const PieceMask &m2){
return m1.getMask(0)==m2.getMask(0) && m1.getMask(1)==m2.getMask(1);
}
inline bool operator!=(const PieceMask &m1, const PieceMask &m2)
{
return ! (m1 == m2);
}
std::ostream& operator<<(std::ostream& os,PieceMask const& pieceMask);
} // namespace osl
#endif /* _PIECE_MASK_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|