fast minimum-maximum fiter in C++