tcpflow  1.6.1
About: tcpflow is a TCP/IP packet demultiplexer that captures data transmitted as part of TCP connections (flows), and stores the data in a way that is convenient for protocol analysis and debugging.
  Fossies Dox: tcpflow-1.6.1.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

intrusive_list.h
Go to the documentation of this file.
1 #ifndef INTRUSIVE_LIST_H
2 #define INTRUSIVE_LIST_H
3 
4 #include <iostream>
5 #include <list>
6 
7 // implement boost::intrusive::list using std::list
8 
9 template <class T>
11  public:
12  intrusive_list():li(), len(0) {}
13 
14  typedef typename std::list<T*>::iterator iterator;
15 
16  inline void push_back(T* node) {
17  li.push_back(node);
18  len++;
19  node->it = --li.end();
20  }
21 
22  inline void erase(T* node) {
23  if (!is_linked(node))
24  return;
25  li.erase(node->it);
26  len--;
27  reset(node);
28  }
29 
30  inline void move_to_end(T* node) {
31  if (!is_linked(node))
32  return;
33  li.splice(li.end(), li, node->it);
34  }
35 
36  inline void reset(T* node) {
37  node->it = li.end();
38  }
39 
40  inline bool empty() {
41  return li.empty();
42  }
43 
44  inline size_t size() {
45  // std::list.size() is O(n) in some platform. Is there any define flag for that?
46  //return li.size();
47  return len;
48  }
49 
50  inline iterator begin() {
51  return li.begin();
52  }
53 
54  inline iterator end() {
55  return li.end();
56  }
57 
58  private:
59  inline bool is_linked(T* node) {
60  return node->it != li.end();
61  }
62 
63  std::list<T*> li;
64  size_t len;
65 };
66 
67 #endif // INTRUSIVE_LIST_H
bool is_linked(T *node)
void move_to_end(T *node)
std::list< T * > li
std::list< T * >::iterator iterator
iterator begin()
iterator end()
void push_back(T *node)
void erase(T *node)
void reset(T *node)
#define T(v)
Definition: http_parser.c:236