bitfield.hh

00001 #ifndef DUNE_BITFIELD_HH
00002 #define DUNE_BITFIELD_HH
00003 
00004 #warning This file is deprecated! Use bitsetvector.hh instead!
00005 
00006 #include <vector>
00007 #include <iostream>
00008 
00009 namespace Dune {
00010 
00017   class BitField : public std::vector<bool> {
00018 
00019   public:
00020 
00022       BitField() : std::vector<bool>() {}
00023 
00025       explicit BitField(int n) : std::vector<bool>(n) {}
00026 
00028     BitField(int n, bool v) : std::vector<bool>(n) {
00029         this->assign(size(), v);
00030     }
00031             
00033     void setAll() {
00034         this->assign(size(), true);
00035     }
00036 
00038     void unsetAll() {
00039         this->assign(size(), false);
00040     }
00041 
00043     int nSetBits() const {
00044       int n = 0;
00045       for (size_t i=0; i<size(); i++)
00046         n += ((*this)[i]) ? 1 : 0;
00047 
00048       return n;
00049     }
00050 
00052     friend std::ostream& operator<< (std::ostream& s, const BitField& v)
00053     {
00054       for (size_t i=0; i<v.size(); i++)
00055         s << v[i] << "  ";
00056             
00057       s << std::endl;
00058       return s;
00059     }
00060 
00061   } DUNE_DEPRECATED;
00062 
00063 }
00064 
00065 #endif

Generated on Thu Apr 2 10:39:53 2009 for dune-common by  doxygen 1.5.6