3 //=============================================================================
5 * @file Intrusive_List.h
7 * $Id: Intrusive_List.h 80826 2008-03-04 14:51:23Z wotte $
9 * @author Carlos O'Ryan <coryan@uci.edu>
11 //=============================================================================
13 #ifndef ACE_INTRUSIVE_LIST_H
14 #define ACE_INTRUSIVE_LIST_H
15 #include /**/ "ace/pre.h"
17 #include /**/ "ace/config-all.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
26 * @class ACE_Intrusive_List
28 * @brief Implement an intrusive double linked list
30 * Intrusive lists assume that the elements they contain the pointers
31 * required to build the list. They are useful as light-weight
32 * containers and free-lists.
34 * The template argument T must implement the following methods:
36 * - T* T::next () const;
37 * - void T::next (T *);
38 * - T* T::prev () const;
39 * - void T::prev (T* );
41 * A simple way to satisfy the Intrusive_List requirements would be to
42 * implement a helper class:
44 * class My_Object : public ACE_Intrusive_List_Node<My_Object> {<BR>
48 * typedef ACE_Intrusive_List<My_Object> My_Object_List;
50 * However, ACE is supported on platforms that would surely get
51 * confused using such templates.
53 * @todo The ACE_Message_Queue is an example of an intrusive list (or
54 * queue) but it is not implemented in terms of this class.
58 class ACE_Intrusive_List
61 // = Initialization and termination methods.
62 /// Constructor. Use user specified allocation strategy
64 ACE_Intrusive_List (void);
67 ~ACE_Intrusive_List (void);
69 // = Check boundary conditions.
71 /// Returns 1 if the container is empty, otherwise returns 0.
72 int is_empty (void) const;
74 /// Returns 1 if the container is empty, otherwise returns 0.
75 /// @deprecated Use is_empty() instead.
76 int empty (void) const;
78 /// Insert an element at the beginning of the list
79 void push_front (T
*node
);
81 /// Insert an element at the end of the list
82 void push_back (T
*node
);
84 /// Remove the element at the beginning of the list
87 /// Remove the element at the end of the list
90 /// Get the element at the head of the queue
93 /// Get the element at the tail of the queue
96 /// Remove a element from the list
98 * Verify that the element is still in the list before removing it.
100 void remove (T
*node
);
103 void swap(ACE_Intrusive_List
<T
> & rhs
);
105 /// Remove a element from the list without checking
107 * No attempts are performed to check if T* really belongs to the
108 * list. The effects of removing an invalid element are unspecified
110 void unsafe_remove (T
*node
);
113 /** @name Disallow copying
117 ACE_Intrusive_List (const ACE_Intrusive_List
<T
> &);
118 ACE_Intrusive_List
<T
>& operator= (const ACE_Intrusive_List
<T
> &);
129 ACE_END_VERSIONED_NAMESPACE_DECL
131 #if defined (__ACE_INLINE__)
132 #include "ace/Intrusive_List.inl"
133 #endif /* __ACE_INLINE__ */
135 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
136 #include "ace/Intrusive_List.cpp"
137 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
139 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
140 #pragma implementation ("Intrusive_List.cpp")
141 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
143 #include /**/ "ace/post.h"
144 #endif /* ACE_INTRUSIVE_LIST_H */