Is there a way to "bulk evaluate" the contents of an array in C++? For example, let int numbers[10]={23,42,12,42,53,10,0,0,0,0}. Is there a way to loop through each element in the array and check whether the element meets a specified condition?
In short, I'd like to be able to do something like:
if(every element in the array meets arbitrary condition)
do this
or
if(array element from m to array element n==something)
do this
For small arrays, I know I could use something like: if(numbers[0]==blabla) && if(numbers[n]==blabla), then do this, but obviously this is not a realistic solution when it comes to evaluating very large arrays.
you probably mean "for"
for(int i = 0; i < size_of_array; i++)
if( the_condition_function(numbers[i])){
//do this
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With