#include <bool_array.h>
Collaboration diagram for bool_array:

Public Member Functions | |
| bool_array () | |
| bool_array (unsigned long __size) | |
| Constructs the packed boolean array with a specific size. | |
| ~bool_array () | |
| bool | create (unsigned long __size) |
| Creates the packed boolean array with a specific size. | |
| void | initialize (bool __value) |
| Initializes all array elements to a specific value optimally. | |
| _Element | operator[] (unsigned long __idx) |
| Creates a reference to an array element. | |
| bool | at (unsigned long __idx) const |
| Reads the boolean value of an array element via an index. | |
| void | reset (unsigned long __idx) |
Resets an array element to false via an index. | |
| void | set (unsigned long __idx) |
Sets an array element to true via an index. | |
| unsigned long | size () const |
| unsigned long | count () const |
Counts elements with a true value. | |
| unsigned long | count (unsigned long __beg, unsigned long __end) const |
Counts elements with a true value in a specified range. | |
| void | flip () |
Changes all true elements to false, and false ones to true. | |
This was first written in April 1995, before I knew of any existing implementation of this kind of classes. Of course, the C++ Standard Template Library now demands an implementation of packed boolean array as `vector<bool>', but the code here should still be useful for the following three reasons: (1) STL support of MSVC 6 did not implement this specialization (nor did it have a `bit_vector'); (2) I incorporated some useful member functions from the STL bitset into this `bool_array', including `reset', `set', `flip', and `count'; (3) In my tests under MSVC 6 and GCC 2.95.3/3.2.3 my code is really FASTER than vector<bool> or the normal boolean array.
|
|
|
|
|
Constructs the packed boolean array with a specific size.
|
|
|
|
|
|
Reads the boolean value of an array element via an index.
|
|
||||||||||||
|
Counts elements with a
|
|
|
Counts elements with a
|
|
|
Creates the packed boolean array with a specific size.
|
|
|
Changes all
|
|
|
Initializes all array elements to a specific value optimally.
|
|
|
Creates a reference to an array element.
|
|
|
Resets an array element to
|
|
|
Sets an array element to
|
|
|
|
1.3.9.1