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-2018, 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 #pragma once
10 
11 #include <list>
12 #include <algorithm>
13 
14 namespace mrpt
15 {
16 namespace containers
17 {
18 /** This class implements a STL container with features of both, a std::set and
19  * a std::list.
20  * \note Defined in #include <mrpt/containers/list_searchable.h>
21  * \ingroup mrpt_containers_grp
22  */
23 template <class T>
24 class list_searchable : public std::list<T>
25 {
26  public:
27  void insert(const T& o) { std::list<T>::push_back(o); }
28  typename std::list<T>::iterator find(const T& i)
29  {
31  }
32 
33  typename std::list<T>::const_iterator find(const T& i) const
34  {
36  }
37 
38  /** Finds an element in a list of smart pointers, having "->pointer()", such
39  * as it matches a given plain pointer "ptr". */
40  template <typename PTR>
41  typename std::list<T>::iterator find_ptr_to(const PTR ptr)
42  {
43  for (typename std::list<T>::iterator it = std::list<T>::begin();
44  it != std::list<T>::end(); it++)
45  if (it->get() == ptr) return it;
46  return std::list<T>::end();
47  }
48 
49  /** Finds an element in a list of smart pointers, having "->pointer()", such
50  * 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  it != std::list<T>::end(); it++)
56  if (it->pointer() == ptr) return it;
57  return std::list<T>::end();
58  }
59 };
60 } // End of namespace
61 } // End of namespace
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 ...
Scalar * iterator
Definition: eigen_plugins.h:26
std::list< T >::iterator find(const T &i)
std::list< T >::const_iterator find(const T &i) const
const_iterator find(const KEY &key) const
Definition: ts_hash_map.h:219
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)
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 ...
This class implements a STL container with features of both, a std::set and a std::list.
GLuint GLuint end
Definition: glext.h:3528
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
const Scalar * const_iterator
Definition: eigen_plugins.h:27



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019