#include <Intrusive_List.h>
Collaboration diagram for ACE_Intrusive_List< T >:
Public Member Functions | |
ACE_Intrusive_List (void) | |
~ACE_Intrusive_List (void) | |
Destructor. | |
int | is_empty (void) const |
Returns 1 if the container is empty, otherwise returns 0. | |
int | empty (void) const |
void | push_front (T *node) |
Insert an element at the beginning of the list. | |
void | push_back (T *node) |
Insert an element at the end of the list. | |
T * | pop_front (void) |
Remove the element at the beginning of the list. | |
T * | pop_back (void) |
Remove the element at the end of the list. | |
T * | head (void) const |
Get the element at the head of the queue. | |
T * | tail (void) const |
Get the element at the tail of the queue. | |
void | remove (T *node) |
Remove a element from the list. | |
void | swap (ACE_Intrusive_List< T > &rhs) |
Swap two lists. | |
void | unsafe_remove (T *node) |
Remove a element from the list without checking. | |
Private Member Functions | |
Disallow copying | |
ACE_Intrusive_List (const ACE_Intrusive_List< T > &) | |
ACE_Intrusive_List< T > & | operator= (const ACE_Intrusive_List< T > &) |
Private Attributes | |
T * | head_ |
Head of the list. | |
T * | tail_ |
Tail of the list. |
Intrusive lists assume that the elements they contain the pointers required to build the list. They are useful as light-weight containers and free-lists.
The template argument T must implement the following methods:
A simple way to satisfy the Intrusive_List requirements would be to implement a helper class:
class My_Object : public ACE_Intrusive_List_Node<My_Object> {
....
};
typedef ACE_Intrusive_List<My_Object> My_Object_List;
However, ACE is supported on platforms that would surely get confused using such templates.
Definition at line 58 of file Intrusive_List.h.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Intrusive_List< T >::ACE_Intrusive_List | ( | void | ) |
Constructor. Use user specified allocation strategy if specified.
Definition at line 19 of file Intrusive_List.cpp.
ACE_Intrusive_List< T >::~ACE_Intrusive_List | ( | void | ) |
ACE_Intrusive_List< T >::ACE_Intrusive_List | ( | const ACE_Intrusive_List< T > & | ) | [private] |
ACE_INLINE int ACE_Intrusive_List< T >::empty | ( | void | ) | const |
Returns 1 if the container is empty, otherwise returns 0.
Definition at line 16 of file Intrusive_List.inl.
References ACE_Intrusive_List< T >::is_empty().
00017 { 00018 return this->is_empty (); 00019 }
ACE_INLINE T * ACE_Intrusive_List< T >::head | ( | void | ) | const |
Get the element at the head of the queue.
Definition at line 22 of file Intrusive_List.inl.
References ACE_Intrusive_List< T >::head_.
Referenced by ACE_Notification_Queue::pop_next_notification(), ACE_Notification_Queue::purge_pending_notifications(), and ACE_Notification_Queue::reset().
00023 { 00024 return this->head_; 00025 }
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_Intrusive_List< T >::is_empty | ( | void | ) | const |
Returns 1 if the container is empty, otherwise returns 0.
Definition at line 10 of file Intrusive_List.inl.
References ACE_Intrusive_List< T >::head_.
Referenced by ACE_Intrusive_List< T >::empty(), ACE_Notification_Queue::pop_next_notification(), and ACE_Notification_Queue::push_new_notification().
00011 { 00012 return this->head_ == 0; 00013 }
ACE_Intrusive_List<T>& ACE_Intrusive_List< T >::operator= | ( | const ACE_Intrusive_List< T > & | ) | [private] |
T * ACE_Intrusive_List< T >::pop_back | ( | void | ) |
Remove the element at the end of the list.
Definition at line 77 of file Intrusive_List.cpp.
References ACE_Intrusive_List< T >::tail_, and ACE_Intrusive_List< T >::unsafe_remove().
00078 { 00079 T *node = this->tail_; 00080 if (node == 0) 00081 return 0; 00082 this->unsafe_remove (node); 00083 return node; 00084 }
T * ACE_Intrusive_List< T >::pop_front | ( | void | ) |
Remove the element at the beginning of the list.
Definition at line 67 of file Intrusive_List.cpp.
References ACE_Intrusive_List< T >::head_, and ACE_Intrusive_List< T >::unsafe_remove().
Referenced by ACE_Notification_Queue::pop_next_notification(), and ACE_Notification_Queue::push_new_notification().
00068 { 00069 T *node = this->head_; 00070 if (node == 0) 00071 return 0; 00072 this->unsafe_remove (node); 00073 return node; 00074 }
void ACE_Intrusive_List< T >::push_back | ( | T * | node | ) |
Insert an element at the end of the list.
Definition at line 31 of file Intrusive_List.cpp.
References ACE_Intrusive_List< T >::head_, and ACE_Intrusive_List< T >::tail_.
Referenced by ACE_Notification_Queue::push_new_notification().
00032 { 00033 if (this->tail_ == 0) 00034 { 00035 this->tail_ = node; 00036 this->head_ = node; 00037 node->next (0); 00038 node->prev (0); 00039 return; 00040 } 00041 00042 this->tail_->next (node); 00043 node->prev (this->tail_); 00044 node->next (0); 00045 this->tail_ = node; 00046 }
void ACE_Intrusive_List< T >::push_front | ( | T * | node | ) |
Insert an element at the beginning of the list.
Definition at line 49 of file Intrusive_List.cpp.
References ACE_Intrusive_List< T >::head_, and ACE_Intrusive_List< T >::tail_.
Referenced by ACE_Notification_Queue::allocate_more_buffers(), ACE_Notification_Queue::pop_next_notification(), and ACE_Notification_Queue::purge_pending_notifications().
00050 { 00051 if (this->head_ == 0) 00052 { 00053 this->tail_ = node; 00054 this->head_ = node; 00055 node->next (0); 00056 node->prev (0); 00057 return; 00058 } 00059 00060 this->head_->prev (node); 00061 node->next (this->head_); 00062 node->prev (0); 00063 this->head_ = node; 00064 }
void ACE_Intrusive_List< T >::remove | ( | T * | node | ) |
Remove a element from the list.
Verify that the element is still in the list before removing it.
Definition at line 87 of file Intrusive_List.cpp.
References ACE_Intrusive_List< T >::unsafe_remove().
00088 { 00089 for (T *i = this->head_; i != 0; i = i->next ()) 00090 { 00091 if (node == i) 00092 { 00093 this->unsafe_remove (node); 00094 return; 00095 } 00096 } 00097 }
ACE_INLINE void ACE_Intrusive_List< T >::swap | ( | ACE_Intrusive_List< T > & | rhs | ) |
Swap two lists.
Definition at line 34 of file Intrusive_List.inl.
References ACE_Intrusive_List< T >::head_, and ACE_Intrusive_List< T >::tail_.
ACE_INLINE T * ACE_Intrusive_List< T >::tail | ( | void | ) | const |
Get the element at the tail of the queue.
Definition at line 28 of file Intrusive_List.inl.
References ACE_Intrusive_List< T >::tail_.
00029 { 00030 return this->tail_; 00031 }
void ACE_Intrusive_List< T >::unsafe_remove | ( | T * | node | ) |
Remove a element from the list without checking.
No attempts are performed to check if T* really belongs to the list. The effects of removing an invalid element are unspecified
Definition at line 100 of file Intrusive_List.cpp.
References ACE_Intrusive_List< T >::head_, and ACE_Intrusive_List< T >::tail_.
Referenced by ACE_Intrusive_List< T >::pop_back(), ACE_Intrusive_List< T >::pop_front(), ACE_Notification_Queue::purge_pending_notifications(), and ACE_Intrusive_List< T >::remove().
00101 { 00102 if (node->prev () != 0) 00103 node->prev ()->next (node->next ()); 00104 else 00105 this->head_ = node->next (); 00106 00107 if (node->next () != 0) 00108 node->next ()->prev (node->prev ()); 00109 else 00110 this->tail_ = node->prev (); 00111 00112 node->next (0); 00113 node->prev (0); 00114 }
T* ACE_Intrusive_List< T >::head_ [private] |
Head of the list.
Definition at line 123 of file Intrusive_List.h.
Referenced by ACE_Intrusive_List< T >::head(), ACE_Intrusive_List< T >::is_empty(), ACE_Intrusive_List< T >::pop_front(), ACE_Intrusive_List< T >::push_back(), ACE_Intrusive_List< T >::push_front(), ACE_Intrusive_List< T >::swap(), and ACE_Intrusive_List< T >::unsafe_remove().
T* ACE_Intrusive_List< T >::tail_ [private] |
Tail of the list.
Definition at line 126 of file Intrusive_List.h.
Referenced by ACE_Intrusive_List< T >::pop_back(), ACE_Intrusive_List< T >::push_back(), ACE_Intrusive_List< T >::push_front(), ACE_Intrusive_List< T >::swap(), ACE_Intrusive_List< T >::tail(), and ACE_Intrusive_List< T >::unsafe_remove().