summaryrefslogtreecommitdiff
path: root/ace/Containers.cpp
diff options
context:
space:
mode:
authornw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-10-16 03:49:35 +0000
committernw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-10-16 03:49:35 +0000
commit791def41394ca14cf0a5faff984b7fac924034da (patch)
tree2a33af29fb95b167bec87402a3fa3b02753d36ea /ace/Containers.cpp
parent840c657ad5baad85a798a1323842d02b2b997dfa (diff)
downloadATCD-791def41394ca14cf0a5faff984b7fac924034da.tar.gz
*** empty log message ***
Diffstat (limited to 'ace/Containers.cpp')
-rw-r--r--ace/Containers.cpp287
1 files changed, 287 insertions, 0 deletions
diff --git a/ace/Containers.cpp b/ace/Containers.cpp
index d78dab66e51..d77dc18511f 100644
--- a/ace/Containers.cpp
+++ b/ace/Containers.cpp
@@ -630,6 +630,274 @@ ACE_Unbounded_Queue_Iterator<T>::next (T *&item)
}
}
+//--------------------------------------------------
+#if defined (NANBOR_EXP_CODES)
+ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Iterator)
+
+template <class T>
+ACE_Double_Linked_List_Iterator<T>::ACE_Double_Linked_List_Iterator
+(ACE_Double_Linked_List<T> &dll)
+ : ACE_Double_Linked_List_Iterator_Base (dll)
+{
+}
+
+template <class T> ACE_DNode<T> *
+ACE_Double_Linked_List_Iterator<T>::next (void)
+{
+ return this->not_done ();
+}
+
+template <class T> int
+ACE_Double_Linked_List_Iterator<T>::next (T *&item)
+{
+ ACE_DNode<T> *ptr = this->not_done ();
+
+ if (ptr != 0)
+ {
+ item = &ptr->item_;
+ return 1;
+ }
+ else
+ return 0;
+}
+
+template <class T> int
+ACE_Double_Linked_List_Iterator<T>::advance (void)
+{
+ return (this->do_advance () ? 1 : 0);
+}
+
+template <class T> int
+ACE_Double_Linked_List_Iterator<T>::done (void) const
+{
+ return (this->not_done () ? 0 : 1);
+}
+
+template <class T> void
+ACE_Double_Linked_List_Iterator<T>::dump (void) const
+{
+ // Dump the state of an object.
+}
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List)
+
+template <class T>
+ACE_Double_Linked_List<T>:: ACE_Double_Linked_List (ACE_Allocator *alloc)
+ : allocator_ (alloc)
+{
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ delete this->head_;
+ ACE_NEW_MALLOC (this->head_,
+ (ACE_DNode<T>*) this->allocator_->malloc (sizeof (ACE_DNode<T>)),
+ ACE_DNode<T>);
+
+ this->init_head ();
+}
+
+template <class T>
+ACE_Double_Linked_List<T>::ACE_Double_Linked_List (const ACE_Double_Linked_List<T> &cx)
+ : allocator_ (cx.allocator_)
+{
+ if (this->allocator_ == 0)
+ this->allocator_ = ACE_Allocator::instance ();
+
+ ACE_NEW_MALLOC (this->head_,
+ (ACE_DNode<T>*) this->allocator_->malloc (sizeof (ACE_DNode<T>)),
+ ACE_DNode<T>);
+ this->init_head ();
+ this->copy_nodes (cx);
+}
+
+template <class T> void
+ACE_Double_Linked_List<T>::operator= (const ACE_Double_Linked_List<T> &cx)
+{
+ if (this != &cx)
+ {
+ this->delete_nodes ();
+ this->copy_nodes (cx);
+ }
+}
+
+template <class T>
+ACE_Double_Linked_List<T>::~ACE_Double_Linked_List (void)
+{
+ this->delete_nodes ();
+ ACE_DES_FREE_TEMPLATE (this->head_, this->allocator_->free,
+ ACE_DNode, <T>);
+ this->head_ = 0;
+}
+
+template <class T> int
+ACE_Double_Linked_List<T>::is_empty (void) const
+{
+ return (this->size () ? 0 : 1);
+}
+
+template <class T> int
+ACE_Double_Linked_List<T>::is_full (void) const
+{
+ return 0; // We have no bound.
+}
+
+template <class T> ACE_DNode<T> *
+ACE_Double_Linked_List<T>::insert_tail (const T &new_item)
+{
+ ACE_DNode<T> *temp;
+
+ // Create a new dummy node.
+ ACE_NEW_MALLOC_RETURN (temp,
+ (ACE_DNode<T>*) this->allocator_->malloc (sizeof (ACE_DNode<T>)),
+ ACE_DNode<T> (new_item), -1);
+
+ this->insert_element (temp, 1); // Insert it before <head_>, i.e., at tail.
+ return 0;
+}
+
+template <class T> ACE_DNode<T> *
+ACE_Double_Linked_List<T>::insert_head (const T &new_item)
+{
+ ACE_DNode<T> *temp;
+
+ // Create a new dummy node.
+ ACE_NEW_MALLOC_RETURN (temp,
+ (ACE_DNode<T>*) this->allocator_->malloc (sizeof (ACE_DNode<T>)),
+ ACE_DNode<T> (new_item), -1);
+
+ this->insert_element (temp); // Insert it after <head_>, i.e., at head.
+ return 0;
+}
+
+template <class T> int
+ACE_Double_Linked_List<T>::delete_head (T &item)
+{
+ ACE_DNode<T> *temp;
+
+ if (this->is_empty ())
+ return -1;
+
+ temp = this->head_->next_;
+ item = temp->item_;
+ this->remove_element (temp); // Detach it from the list.
+ ACE_DES_FREE_TEMPLATE (temp, this->allocator_->free,
+ ACE_DNode, <T>);
+ return 0;
+}
+
+template <class T> int
+ACE_Double_Linked_List<T>::delete_tail (T &item)
+{
+ ACE_DNode<T> *temp;
+
+ if (this->is_empty ())
+ return -1;
+
+ temp = this->head_->prev_;
+ item = temp->item_;
+ this->remove_element (temp); // Detach it from the list.
+ ACE_DES_FREE_TEMPLATE (temp, this->allocator_->free,
+ ACE_DNode, <T>);
+ return 0;
+}
+
+template <class T> void
+ACE_Double_Linked_List<T>::reset (void)
+{
+ this->delete_nodes ();
+}
+
+template <class T> int
+ACE_Double_Linked_List<T>::get (T *&item, size_t index = 0) const
+{
+ ACE_Double_Linked_List_Iterator<T> iter (*this);
+
+ for (size_t i = 0; i < index && !iter.done (); i++, iter.advance ())
+ ;
+ if (iter.next (item))
+ return 0;
+ else
+ return -1;
+}
+
+template <class T> int
+ACE_Double_Linked_List<T>::set (const T &item, size_t index)
+{
+ ACE_Double_Linked_List_Iterator<T> iter (*this);
+
+ for (size_t i = 0; i < index && !iter.done (); i++, iter.advance ())
+ ;
+ ACE_DNode<T> *temp = iter.next ();
+ if (temp)
+ {
+ temp->item_ = item;
+ return 0;
+ }
+ else
+ return -1;
+}
+
+template <class T> size_t
+ACE_Double_Linked_List<T>::size (void) const
+{
+ return this->size_;
+}
+
+template <class T> void
+ACE_Double_Linked_List<T>::dump (void) const
+{
+ // Dump the state of an object.
+}
+
+template <class T> ACE_DNode<T> *
+ACE_Double_Linked_List<T>::find (const T &item)
+{
+ ACE_Double_Linked_List_Iterator<T> iter (*this);
+
+ for (;!iter.done (); iter.advance ())
+ {
+ ACE_DNode<T> *temp = iter.next ();
+ if (temp->item_ == item)
+ return temp;
+ }
+ return 0;
+}
+
+template <class T> int
+ACE_Double_Linked_List<T>::remove (const T &item)
+{
+ ACE_DNode<T> *temp = this->find (item);
+ if (temp != 0)
+ return this->remove (temp);
+ else
+ return -1;
+}
+
+template <class T> int
+ACE_Double_Linked_List<T>::remove (ACE_DNode<T> *n)
+{
+ return this->remove_element (n);
+}
+
+template <class T> void
+ACE_Double_Linked_List<T>::delete_nodes (void)
+{
+ while (! this->is_empty ())
+ this->remove_element (this->head_->next_);
+}
+
+template <class T> void
+ACE_Double_Linked_List<T>::copy_nodes (const ACE_Double_Linked_List<T> &c)
+{
+ ACE_Double_Linked_List_Iterator<T> iter (c);
+
+ for (; !iter.done (); iter.advance ())
+ this->insert_head (iter.next ()->item_);
+}
+
+#endif /* NANBOR_EXP_CODE */
+//--------------------------------------------------
+
ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set)
template <class T, size_t SIZE> size_t
@@ -1069,6 +1337,25 @@ ACE_Node<T>::ACE_Node (const ACE_Node<T> &s)
// ACE_TRACE ("ACE_Node<T>::ACE_Node");
}
+#if defined (NANBOT_EXP_CODES)
+template <class T>
+ACE_DNode<T>::ACE_DNode (const T &i, ACE_DNode<T> *n, ACE_DNode<T> *p)
+ : ACE_DNode_Base (n, p), item_ (i)
+{
+}
+
+template <class T>
+ACE_DNode<T>::ACE_DNode (const ACE_DNode<T> &i)
+ : ACE_DNode_Base (i.next_, i.prev_), item_ (i.item_)
+{
+}
+
+template <class T>
+ACE_DNode<T>::~ACE_DNode (void)
+{
+}
+#endif /* NANBOR_EXP_CODES */
+
ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Set)
template <class T> int