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