Files
ogws/include/MSL/algorithm
T

43 lines
944 B
Plaintext
Raw Normal View History

2023-06-19 10:40:14 -04:00
#ifndef MSL_CPP_ALGORITHM_H
#define MSL_CPP_ALGORITHM_H
#include <iterator>
2021-07-28 13:01:11 -04:00
namespace std
{
2022-04-24 02:28:26 -04:00
template <typename T>
2022-01-31 19:06:41 -05:00
inline const T& max(const T& a, const T& b)
2021-07-28 13:01:11 -04:00
{
return (a < b) ? b : a;
}
2022-01-31 19:06:41 -05:00
2022-04-24 02:28:26 -04:00
template <typename T>
inline const T& min(const T& a, const T& b)
{
return (b < a) ? b : a;
}
2022-01-31 19:06:41 -05:00
template <typename TPtr, typename T>
inline TPtr find(TPtr first, TPtr last, const T& value)
{
while (first != last && *first != value) {
++first;
}
2022-01-31 19:06:41 -05:00
return first;
}
template <typename TPtr>
inline long distance(TPtr first, TPtr last)
2022-01-31 19:06:41 -05:00
{
random_access_iterator_tag tag;
return __distance(first, last, tag);
}
template <typename TPtr>
inline long __distance(TPtr first, TPtr last, random_access_iterator_tag tag)
{
long dist = (long)last - (long)first;
return dist / (long)sizeof(TPtr);
}
2021-07-28 13:01:11 -04:00
}
#endif