algorithm.cti
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief Algorithm inline template implementation */
16 
17 // Custom includes
18 
19 #define prefix_ inline
20 //-/////////////////////////////////////////////////////////////////////////////////////////////////
21 
22 template <class InputIterator, class ValueType>
23 prefix_ bool senf::contains(InputIterator first, InputIterator last, ValueType const & value)
24 {
25  return std::find(first, last, value) != last;
26 }
27 
28 template <class Container, class ValueType>
29 prefix_ bool senf::contains(Container const & container, ValueType const & value)
30 {
31  return senf::contains( boost::begin(container), boost::end(container), value);
32 }
33 
34 template <class ValueType>
35 prefix_ bool senf::contains(std::set<ValueType> const & container, ValueType const & value)
36 {
37  return container.find(value) != container.end();
38 }
39 
40 template <typename KeyType, typename ValueType>
41 prefix_ bool senf::contains(std::map<KeyType, ValueType> const & container, KeyType const & key)
42 {
43  return container.find(key) != container.end();
44 }
45 
46 template <typename KeyType, typename ValueType>
47 prefix_ bool senf::contains(boost::ptr_map<KeyType, ValueType> const & container, KeyType const & key)
48 {
49  return container.find(key) != container.end();
50 }
51 
52 template <typename KeyType, typename ValueType>
53 prefix_ bool senf::contains(boost::ptr_unordered_map<KeyType, ValueType> const & container, KeyType const & key)
54 {
55  return container.find(key) != container.end();
56 }
57 
58 //-/////////////////////////////////////////////////////////////////////////////////////////////////
59 #undef prefix_
60 
61 
62 // Local Variables:
63 // mode: c++
64 // fill-column: 100
65 // comment-column: 40
66 // c-file-style: "senf"
67 // indent-tabs-mode: nil
68 // ispell-local-dictionary: "american"
69 // compile-command: "scons -u test"
70 // End: