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
begin
EIGEN_STRONG_INLINE iterator begin()
Definition: eigen_plugins.h:29
const_iterator
const Scalar * const_iterator
Definition: eigen_plugins.h:27
end
GLuint GLuint end
Definition: glext.h:3528
mrpt::containers::list_searchable::find_ptr_to
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 ...
Definition: list_searchable.h:52
mrpt::containers::find
const_iterator find(const KEY &key) const
Definition: ts_hash_map.h:219
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::containers::list_searchable::insert
void insert(const T &o)
Definition: list_searchable.h:27
push_back
EIGEN_STRONG_INLINE void push_back(Scalar val)
Insert an element at the end of the container (for 1D vectors/arrays)
Definition: eigen_plugins.h:134
mrpt::containers::list_searchable::find_ptr_to
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 ...
Definition: list_searchable.h:41
mrpt::containers::list_searchable::find
std::list< T >::iterator find(const T &i)
Definition: list_searchable.h:28
mrpt::containers::list_searchable
This class implements a STL container with features of both, a std::set and a std::list.
Definition: list_searchable.h:24
iterator
Scalar * iterator
Definition: eigen_plugins.h:26
mrpt::containers::list_searchable::find
std::list< T >::const_iterator find(const T &i) const
Definition: list_searchable.h:33



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST