Main MRPT website > C++ reference for MRPT 1.9.9
list_searchable.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #ifndef list_searchable_H
10 #define list_searchable_H
11 
12 #include <list>
13 #include <algorithm>
14 
15 namespace mrpt
16 {
17 namespace utils
18 {
19 using std::for_each;
20 using std::string;
21 
22 /** This class implements a STL container with features of both, a std::set and
23  * a std::list.
24  * \note Defined in #include <mrpt/utils/list_searchable.h>
25  * \ingroup stlext_grp
26  */
27 template <class T>
28 class list_searchable : public std::list<T>
29 {
30  public:
31  void insert(const T& o) { std::list<T>::push_back(o); }
32  typename std::list<T>::iterator find(const T& i)
33  {
35  }
36 
37  typename std::list<T>::const_iterator find(const T& i) const
38  {
40  }
41 
42  /** Finds an element in a list of smart pointers, having "->pointer()", such
43  * as it matches a given plain pointer "ptr". */
44  template <typename PTR>
45  typename std::list<T>::iterator find_ptr_to(const PTR ptr)
46  {
47  for (typename std::list<T>::iterator it = std::list<T>::begin();
48  it != std::list<T>::end(); it++)
49  if (it->get() == ptr) return it;
50  return std::list<T>::end();
51  }
52 
53  /** Finds an element in a list of smart pointers, having "->pointer()", such
54  * as it matches a given plain pointer "ptr". */
55  template <typename PTR>
56  typename std::list<T>::const_iterator find_ptr_to(const PTR ptr) const
57  {
59  it != std::list<T>::end(); it++)
60  if (it->pointer() == ptr) return it;
61  return std::list<T>::end();
62  }
63 };
64 
65 } // End of namespace
66 } // End of namespace
67 #endif
This class implements a STL container with features of both, a std::set and a std::list.
Scalar * iterator
Definition: eigen_plugins.h:26
EIGEN_STRONG_INLINE iterator begin()
Definition: eigen_plugins.h:29
EIGEN_STRONG_INLINE void push_back(Scalar val)
Insert an element at the end of the container (for 1D vectors/arrays)
const Scalar * const_iterator
Definition: eigen_plugins.h:27
const_iterator find(const KEY &key) const
Definition: ts_hash_map.h:220
std::list< T >::const_iterator find(const T &i) const
std::list< T >::iterator find_ptr_to(const PTR ptr)
Finds an element in a list of smart pointers, having "->pointer()", such as it matches a given plain ...
std::list< T >::const_iterator find_ptr_to(const PTR ptr) const
Finds an element in a list of smart pointers, having "->pointer()", such as it matches a given plain ...
GLuint GLuint end
Definition: glext.h:3528
GLsizei const GLchar ** string
Definition: glext.h:4101
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::list< T >::iterator find(const T &i)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019