service_discovery
List.hpp
Go to the documentation of this file.
1 #ifndef _SERVICE_DISCOVERY_LIST_H_
2 #define _SERVICE_DISCOVERY_LIST_H_
3 
4 #include <list>
5 #include <iostream>
6 
7 namespace servicediscovery {
8 
12 template <class T>
13 class List : public std::list<T> {
14 public:
15  typename std::list<T>::iterator find(const T &x)
16  {
17 
18  typename std::list<T>::iterator it;
19  for (it = this->begin(); it != this->end(); it++) {
20  if ((*it) == x) {
21  return it;
22  }
23  }
24  return this->end();
25 
26  }
27 
28 };
29 
30 
34 template <class T>
35 class List <T*> : public std::list<T*> {
36 public:
37  typename std::list<T>::iterator find(T &x)
38  {
39  typename std::list<T*>::iterator it;
40  for (it = this->begin() ; it != this->end(); it++) {
41  T* ptr = (*it);
42  if ((*ptr) == x) {
43  return it;
44  }
45  }
46  return this->end();
47  }
48 };
49 
50 } // end namespace servicediscovery
51 
52 
53 #endif /* _SERVICE_DISCOVERY_LIST_H_ */
Definition: Client.cpp:7
Definition: List.hpp:13
std::list< T >::iterator find(const T &x)
Definition: List.hpp:15
std::list< T >::iterator find(T &x)
Definition: List.hpp:37