5 #ifndef BALL_DATATYPE_BITVECTOR_H
6 #define BALL_DATATYPE_BITVECTOR_H
12 #ifndef BALL_CONCEPT_PERSISTENCEMANAGER_H
16 #ifndef BALL_COMMON_EXCEPTION_H
23 #define BALL_BLOCK_BITS 8
24 #define BALL_BLOCK_MASK (BALL_BLOCK_BITS - 1)
25 #define BALL_BLOCK_SHIFT 3
26 #define BALL_BLOCK_ALL_BITS_SET 0xFF
27 #define BALL_BLOCK_ALL_BITS_CLEARED 0x00
30 #define BALL_BLOCK_SIZE(bits) (Size)(((bits) + BALL_BLOCK_BITS - 1) >> BALL_BLOCK_SHIFT)
104 operator
bool() const;
114 Bit& operator = (const Bit& bit);
122 Bit& operator = (const
bool bit);
126 virtual
void clear();
136 bool operator == (const Bit& bit) const;
142 bool operator == (
bool bit) const;
147 bool operator != (const Bit& bit) const;
153 bool operator != (
bool bit) const;
163 bool bitvector_muteable_;
206 BitVector(
Size size);
211 BitVector(const BitVector& bit_vector);
217 BitVector(const
char* bit_string);
221 virtual ~BitVector();
236 void set(const BitVector& bit_vector);
243 void set(const
char* bit_string);
248 BitVector& operator = (const BitVector& bit_vector);
254 BitVector& operator = (const
char *bit_string);
259 void get(BitVector& bitvector) const;
274 BitVector operator () (
Index first,
Index last) const;
281 void setSize(
Size size,
bool keep = true);
285 Size getSize() const;
291 Size countValue(
bool value) const;
296 VectorType& getBitSet();
301 const VectorType& getBitSet() const;
309 Bit operator [] (
Index index);
317 bool operator [] (
Index index) const;
328 void setBit(
Index index,
bool value = true);
338 bool getBit(
Index index);
348 bool getBit(
Index index) const;
356 void toggleBit(
Index index);
366 void fill(
bool value = true,
Index first = 0 ,
Index last = -1);
376 void toggle(
Index first = 0,
Index last = -1);
382 void setUnsignedChar(
unsigned char bit_pattern);
388 unsigned char getUnsignedChar() const;
393 void setUnsignedShort(
unsigned short bit_pattern);
398 unsigned short getUnsignedShort() const;
403 void setUnsignedInt(
unsigned int bit_pattern);
408 unsigned int getUnsignedInt() const;
413 void setUnsignedLong(
unsigned long bit_pattern);
418 unsigned long getUnsignedLong() const;
424 void bitwiseOr(const BitVector& bit_vector);
430 void bitwiseXor(const BitVector& bit_vector);
436 void bitwiseAnd(const BitVector& bit_vector);
443 BitVector operator | (const BitVector& bit_vector);
449 BitVector& operator |= (const BitVector& bit_vector);
456 BitVector operator & (const BitVector& bit_vector);
462 BitVector& operator &= (const BitVector& bit_vector);
469 BitVector operator ^ (const BitVector& bit_vector);
475 BitVector& operator ^= (const BitVector& bit_vector);
482 BitVector operator ~ ();
490 bool operator == (const BitVector& bit_vector) const;
493 bool operator != (const BitVector& bit_vector) const;
502 bool isAnyBit(
bool value,
Index first = 0,
Index last = -1) const;
511 bool isEveryBit(
bool value,
Index first = 0,
Index last = -1) const;
520 bool isValid() const;
531 BALL_EXPORT friend std::istream& operator >> (std::istream& s, BitVector& bit_vector);
536 BALL_EXPORT friend std::ostream& operator << (std::ostream& s, const BitVector& bit_vector);
541 virtual
void read(std::istream& s);
545 virtual
void write(std::ostream& s) const;
562 void validateIndex_(
Index& index);
566 void validateIndex_(
Index& index) const;
570 void validateRange_(
Index& first,
Index& last) const;
583 BlockType mask_(
Index index) const;
591 # ifndef BALL_NO_INLINE_FUNCTIONS
592 # include <BALL/DATATYPE/bitVector.iC>
597 #endif // BALL_DATATYPE_BITVECTOR_H
#define BALL_CREATE(name)
std::vector< BlockType > VectorType