/* * Acess2 C++ Library * - By John Hodge (thePowersGang) * * algorithm (header) * - C++'s generic algorithms */ #ifndef _LIBCXX_ALGORITHM_ #define _LIBCXX_ALGORITHM_ #include #include "_libcxx_helpers.h" namespace std { // --- Non-modifiying sequence operations --- #if _CXX11_AVAIL // TODO: all_of // TODO: any_of // TODO: none_of #endif template Function for_each(InputIterator first, InputIterator last, Function fn) { while( first != last ) { fn( *first ); ++ first; } return _CXX11_MOVE(fn); } template InputIterator find(InputIterator first, InputIterator last, const T& val) { while( first != last ) { if( *first == val ) return first; ++ first; } return last; } // TODO: find_if // TODO: find_if_not (C++11) // TODO: find_end // TODO: find_first_of // Maximum template const T& max(const T& a, const T& b) { return (a const T& max(const T& a, const T& b, Compare comp) { return comp(a, b) ? b : a; } template const T& min(const T& a, const T& b) { return (a const T& min(const T& a, const T& b, Compare comp) { return comp(a, b) ? a : b; } }; // namespace std #endif // vim: ft=cpp