Regarding the first example it's interesting to note that while for small arrays and searching for a frequent occurence using x->xx<num seems directly related to the rarity of the searched for condition. Even for small arrays where the condition does not occur, this approah is significantly slower than the other approaches (and the vectorized approach is fastest).