00001 /* bitXmask.h 00002 */ 00003 #ifndef OSL_BITXMASK_H 00004 #define OSL_BITXMASK_H 00005 00006 #include "osl/basic_type.h" 00007 #include <iosfwd> 00008 00009 namespace osl 00010 { 00011 namespace container 00012 { 00016 class BitXmask 00017 { 00018 int mask; 00019 public: 00020 BitXmask() : mask(0) {} 00021 void clearAll() { mask = 0; } 00022 void set(int x) { mask |= (1 << x); } 00023 void clear(int x) { mask &= ~(1 << x); } 00024 00025 void set(Square position) { set(position.x()); } 00026 void clear(Square position) { clear(position.x()); } 00027 00028 bool isSet(int x) const { return mask & (1<<x); } 00029 00030 int intValue() const { return mask; } 00031 }; 00032 00033 inline bool operator==(BitXmask l, BitXmask r) 00034 { 00035 return l.intValue() == r.intValue(); 00036 } 00037 inline bool operator!=(BitXmask l, BitXmask r) 00038 { 00039 return ! (l == r); 00040 } 00041 inline bool operator<(BitXmask l, BitXmask r) 00042 { 00043 return l < r; 00044 } 00045 00046 std::ostream& operator<<(std::ostream&,const BitXmask); 00047 } // namespace container 00048 using container::BitXmask; 00049 } // namespace osl 00050 00051 #endif /* OSL_BITXMASK_H */ 00052 // ;;; Local Variables: 00053 // ;;; mode:c++ 00054 // ;;; c-basic-offset:2 00055 // ;;; coding:utf-8 00056 // ;;; End: