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::containers
15 {
16 /** This class implements a STL container with features of both, a std::set and
17  * a std::list.
18  * \note Defined in #include <mrpt/containers/list_searchable.h>
19  * \ingroup mrpt_containers_grp
20  */
21 template <class T>
22 class list_searchable : public std::list<T>
23 {
24  public:
25  void insert(const T& o) { std::list<T>::push_back(o); }
26  typename std::list<T>::iterator find(const T& i)
27  {
29  }
30 
31  typename std::list<T>::const_iterator find(const T& i) const
32  {
34  }
35 
36  /** Finds an element in a list of smart pointers, having "->pointer()", such
37  * as it matches a given plain pointer "ptr". */
38  template <typename PTR>
39  typename std::list<T>::iterator find_ptr_to(const PTR ptr)
40  {
41  for (typename std::list<T>::iterator it = std::list<T>::begin();
42  it != std::list<T>::end(); it++)
43  if (it->get() == ptr) return it;
44  return std::list<T>::end();
45  }
46 
47  /** Finds an element in a list of smart pointers, having "->pointer()", such
48  * as it matches a given plain pointer "ptr". */
49  template <typename PTR>
50  typename std::list<T>::const_iterator find_ptr_to(const PTR ptr) const
51  {
53  it != std::list<T>::end(); it++)
54  if (it->pointer() == ptr) return it;
55  return std::list<T>::end();
56  }
57 };
58 }
59 
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:217
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
const Scalar * const_iterator
Definition: eigen_plugins.h:27



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020