Is it possible to check C (++) if the array is 0 (or false) without repeating / looping over each individual value and without allocating a new array of the same size (for use memcmp)?
memcmp
I am abusing the bools array to have arbitrary large bits at runtime and do some bitfling on it
You can use the following condition:
(myvector.end() == std::find(myvector.begin(), myvector.end(), true))
Obviously, internally this happens for all meanings.
( ) , true - .
true
UPDATE
, .
, . ? , , 0 ! memcmp, , . , .
, , -0.
- SIMD ( , ), .
(Btw, , C/++. , , .)
, , , (, ) . , , ++ , c.
boost::dynamic_bitset. none std::bitset - , .
boost::dynamic_bitset
none
std::bitset
, N, .
, 15- , .
8- , 4- , 2- 1- .
, , . , ( , ).
8- , 4- 8 .
, memcmp, .
, ++, .
- , - , , bool (__int64 say), .
bool
__int64
EDIT: , . , ++ ..
++
knittl,
I do not assume that you have access to some fancy DMA hardware on the target computer? Sometimes DMA hardware supports exactly the required operation, i.e. "Is this memory area zero?" This hardware acceleration comparison is a common solution when working with large bit buffers. For example, some RAID controllers use this mechanism to check for parity.