3 //=============================================================================
5 * @file Intrusive_List.h
7 * @author Carlos O'Ryan <coryan@uci.edu>
9 //=============================================================================
11 #ifndef ACE_INTRUSIVE_LIST_H
12 #define ACE_INTRUSIVE_LIST_H
13 #include /**/ "ace/pre.h"
15 #include /**/ "ace/config-lite.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
24 * @class ACE_Intrusive_List
26 * @brief Implement an intrusive double linked list
28 * Intrusive lists assume that the elements they contain the pointers
29 * required to build the list. They are useful as light-weight
30 * containers and free-lists.
32 * The template argument T must implement the following methods:
34 * - T* T::next () const;
35 * - void T::next (T *);
36 * - T* T::prev () const;
37 * - void T::prev (T* );
39 * A simple way to satisfy the Intrusive_List requirements would be to
40 * implement a helper class:
42 * class My_Object : public ACE_Intrusive_List_Node<My_Object> {<BR>
46 * typedef ACE_Intrusive_List<My_Object> My_Object_List;
48 * However, ACE is supported on platforms that would surely get
49 * confused using such templates.
51 * @todo The ACE_Message_Queue is an example of an intrusive list (or
52 * queue) but it is not implemented in terms of this class.
55 class ACE_Intrusive_List
58 /// Constructor. Use user specified allocation strategy
60 ACE_Intrusive_List () = default;
63 ~ACE_Intrusive_List () = default;
65 // = Check boundary conditions.
67 /// Returns true if the container is empty, otherwise returns false.
68 bool is_empty () const;
70 /// Insert an element at the beginning of the list
71 void push_front (T
*node
);
73 /// Insert an element at the end of the list
74 void push_back (T
*node
);
76 /// Remove the element at the beginning of the list
79 /// Remove the element at the end of the list
82 /// Get the element at the head of the queue
85 /// Get the element at the tail of the queue
88 /// Remove a element from the list
90 * Verify that the element is still in the list before removing it.
92 void remove (T
*node
);
95 void swap(ACE_Intrusive_List
<T
> & rhs
);
97 /// Remove a element from the list without checking
99 * No attempts are performed to check if T* really belongs to the
100 * list. The effects of removing an invalid element are unspecified
102 void unsafe_remove (T
*node
);
105 /** @name Disallow copying
109 ACE_Intrusive_List (const ACE_Intrusive_List
<T
> &);
110 ACE_Intrusive_List
<T
>& operator= (const ACE_Intrusive_List
<T
> &);
121 ACE_END_VERSIONED_NAMESPACE_DECL
123 #if defined (__ACE_INLINE__)
124 #include "ace/Intrusive_List.inl"
125 #endif /* __ACE_INLINE__ */
127 #include "ace/Intrusive_List.cpp"
129 #include /**/ "ace/post.h"
130 #endif /* ACE_INTRUSIVE_LIST_H */