Expand Bitset
shsr04 opened this issue · 5 comments
The Sealib::Bitset
implementation should include all the essential functionality of the boost::dynamic_bitset
class, as specified here: https://www.boost.org/doc/libs/1_67_0/libs/dynamic_bitset/dynamic_bitset.html
Required:
class Bitset {
//constructors:
Bitset(sizetype bits, unsigned long value);
Bitset(Bitset&);
Bitset operator~();
unsigned long to_ulong();
};
//static procedures:
Bitset operator&(Bitset&, Bitset&);
Bitset operator|(Bitset&, Bitset&);
//static procedures:
Bitset operator&(Bitset&, Bitset&);
Bitset operator|(Bitset&, Bitset&);
Bitset operator~();
//constructors:
Bitset(Bitset&);
Will do.
unsigned long to_ulong();
This implementation allows direct access to the underlying data via the functions getBlock and setBlock. Is this needed? to_ulong only works for bitsets with <= 64 bits. I can implement it if it's needed.
Bitset(sizetype bits, unsigned long value);
Similiar to the function to_ulong, since we can set blocks directly via setBlock, is this needed?
Currently blocks are unsinged char based. It is probably better to change it to unsinged long altogether.
If this exact behavior is needed, i can implement it.
Either change blocktype
to unsigned long
. This enables simple setting/getting of the first block and treat it as a number.
Or, if you want to keep the byte access, please implement the unsigned long
variants in addition.
@1yay1 Note: operator~
is not a static procedure, it is a member of the Bitset class. I edited the description to fix this.
Implemented the functions.
The default behavior of the copy constructor works correctly for this class, so no implementation is needed