// Returns the minimum value from a range [first, last)
template <class Iter>
typename std::iterator_traits<Iter>::value_type
MinRange(Iter first, Iter last)
{
typename std::iterator_traits<Iter>::value_type lowVal = *first++;
for ( ; first != last; ++first)
if (*first < lowVal)
lowVal = *first;
return lowVal;
}
// Returns the maximum value from a range [first, last)
template <class Iter>
typename std::iterator_traits<Iter>::value_type
MaxRange(Iter first, Iter last)
{
typename std::iterator_traits<Iter>::value_type highVal = *first++;
for ( ; first != last; ++first)
if (highVal < *first)
highVal = *first;
return highVal;
}