values-bitset.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 namespace Gecode { namespace Iter { namespace Values {
00035
00041 template<class BS>
00042 class BitSet {
00043 protected:
00045 const BS& bs;
00047 unsigned int cur;
00049 unsigned int limit;
00051 void move(void);
00052 public:
00054
00055
00056 BitSet(const BS& bs);
00058 BitSet(const BS& bs, int n, int m);
00060
00062
00063
00064 bool operator ()(void) const;
00066 void operator ++(void);
00068
00070
00071
00072 int val(void) const;
00074 };
00075
00076
00077 template<class BS>
00078 forceinline
00079 BitSet<BS>::BitSet(const BS& bs0)
00080 : bs(bs0), cur(bs.next(0)), limit(bs.size()) {
00081 }
00082
00083 template<class BS>
00084 forceinline
00085 BitSet<BS>::BitSet(const BS& bs0, int n, int m)
00086 : bs(bs0),
00087 cur(bs.next(static_cast<unsigned int>(n))),
00088 limit(std::min(bs.size(),static_cast<unsigned int>(m)+1)) {
00089 }
00090
00091 template<class BS>
00092 forceinline void
00093 BitSet<BS>::operator ++(void) {
00094 cur=bs.next(cur+1);
00095 }
00096 template<class BS>
00097 forceinline bool
00098 BitSet<BS>::operator ()(void) const {
00099 return cur < limit;
00100 }
00101
00102 template<class BS>
00103 forceinline int
00104 BitSet<BS>::val(void) const {
00105 return static_cast<int>(cur);
00106 }
00107
00108 }}}
00109
00110