Usermode/libc++ - Implement map::insert and map::erase
[tpg/acess2.git] / Usermode / Libraries / libc++.so_src / include_exp / algorithm
1 /*
2  * Acess2 C++ Library
3  * - By John Hodge (thePowersGang)
4  *
5  * algorithm (header)
6  * - C++'s generic algorithms
7  */
8 #ifndef _LIBCXX_ALGORITHM_
9 #define _LIBCXX_ALGORITHM_
10
11 #include <utility>
12
13 #include "_libcxx_helpers.h"
14
15 namespace std {
16
17 // --- Non-modifiying sequence operations ---
18 #if _CXX11_AVAIL
19 // TODO: all_of
20 // TODO: any_of
21 // TODO: none_of
22 #endif
23 template <class InputIterator, class Function>
24 Function for_each(InputIterator first, InputIterator last, Function fn)
25 {
26         while( first != last )
27         {
28                 fn( *first );
29                 ++ first;
30         }
31         return _CXX11_MOVE(fn);
32 }
33
34 template <class InputIterator, class T>
35 InputIterator find(InputIterator first, InputIterator last, const T& val)
36 {
37         while( first != last )
38         {
39                 if( *first == val )
40                         return first;
41                 ++ first;
42         }
43         return last;
44 }
45 // TODO: find_if
46 // TODO: find_if_not (C++11)
47 // TODO: find_end
48 // TODO: find_first_of
49
50 // Maximum
51 template <class T>
52 const T& max(const T& a, const T& b)
53 {
54         return (a<b) ? b : a;
55 }
56
57 template <class T, class Compare>
58 const T& max(const T& a, const T& b, Compare comp)
59 {
60         return comp(a, b) ? b : a;
61 }
62
63 template <class T>
64 const T& min(const T& a, const T& b)
65 {
66         return (a<b) ? a : b;
67 }
68
69 template <class T, class Compare>
70 const T& min(const T& a, const T& b, Compare comp)
71 {
72         return comp(a, b) ? a : b;
73 }
74
75 };      // namespace std
76
77 #endif
78
79 // vim: ft=cpp

UCC git Repository :: git.ucc.asn.au