ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/utils/BitSet.cpp
(Generate patch)

Comparing trunk/src/utils/BitSet.cpp (file contents):
Revision 286 by tim, Fri Feb 4 05:42:30 2005 UTC vs.
Revision 347 by tim, Tue Feb 15 17:11:35 2005 UTC

# Line 39 | Line 39
39   * such damages.
40   */
41  
42 #include "utils/BitSet.hpp"
42   #include <algorithm>
43   #include <cassert>
44 + #include <string>
45  
46 + #include "utils/BitSet.hpp"
47 + #include "utils/Algorithm.hpp"
48 +
49   namespace oopse {
50   int BitSet::countBits() {
51 + #ifdef __RWSTD    
52 +    //For the compiler(Sun, MSVC6.0) binding with RougeWave STL Library, we need to use old-style
53 +    // std::count which is error-prone.
54 +    int count = 0;
55 +    std::count(bitset_.begin(), bitset_.end(), true, count);
56 +    return count;
57 + #else
58      return std::count(bitset_.begin(), bitset_.end(), true);
59 + #endif
60   }
61  
62   void BitSet::flip(int fromIndex, int toIndex) {
# Line 76 | Line 87 | bool BitSet::none() {
87      return i == bitset_.end() ? true : false;
88   }
89      
90 < int BitSet::nextOffBit(int fromIndex) {
90 > int BitSet::nextOffBit(int fromIndex) const {
91      ++fromIndex;
92      while (fromIndex < size()) {
93          if (!bitset_[fromIndex]) {
# Line 88 | Line 99 | int BitSet::nextOffBit(int fromIndex) {
99      return -1;
100   }
101  
102 < int BitSet::nextOnBit(int fromIndex) {
102 > int BitSet::nextOnBit(int fromIndex) const {
103      ++fromIndex;
104      while (fromIndex < size()) {
105          if (bitset_[fromIndex]) {
# Line 168 | Line 179 | std::ostream& operator<< ( std::ostream& os, const Bit
179   }
180  
181   std::ostream& operator<< ( std::ostream& os, const BitSet& bs) {
182 +    for (int i = 0; i < bs.bitset_.size(); ++i) {
183 +        std::string val = bs[i] ? "true" : "false";
184 +        os << "BitSet[" << i <<"] = " << val << std::endl;
185 +    }
186 +    
187      return os;
188   }
189  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines