I have a double array double myArray[] and a scalar x. I would like to check if x is an element of myArray[]. I already know how to do this by std::find if the array and the scalar are both integers. e.g.
1 2 3 4 5 6 7 8 9 10
#include <algorithm>
int myArray[] = { 3, 2, 1, 0, 1, 2, 3 };
size_t myArraySize = sizeof(myArray) / sizeof(int);
int *end = myArray + myArraySize;
// find the value 0:
int *result = std::find(myArray, end, 0);
if (result != end) {
// found value at "result" pointer location...
}
I have a very large number of arrays to check and do not prefere to convert every element in loop. Is there any efficient way around here without looping over the array?