: This would appear to work for == and !=, but I would not be able to
: do:
:
: BitMap temp;
:
: temp.allocateBits(33);
:
: temp[5] = 1
: I would have to change it to something like:
:
: BitMap temp;
:
: temp.allocateBits(33);
:
: temp.setBit(5, true) //setBit(uint bitIndex, bool toggle)
: Yes?
:
: I would like to avoid needing a separate method for checking/setting
: the bits, which was why I used the non-standard way of the
: operator[] to return a BitMap with internal index/position pointers
: set, ready for the next binary operator (=, ==, !=).
:
Tbh, I doubt that code works now. Have you tried it?
It probably depends on how you implemented =.
If you want it like that, my thought would be to return a BitMap& (reference to a BitMap) in the operator[]. Then operator = can be done like:
BitMap& BitMap::operator= (int n)
{
//Set 'list[index, position]' to n
list[index] = ...
return *this;
}
Ofcourse, I actually can't say anything about it right now - how did you implement = ?
: The internal "logic" might then be a bit messier, and marginally
: slower, but the actual use of the class seems more standard/user
: friendly. I did, however, have to use a toString() method for
: printing.
:
: That wouldn't be a problem if C++ tried to call any toString()
: methods automatically for printing if it received an
: unknown/unhandled type for output, but we can't have everything :).
:
: I will make these changes and see just how much faster/speed
: difference this does indeed make and post my findings.
You can add an overload for the << and >> of the iostream object (eg making it compatible with cin/cout).
I always forget how to, exactly, but it's possible.
Best Regards,
Richard
The way I see it... Well, it's all pretty blurry