Mercurial > dedupe
view BitArray.cpp @ 62:247adcbbaf8b
Remove unnecessary includes in .cpp files.
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Fri, 14 Sep 2012 20:57:44 +0200 |
| parents | 725b0d776f3c |
| children | b9515dc35fe4 |
line wrap: on
line source
#include "BitArray.hpp" BitArray::~BitArray() { delete bits; } BitArray::BitArray(const BitArray& other) : size_(other.size()), bits(new uchar[NUMCHARS(size_)]) { memcpy(bits, other.bits, NUMCHARS(size_)); } BitArray& BitArray::operator=(const BitArray& other) { if (NUMCHARS(size_) != NUMCHARS(other.size_)) { delete bits; bits = new uchar[NUMCHARS(other.size_)]; } size_ = other.size_; memcpy(bits, other.bits, NUMCHARS(size_)); return *this; } bool BitArray::operator==(const BitArray& rhs) const { if (size() != rhs.size()) return false; for(size_t i = 0; i < size(); ++i) { if (testBit(i) != rhs.testBit(i)) return false; } return true; } std::ostream& operator<<(std::ostream& out, const BitArray& rhs) { for (size_t i = 0; i < rhs.size(); ++i) { out << (rhs.testBit(i) ? "1" : "0"); } return out; }
