#include <Naming_Service_Container.h>
Collaboration diagram for ACE_Unbounded_List< T >:
Public Types | |
typedef ACE_Unbounded_List_Iterator< T > | ITERATOR |
typedef ACE_Unbounded_List_Iterator< T > | iterator |
Public Member Functions | |
ACE_Unbounded_List (ACE_Allocator *alloc=0) | |
ACE_Unbounded_List (const ACE_Unbounded_List< T > &) | |
Copy constructor. | |
void | operator= (const ACE_Unbounded_List< T > &) |
Assignment operator. | |
~ACE_Unbounded_List (void) | |
Destructor. | |
int | is_empty (void) const |
Returns 1 if the container is empty, otherwise returns 0. | |
int | is_full (void) const |
Returns 1 if the container is full, otherwise returns 0. | |
int | insert (const T &new_item) |
int | remove (const T &item) |
size_t | size (void) const |
Size of the set. | |
void | dump (void) const |
Dump the state of an object. | |
void | reset (void) |
Reset the to be empty. | |
ACE_Unbounded_List_Iterator< T > | begin (void) |
ACE_Unbounded_List_Iterator< T > | end (void) |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
Private Member Functions | |
int | insert_tail (const T &item) |
void | delete_nodes (void) |
Delete all the nodes in the List. | |
void | copy_nodes (const ACE_Unbounded_List< T > &) |
Copy nodes into this set. | |
Private Attributes | |
ACE_NS_Node< T > * | head_ |
Head of the linked list of NS_Nodes. | |
size_t | cur_size_ |
Current size of the set. | |
ACE_Allocator * | allocator_ |
Allocation strategy of the set. | |
Friends | |
class | ACE_Unbounded_List_Iterator< T > |
This implementation of an unordered set uses a circular linked list with a dummy node. This implementation does not allow duplicates, but it maintains FIFO ordering of insertions.
Definition at line 139 of file Naming_Service_Container.h.
|
Definition at line 146 of file Naming_Service_Container.h. |
|
Definition at line 145 of file Naming_Service_Container.h. |
|
Constructor. Use user specified allocation strategy if specified. Definition at line 169 of file Naming_Service_Container.cpp. References ACE_NEW_MALLOC, and ACE_Allocator::instance().
00170 : head_ (0), 00171 cur_size_ (0), 00172 allocator_ (alloc) 00173 { 00174 // ACE_TRACE ("ACE_Unbounded_List<T>::ACE_Unbounded_List"); 00175 00176 if (this->allocator_ == 0) 00177 this->allocator_ = ACE_Allocator::instance (); 00178 00179 ACE_NEW_MALLOC (this->head_, 00180 (ACE_NS_Node<T>*) this->allocator_->malloc (sizeof (ACE_NS_Node<T>)), 00181 ACE_NS_Node<T>); 00182 // Make the list circular by pointing it back to itself. 00183 this->head_->next_ = this->head_; 00184 } |
|
Copy constructor.
Definition at line 187 of file Naming_Service_Container.cpp. References ACE_NEW_MALLOC, ACE_TRACE, ACE_Unbounded_List< T >::copy_nodes(), and ACE_Allocator::instance().
00188 : head_ (0), 00189 cur_size_ (0), 00190 allocator_ (us.allocator_) 00191 { 00192 ACE_TRACE ("ACE_Unbounded_List<T>::ACE_Unbounded_List"); 00193 00194 if (this->allocator_ == 0) 00195 this->allocator_ = ACE_Allocator::instance (); 00196 00197 ACE_NEW_MALLOC (this->head_, 00198 (ACE_NS_Node<T>*) this->allocator_->malloc (sizeof (ACE_NS_Node<T>)), 00199 ACE_NS_Node<T>); 00200 this->head_->next_ = this->head_; 00201 this->copy_nodes (us); 00202 } |
|
Destructor.
Definition at line 154 of file Naming_Service_Container.cpp. References ACE_DES_FREE_TEMPLATE, and ACE_Unbounded_List< T >::delete_nodes().
00155 { 00156 // ACE_TRACE ("ACE_Unbounded_List<T>::~ACE_Unbounded_List"); 00157 00158 this->delete_nodes (); 00159 00160 // Delete the dummy node. 00161 ACE_DES_FREE_TEMPLATE (head_, 00162 this->allocator_->free, 00163 ACE_NS_Node, 00164 <T>); 00165 this->head_ = 0; 00166 } |
|
Definition at line 253 of file Naming_Service_Container.cpp.
00254 { 00255 // ACE_TRACE ("ACE_Unbounded_List<T>::begin"); 00256 return ACE_Unbounded_List_Iterator<T> (*this); 00257 } |
|
Copy nodes into this set.
Definition at line 123 of file Naming_Service_Container.cpp. References ACE_Unbounded_List< T >::head_, ACE_Unbounded_List< T >::insert_tail(), ACE_NS_Node< T >::item_, and ACE_NS_Node< T >::next_. Referenced by ACE_Unbounded_List< T >::ACE_Unbounded_List(), and ACE_Unbounded_List< T >::operator=().
00124 { 00125 for (ACE_NS_Node<T> *curr = us.head_->next_; 00126 curr != us.head_; 00127 curr = curr->next_) 00128 this->insert_tail (curr->item_); 00129 } |
|
Delete all the nodes in the List.
Definition at line 132 of file Naming_Service_Container.cpp. References ACE_DES_FREE_TEMPLATE, and ACE_NS_Node< T >::next_. Referenced by ACE_Unbounded_List< T >::operator=(), ACE_Unbounded_List< T >::reset(), and ACE_Unbounded_List< T >::~ACE_Unbounded_List().
00133 { 00134 ACE_NS_Node<T> *curr = this->head_->next_; 00135 00136 // Keep looking until we've hit the dummy node. 00137 00138 while (curr != this->head_) 00139 { 00140 ACE_NS_Node<T> *temp = curr; 00141 curr = curr->next_; 00142 ACE_DES_FREE_TEMPLATE (temp, 00143 this->allocator_->free, 00144 ACE_NS_Node, 00145 <T>); 00146 this->cur_size_--; 00147 } 00148 00149 // Reset the list to be a circular list with just a dummy node. 00150 this->head_->next_ = this->head_; 00151 } |
|
Dump the state of an object.
Definition at line 100 of file Naming_Service_Container.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_TEXT, ACE_TRACE, ACE_Unbounded_List_Iterator< T >::advance(), LM_DEBUG, and ACE_Unbounded_List_Iterator< T >::next().
00101 { 00102 ACE_TRACE ("ACE_Unbounded_List<T>::dump"); 00103 00104 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); 00105 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhead_ = %u"), this->head_)); 00106 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhead_->next_ = %u"), this->head_->next_)); 00107 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ncur_size_ = %d\n"), this->cur_size_)); 00108 00109 T *item = 0; 00110 #if !defined (ACE_NLOGGING) 00111 size_t count = 1; 00112 #endif /* ! ACE_NLOGGING */ 00113 00114 for (ACE_Unbounded_List_Iterator<T> iter (*(ACE_Unbounded_List<T> *) this); 00115 iter.next (item) != 0; 00116 iter.advance ()) 00117 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("count = %d\n"), count++)); 00118 00119 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); 00120 } |
|
Definition at line 260 of file Naming_Service_Container.cpp.
00261 { 00262 // ACE_TRACE ("ACE_Unbounded_List<T>::end"); 00263 return ACE_Unbounded_List_Iterator<T> (*this, 1); 00264 } |
|
Insert into the set (doesn't allow duplicates). Returns -1 if failures occur, 1 if item is already present, else 0. Definition at line 217 of file Naming_Service_Container.cpp. References ACE_TRACE, and ACE_Unbounded_List< T >::insert_tail().
00218 { 00219 ACE_TRACE ("ACE_Unbounded_List<T>::insert"); 00220 return this->insert_tail (item); 00221 } |
|
Insert at the tail of the set (doesn't check for duplicates). Definition at line 69 of file Naming_Service_Container.cpp. References ACE_NEW_MALLOC_RETURN. Referenced by ACE_Unbounded_List< T >::copy_nodes(), and ACE_Unbounded_List< T >::insert().
00070 { 00071 ACE_NS_Node<T> *temp; 00072 00073 // Insert <item> into the old dummy node location. 00074 this->head_->item_ = item; 00075 00076 // Create a new dummy node. 00077 ACE_NEW_MALLOC_RETURN (temp, 00078 (ACE_NS_Node<T>*) this->allocator_->malloc (sizeof (ACE_NS_Node<T>)), 00079 ACE_NS_Node<T> (this->head_->next_), 00080 -1); 00081 // Link this pointer into the list. 00082 this->head_->next_ = temp; 00083 00084 // Point the head to the new dummy node. 00085 this->head_ = temp; 00086 00087 this->cur_size_++; 00088 return 0; 00089 } |
|
Returns 1 if the container is empty, otherwise returns 0.
Definition at line 373 of file Naming_Service_Container.cpp. References ACE_TRACE.
|
|
Returns 1 if the container is full, otherwise returns 0.
Definition at line 380 of file Naming_Service_Container.cpp. References ACE_TRACE.
00381 { 00382 ACE_TRACE ("ACE_Unbounded_List<T>::is_full"); 00383 return 0; // We should implement a "node of last resort for this..." 00384 } |
|
Assignment operator.
Definition at line 205 of file Naming_Service_Container.cpp. References ACE_TRACE, ACE_Unbounded_List< T >::copy_nodes(), and ACE_Unbounded_List< T >::delete_nodes().
00206 { 00207 ACE_TRACE ("ACE_Unbounded_List<T>::operator="); 00208 00209 if (this != &us) 00210 { 00211 this->delete_nodes (); 00212 this->copy_nodes (us); 00213 } 00214 } |
|
Remove first occurrence of from the set. Returns 0 if it removes the item, -1 if it can't find the item, and -1 if a failure occurs. Definition at line 224 of file Naming_Service_Container.cpp. References ACE_DES_FREE_TEMPLATE, and ACE_NS_Node< T >::next_.
00225 { 00226 // ACE_TRACE ("ACE_Unbounded_List<T>::remove"); 00227 00228 // Insert the item to be founded into the dummy node. 00229 this->head_->item_ = item; 00230 00231 ACE_NS_Node<T> *curr = this->head_; 00232 00233 while (!(curr->next_->item_ == item)) 00234 curr = curr->next_; 00235 00236 if (curr->next_ == this->head_) 00237 return -1; // Item was not found. 00238 else 00239 { 00240 ACE_NS_Node<T> *temp = curr->next_; 00241 // Skip over the node that we're deleting. 00242 curr->next_ = temp->next_; 00243 this->cur_size_--; 00244 ACE_DES_FREE_TEMPLATE (temp, 00245 this->allocator_->free, 00246 ACE_NS_Node, 00247 <T>); 00248 return 0; 00249 } 00250 } |
|
Reset the to be empty.
Definition at line 92 of file Naming_Service_Container.cpp. References ACE_TRACE, and ACE_Unbounded_List< T >::delete_nodes().
00093 { 00094 ACE_TRACE ("reset"); 00095 00096 this->delete_nodes (); 00097 } |
|
Size of the set.
Definition at line 62 of file Naming_Service_Container.cpp.
00063 { 00064 // ACE_TRACE ("ACE_Unbounded_List<T>::size"); 00065 return this->cur_size_; 00066 } |
|
Definition at line 142 of file Naming_Service_Container.h. |
|
Declare the dynamic allocation hooks.
Definition at line 200 of file Naming_Service_Container.h. |
|
Allocation strategy of the set.
Definition at line 220 of file Naming_Service_Container.h. |
|
Current size of the set.
Definition at line 217 of file Naming_Service_Container.h. |
|
Head of the linked list of NS_Nodes.
Definition at line 214 of file Naming_Service_Container.h. Referenced by ACE_Unbounded_List< T >::copy_nodes(). |