]> git.tdb.fi Git - libs/core.git/blob - source/core/algorithm.h
Use vectors for storage in Poller
[libs/core.git] / source / core / algorithm.h
1 #ifndef MSP_CORE_ALGORITHM_H_
2 #define MSP_CORE_ALGORITHM_H_
3
4 #include <algorithm>
5
6 namespace Msp {
7
8 template<typename Container, typename T>
9 inline typename Container::iterator find(Container &cont, const T &value)
10 {
11         return std::find(cont.begin(), cont.end(), value);
12 }
13
14 template<typename Container, typename T>
15 inline typename Container::const_iterator find(const Container &cont, const T &value)
16 {
17         return std::find(cont.begin(), cont.end(), value);
18 }
19
20 template<typename Container, typename Predicate>
21 inline typename Container::iterator find_if(Container &cont, Predicate pred)
22 {
23         return std::find_if(cont.begin(), cont.end(), pred);
24 }
25
26 template<typename Container, typename Predicate>
27 inline typename Container::const_iterator find_if(const Container &cont, Predicate pred)
28 {
29         return std::find_if(cont.begin(), cont.end(), pred);
30 }
31
32 template<typename Container>
33 inline void sort(Container &cont)
34 {
35         std::sort(cont.begin(), cont.end());
36 }
37
38 template<typename Container, typename Predicate>
39 inline void sort(Container &cont, Predicate pred)
40 {
41         std::sort(cont.begin(), cont.end(), pred);
42 }
43
44 template<typename Container>
45 inline void stable_sort(Container &cont)
46 {
47         std::stable_sort(cont.begin(), cont.end());
48 }
49
50 template<typename Container, typename Predicate>
51 inline void stable_sort(Container &cont, Predicate pred)
52 {
53         std::stable_sort(cont.begin(), cont.end(), pred);
54 }
55
56 } // namespace Msp
57
58 #endif