Main MRPT website > C++ reference for MRPT 1.5.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 a std::list.
23  * \note Defined in #include <mrpt/utils/list_searchable.h>
24  * \ingroup stlext_grp
25  */
26  template <class T>
27  class list_searchable : public std::list<T>
28  {
29  public:
30  void insert( const T &o ) { std::list<T>::push_back(o); }
31 
32  typename std::list<T>::iterator find( const T& i ) {
34  }
35 
36  typename std::list<T>::const_iterator find( const T& i ) const {
38  }
39 
40  /** Finds an element in a list of smart pointers, having "->pointer()", such as it matches a given plain pointer "ptr". */
41  template <typename PTR>
42  typename std::list<T>::iterator find_ptr_to( const PTR ptr )
43  {
44  for (typename std::list<T>::iterator it=std::list<T>::begin();it!=std::list<T>::end();it++)
45  if (it->pointer()==ptr)
46  return it;
47  return std::list<T>::end();
48  }
49 
50  /** Finds an element in a list of smart pointers, having "->pointer()", such as it matches a given plain pointer "ptr". */
51  template <typename PTR>
52  typename std::list<T>::const_iterator find_ptr_to( const PTR ptr ) const
53  {
55  if (it->pointer()==ptr)
56  return it;
57  return std::list<T>::end();
58  }
59 
60  };
61 
62  } // End of namespace
63 } // End of namespace
64 #endif
This class implements a STL container with features of both, a std::set and a std::list.
Scalar * iterator
Definition: eigen_plugins.h:23
EIGEN_STRONG_INLINE iterator begin()
Definition: eigen_plugins.h:26
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:24
const_iterator find(const KEY &key) const
Definition: ts_hash_map.h:139
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:3512
GLsizei const GLchar ** string
Definition: glext.h:3919
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.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020