#ifndef _STD_ALGORITHM_H #define _STD_ALGORITHM_H // from rb3/key decomp #include namespace std { template inline const T &min(const T &a, const T &b) { return b < a ? b : a; } template inline const T &max(const T &a, const T &b) { return a < b ? b : a; } template inline const T &min(const T &a, const T &b, _Compare comp) { return comp(b, a) ? b : a; } template inline const T &max(const T &a, const T &b, _Compare comp) { return comp(a, b) ? b : a; } template inline InputIterator find_if(InputIterator first, InputIterator last, Predicate p) { for (; first != last && !p(*first); ++first) { } return first; } template inline It find(It first, It last, const T &value) { while (first != last && *first != value) { first++; } return first; } // adapted from https://github.com/matta/sgi-stl/blob/635eaeef4533214ec140fb17411558ad441d2996/stl/stl_algo.h#L638 template inline It remove(It first, It last, const T &value) { first = find(first, last, value); if (first != last) { It it = first; for (it++; it != last; it++) { if (*it != value) { *first = *it; first++; } } } return first; } template struct __fill_n { static inline void fill_n(T *first, Size n, const T &value) { for (; n != 0; first++, n--) { *first = value; } } }; template inline void fill_n(OutputIt *first, Size n, const T &value) { __fill_n::fill_n(first, n, value); } template inline T &move(T &p) { return p; } template inline void swap(T &a, T &b) { T temp = move(a); a = move(b); b = move(temp); } } // namespace std #endif