diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-05-08 23:28:39 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-05-08 23:28:39 +0000 |
commit | 690e47e7a3095df85af55ba67ad0413f07bb0370 (patch) | |
tree | ff019a5b531740517b69ca44c2d24e22c999281d /ace | |
parent | 7d5765e85991aa52b3962d6d5f234f7653dfb32b (diff) | |
download | ATCD-690e47e7a3095df85af55ba67ad0413f07bb0370.tar.gz |
*** empty log message ***
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Containers.cpp | 186 | ||||
-rw-r--r-- | ace/Containers.h | 81 | ||||
-rw-r--r-- | ace/Containers.i | 28 |
3 files changed, 153 insertions, 142 deletions
diff --git a/ace/Containers.cpp b/ace/Containers.cpp index 45ecfe155d5..fcfc1568076 100644 --- a/ace/Containers.cpp +++ b/ace/Containers.cpp @@ -42,21 +42,23 @@ ACE_Bounded_Stack<T>::ACE_Bounded_Stack (const ACE_Bounded_Stack<T> &s) this->stack_[i] = s.stack_[i]; } -template<class T> void +template<class T> const ACE_Bounded_Stack<T> & ACE_Bounded_Stack<T>::operator= (const ACE_Bounded_Stack<T> &s) { ACE_TRACE ("ACE_Bounded_Stack<T>::operator="); - if (&s == this) - return; - else if (this->size_ < s.size_) + if (&s != this) { - delete [] this->stack_; - ACE_NEW (this->stack_, T[s.size_]); + if (this->size_ < s.size_) + { + delete [] this->stack_; + ACE_NEW (this->stack_, T[s.size_]); + } + this->top_ = s.top_; + + for (size_t i = 0; i < this->top_; i++) + this->stack_[i] = s.stack_[i]; } - this->top_ = s.top_; - - for (size_t i = 0; i < this->top_; i++) - this->stack_[i] = s.stack_[i]; + return *this; } template<class T> @@ -94,16 +96,18 @@ ACE_Fixed_Stack<T, SIZE>::ACE_Fixed_Stack (const ACE_Fixed_Stack<T, SIZE> &s) this->stack_[i] = s.stack_[i]; } -template<class T, size_t SIZE> void +template<class T, size_t SIZE> const ACE_Fixed_Stack<T, SIZE> & ACE_Fixed_Stack<T, SIZE>::operator= (const ACE_Fixed_Stack<T, SIZE> &s) { ACE_TRACE ("ACE_Fixed_Stack<T, SIZE>::operator="); - if (&s == this) - return; - this->top_ = s.top_; - - for (size_t i = 0; i < this->top_; i++) - this->stack_[i] = s.stack_[i]; + if (&s != this) + { + this->top_ = s.top_; + + for (size_t i = 0; i < this->top_; i++) + this->stack_[i] = s.stack_[i]; + } + return *this; } template<class T, size_t SIZE> @@ -180,15 +184,16 @@ ACE_Unbounded_Stack<T>::ACE_Unbounded_Stack (const ACE_Unbounded_Stack<T> &s) this->copy_all_nodes (s); } -template<class T> void +template<class T> const ACE_Unbounded_Stack<T> & ACE_Unbounded_Stack<T>::operator= (const ACE_Unbounded_Stack<T> &s) { ACE_TRACE ("ACE_Unbounded_Stack<T>::operator="); - if (this == &s) - return; - - this->delete_all_nodes (); - this->copy_all_nodes (s); + if (this != &s) + { + this->delete_all_nodes (); + this->copy_all_nodes (s); + } + return *this; } template<class T> @@ -207,10 +212,10 @@ ACE_Unbounded_Stack<T>::push (const T &new_item) ACE_Node<T> *temp = 0; - ACE_NEW_RETURN (temp, ACE_Node<T> (new_item, this->head_->next_), 0); + ACE_NEW_RETURN (temp, ACE_Node<T> (new_item, this->head_->next_), -1); this->head_->next_ = temp; - return 1; + return 0; } template<class T> int @@ -219,7 +224,7 @@ ACE_Unbounded_Stack<T>::pop (T &item) ACE_TRACE ("ACE_Unbounded_Stack<T>::pop"); if (this->is_empty ()) - return 0; + return -1; else { ACE_Node<T> *temp = this->head_->next_; @@ -227,7 +232,7 @@ ACE_Unbounded_Stack<T>::pop (T &item) this->head_->next_ = temp->next_; delete temp; - return 1; + return 0; } } @@ -246,18 +251,18 @@ ACE_Unbounded_Stack<T>::find (const T &item) const // If we found the dummy node then it's not really there, otherwise, // it is there. - return temp == this->head_ ? 0 : 1; + return temp == this->head_ ? -1 : 0; } template <class T> int ACE_Unbounded_Stack<T>::insert (const T &item) { // ACE_TRACE ("ACE_Unbounded_Stack<T>::insert"); - + if (this->find (item) == 0) - return this->push (item); - else return 1; + else + return this->push (item); } template <class T> int @@ -274,7 +279,7 @@ ACE_Unbounded_Stack<T>::remove (const T &item) curr = curr->next_; if (curr->next_ == this->head_) - return 0; // Item was not found. + return -1; // Item was not found. else { ACE_Node<T> *temp = curr->next_; @@ -282,7 +287,7 @@ ACE_Unbounded_Stack<T>::remove (const T &item) curr->next_ = temp->next_; this->cur_size_--; delete temp; - return 1; + return 0; } } @@ -316,11 +321,12 @@ ACE_Unbounded_Queue<T>::operator = (const ACE_Unbounded_Queue<T> &us) { ACE_TRACE ("ACE_Unbounded_Queue<T>::operator ="); - if (this == &us) - return; - - this->delete_nodes (); - this->copy_nodes (us); + if (this != &us) + { + this->delete_nodes (); + this->copy_nodes (us); + } + return *this; } ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Queue) @@ -394,13 +400,13 @@ ACE_Unbounded_Queue<T>::enqueue_head (const T &new_item) ACE_Node<T> *temp; // Create a new node that points to the original head. - ACE_NEW_RETURN (temp, ACE_Node<T> (new_item, this->head_->next_), 0); + ACE_NEW_RETURN (temp, ACE_Node<T> (new_item, this->head_->next_), -1); // Link this pointer into the front of the list. this->head_->next_ = temp; this->cur_size_++; - return 1; + return 0; } template <class T> int @@ -414,7 +420,7 @@ ACE_Unbounded_Queue<T>::enqueue_tail (const T &new_item) this->head_->item_ = new_item; // Create a new dummy node. - ACE_NEW_RETURN (temp, ACE_Node<T> (this->head_->next_), 0); + ACE_NEW_RETURN (temp, ACE_Node<T> (this->head_->next_), -1); // Link this dummy pointer into the list. this->head_->next_ = temp; @@ -423,7 +429,7 @@ ACE_Unbounded_Queue<T>::enqueue_tail (const T &new_item) this->head_ = temp; this->cur_size_++; - return 1; + return 0; } template <class T> int @@ -433,7 +439,7 @@ ACE_Unbounded_Queue<T>::dequeue_head (T &item) // Check for empty queue. if (this->is_empty ()) - return 0; + return -1; ACE_Node<T> *temp = this->head_->next_; @@ -441,7 +447,7 @@ ACE_Unbounded_Queue<T>::dequeue_head (T &item) this->head_->next_ = temp->next_; delete temp; --this->cur_size_; - return 1; + return 0; } template <class T> void @@ -472,10 +478,10 @@ ACE_Unbounded_Queue<T>::get (T *&item, size_t index) const if (i < this->cur_size_) { item = &curr->item_; - return 1; + return 0; } else - return 0; + return -1; } template <class T> int @@ -497,7 +503,7 @@ ACE_Unbounded_Queue<T>::set (const T &item, { // We're in range, so everything's cool. curr->item_ = item; - return 1; + return 0; } else { @@ -625,18 +631,19 @@ ACE_Fixed_Set<T, SIZE>::ACE_Fixed_Set (const ACE_Fixed_Set<T, SIZE> &fs) this->search_structure_[i] = fs.search_structure_[i]; } -template <class T, size_t SIZE> void +template <class T, size_t SIZE> const ACE_Fixed_Set<T, SIZE> & ACE_Fixed_Set<T, SIZE>::operator = (const ACE_Fixed_Set<T, SIZE> &fs) { ACE_TRACE ("ACE_Fixed_Set<T>::operator ="); - if (this == &fs) - return; - - this->cur_size_ = fs.cur_size_; - - for (size_t i = 0; i < this->cur_size_; i++) - this->search_structure_[i] = fs.search_structure_[i]; + if (this != &fs) + { + this->cur_size_ = fs.cur_size_; + + for (size_t i = 0; i < this->cur_size_; i++) + this->search_structure_[i] = fs.search_structure_[i]; + } + return *this; } template <class T, size_t SIZE> @@ -657,9 +664,9 @@ ACE_Fixed_Set<T, SIZE>::find (const T &item) const for (size_t i = 0; i < this->cur_size_; i++) if (this->search_structure_[i].item_ == item && this->search_structure_[i].is_free_ == 0) - return 1; + return 0; - return 0; + return -1; } template <class T, size_t SIZE> int @@ -727,10 +734,10 @@ ACE_Fixed_Set<T, SIZE>::remove (const T &item) else this->cur_size_ = i + 1; } - return 1; + return 0; } - return 0; + return -1; } ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set_Iterator) @@ -826,27 +833,29 @@ ACE_Bounded_Set<T>::ACE_Bounded_Set (const ACE_Bounded_Set<T> &bs) this->search_structure_[i] = bs.search_structure_[i]; } -template <class T> void +template <class T> const ACE_Bounded_Set<T> & ACE_Bounded_Set<T>::operator = (const ACE_Bounded_Set<T> &bs) { ACE_TRACE ("ACE_Bounded_Set<T>::operator ="); - if (this == &bs) - return; - else if (this->max_size_ < bs.cur_size_) + if (this != &bs) { - delete [] this->search_structure_; - ACE_NEW (this->search_structure_, - ACE_Bounded_Set<T>::Search_Structure[bs.cur_size_]); - this->max_size_ = bs.cur_size_; + if (this->max_size_ < bs.cur_size_) + { + delete [] this->search_structure_; + ACE_NEW (this->search_structure_, + ACE_Bounded_Set<T>::Search_Structure[bs.cur_size_]); + this->max_size_ = bs.cur_size_; + } + + this->cur_size_ = bs.cur_size_; + + for (size_t i = 0; i < this->cur_size_; i++) + this->search_structure_[i] = bs.search_structure_[i]; } - - this->cur_size_ = bs.cur_size_; - - for (size_t i = 0; i < this->cur_size_; i++) - this->search_structure_[i] = bs.search_structure_[i]; + return *this; } - + template <class T> ACE_Bounded_Set<T>::ACE_Bounded_Set (size_t size) : cur_size_ (0), @@ -867,9 +876,9 @@ ACE_Bounded_Set<T>::find (const T &item) const for (size_t i = 0; i < this->cur_size_; i++) if (this->search_structure_[i].item_ == item && this->search_structure_[i].is_free_ == 0) - return 1; + return 0; - return 0; + return -1; } template <class T> int @@ -930,10 +939,10 @@ ACE_Bounded_Set<T>::remove (const T &item) else this->cur_size_ = i + 1; } - return 1; + return 0; } - return 0; + return -1; } ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Set_Iterator) @@ -1128,16 +1137,17 @@ ACE_Unbounded_Set<T>::ACE_Unbounded_Set (const ACE_Unbounded_Set<T> &us) this->copy_nodes (us); } -template <class T> void +template <class T> const ACE_Unbounded_Set<T> & ACE_Unbounded_Set<T>::operator = (const ACE_Unbounded_Set<T> &us) { ACE_TRACE ("ACE_Unbounded_Set<T>::operator ="); - if (this == &us) - return; - - this->delete_nodes (); - this->copy_nodes (us); + if (this != &us) + { + this->delete_nodes (); + this->copy_nodes (us); + } + return *this; } template <class T> int @@ -1155,7 +1165,7 @@ ACE_Unbounded_Set<T>::find (const T &item) const // If we found the dummy node then it's not really there, otherwise, // it is there. - return temp == this->head_ ? 0 : 1; + return temp == this->head_ ? -1 : 0; } template <class T> int @@ -1163,9 +1173,9 @@ ACE_Unbounded_Set<T>::insert (const T &item) { // ACE_TRACE ("ACE_Unbounded_Set<T>::insert"); if (this->find (item) == 0) - return this->insert_tail (item); - else return 1; + else + return this->insert_tail (item); } template <class T> int @@ -1182,7 +1192,7 @@ ACE_Unbounded_Set<T>::remove (const T &item) curr = curr->next_; if (curr->next_ == this->head_) - return 0; // Item was not found. + return -1; // Item was not found. else { ACE_Node<T> *temp = curr->next_; @@ -1190,7 +1200,7 @@ ACE_Unbounded_Set<T>::remove (const T &item) curr->next_ = temp->next_; this->cur_size_--; delete temp; - return 1; + return 0; } } diff --git a/ace/Containers.h b/ace/Containers.h index 6a1cf76614b..a2912fd1b3b 100644 --- a/ace/Containers.h +++ b/ace/Containers.h @@ -37,7 +37,7 @@ public: ACE_Bounded_Stack (const ACE_Bounded_Stack<T> &s); // The copy constructor (performs initialization). - void operator= (const ACE_Bounded_Stack<T> &s); + const ACE_Bounded_Stack<T> &operator= (const ACE_Bounded_Stack<T> &s); // Assignment operator (performs assignment). ~ACE_Bounded_Stack (void); @@ -46,18 +46,18 @@ public: // = Classic Stack operations. int push (const T &new_item); - // Place a new item on top of the stack. Returns 0 if the stack - // is already full, 1 if the stack is not already full, and -1 if + // Place a new item on top of the stack. Returns -1 if the stack + // is already full, 0 if the stack is not already full, and -1 if // failure occurs. int pop (T &item); - // Remove and return the top stack item. Returns 0 if the stack is - // already empty, 1 if the stack is not already empty, and -1 if + // Remove and return the top stack item. Returns -1 if the stack is + // already empty, 0 if the stack is not already empty, and -1 if // failure occurs. int top (T &item) const; - // Return top stack item without removing it. Returns 0 if the - // stack is already empty, 1 if the stack is not already empty, and + // Return top stack item without removing it. Returns -1 if the + // stack is already empty, 0 if the stack is not already empty, and // -1 if failure occurs. // = Check boundary conditions. @@ -107,7 +107,7 @@ public: ACE_Fixed_Stack (const ACE_Fixed_Stack<T, SIZE> &s); // The copy constructor (performs initialization). - void operator= (const ACE_Fixed_Stack<T, SIZE> &s); + const ACE_Fixed_Stack<T, SIZE> &operator= (const ACE_Fixed_Stack<T, SIZE> &s); // Assignment operator (performs assignment). ~ACE_Fixed_Stack (void); @@ -116,18 +116,18 @@ public: // = Classic Stack operations. int push (const T &new_item); - // Place a new item on top of the stack. Returns 0 if the stack - // is already full, 1 if the stack is not already full, and -1 if + // Place a new item on top of the stack. Returns -1 if the stack + // is already full, 0 if the stack is not already full, and -1 if // failure occurs. int pop (T &item); - // Remove and return the top stack item. Returns 0 if the stack is - // already empty, 1 if the stack is not already empty, and -1 if + // Remove and return the top stack item. Returns -1 if the stack is + // already empty, 0 if the stack is not already empty, and -1 if // failure occurs. int top (T &item) const; - // Return top stack item without removing it. Returns 0 if the - // stack is already empty, 1 if the stack is not already empty, and + // Return top stack item without removing it. Returns -1 if the + // stack is already empty, 0 if the stack is not already empty, and // -1 if failure occurs. // = Check boundary conditions. @@ -212,7 +212,7 @@ public: ACE_Unbounded_Stack (const ACE_Unbounded_Stack<T> &s); // The copy constructor (performs initialization). - void operator= (const ACE_Unbounded_Stack<T> &s); + const ACE_Unbounded_Stack<T> &operator= (const ACE_Unbounded_Stack<T> &s); // Assignment operator (performs assignment). ~ACE_Unbounded_Stack (void); @@ -221,18 +221,18 @@ public: // = Classic Stack operations. int push (const T &new_item); - // Place a new item on top of the stack. Returns 0 if the stack - // is already full, 1 if the stack is not already full, and -1 if + // Place a new item on top of the stack. Returns -1 if the stack + // is already full, 0 if the stack is not already full, and -1 if // failure occurs. int pop (T &item); - // Remove and return the top stack item. Returns 0 if the stack is - // already empty, 1 if the stack is not already empty, and -1 if + // Remove and return the top stack item. Returns -1 if the stack is + // already empty, 0 if the stack is not already empty, and -1 if // failure occurs. int top (T &item) const; - // Return top stack item without removing it. Returns 0 if the - // stack is already empty, 1 if the stack is not already empty, and + // Return top stack item without removing it. Returns -1 if the + // stack is already empty, 0 if the stack is not already empty, and // -1 if failure occurs. // = Check boundary conditions. @@ -251,11 +251,11 @@ public: // present, else 0. int remove (const T &item); - // Remove <item> from the Stack. Returns 1 if it removes the item, - // 0 if it can't find the item, and -1 if a failure occurs. + // Remove <item> from the Stack. Returns 0 if it removes the item, + // -1 if it can't find the item, and -1 if a failure occurs. int find (const T &item) const; - // Finds if <item> occurs the set. Returns 1 if finds, else 0. + // Finds if <item> occurs the set. Returns 0 if finds, else -1. size_t size (void) const; // The number of items in the stack. @@ -373,7 +373,7 @@ public: ACE_Unbounded_Queue (const ACE_Unbounded_Queue<T> &); // Copy constructor. - void operator= (const ACE_Unbounded_Queue<T> &); + const ACE_Unbounded_Queue<T> &operator= (const ACE_Unbounded_Queue<T> &); // Assignment operator. ~ACE_Unbounded_Queue (void); @@ -407,14 +407,14 @@ public: // Reset the <ACE_Unbounded_Queue> to be empty. int get (T *&item, size_t index = 0) const; - // Get the <index>th element in the set. Returns 0 if the element - // isn't in the range <0..size() - 1>, else 1. + // Get the <index>th element in the set. Returns -1 if the element + // isn't in the range <0..size() - 1>, else 0. int set (const T &item, size_t index); // Set the <index>th element in the set. Will pad out the set with // empty nodes if <index> is beyond the range <0..size() - 1>. // Returns -1 on failure, 0 if <index> isn't initially in range, and - // 1 otherwise. + // 0 otherwise. size_t size (void) const; // The number of items in the queue. @@ -494,7 +494,7 @@ public: ACE_Unbounded_Set (const ACE_Unbounded_Set<T> &); // Copy constructor. - void operator= (const ACE_Unbounded_Set<T> &); + const ACE_Unbounded_Set<T> &operator= (const ACE_Unbounded_Set<T> &); // Assignment operator. ~ACE_Unbounded_Set (void); @@ -516,12 +516,13 @@ public: // 0. int remove (const T &item); - // Remove first occurrence of <item> from the set. Returns 1 if - // it removes the item, 0 if it can't find the item, and -1 if a + // Remove first occurrence of <item> from the set. Returns 0 if + // it removes the item, -1 if it can't find the item, and -1 if a // failure occurs. int find (const T &item) const; - // Finds if <item> occurs in the set. Returns 1 if finds, else 0. + // Finds if <item> occurs in the set. Returns 0 if find succeeds, + // else -1. size_t size (void) const; // Size of the set. @@ -615,7 +616,7 @@ public: ACE_Fixed_Set (const ACE_Fixed_Set<T, SIZE> &); // Copy constructor. - void operator = (const ACE_Fixed_Set<T, SIZE> &); + const ACE_Fixed_Set<T, SIZE> &operator= (const ACE_Fixed_Set<T, SIZE> &); // Assignment operator. ~ACE_Fixed_Set (void); @@ -637,12 +638,12 @@ public: // 0. int remove (const T &item); - // Remove first occurrence of <item> from the set. Returns 1 if - // it removes the item, 0 if it can't find the item, and -1 if a + // Remove first occurrence of <item> from the set. Returns 0 if + // it removes the item, -1 if it can't find the item, and -1 if a // failure occurs. int find (const T &item) const; - // Finds if <item> occurs in the set. Returns 1 if finds, else 0. + // Finds if <item> occurs in the set. Returns 0 if finds, else -1. size_t size (void) const; // Size of the set. @@ -742,7 +743,7 @@ public: ACE_Bounded_Set (const ACE_Bounded_Set<T> &); // Copy constructor. - void operator= (const ACE_Bounded_Set<T> &); + const ACE_Bounded_Set<T> &operator= (const ACE_Bounded_Set<T> &); // Assignment operator. ~ACE_Bounded_Set (void); @@ -764,12 +765,12 @@ public: // 0. int remove (const T &item); - // Remove first occurrence of <item> from the set. Returns 1 if it - // removes the item, 0 if it can't find the item, and -1 if a + // Remove first occurrence of <item> from the set. Returns 0 if it + // removes the item, -1 if it can't find the item, and -1 if a // failure occurs. int find (const T &item) const; - // Finds if <item> occurs in the set. Returns 1 if finds, else 0. + // Finds if <item> occurs in the set. Returns 0 if finds, else -1. size_t size (void) const; // Size of the set. diff --git a/ace/Containers.i b/ace/Containers.i index 2ca3093f72c..8e43d502de1 100644 --- a/ace/Containers.i +++ b/ace/Containers.i @@ -24,10 +24,10 @@ ACE_Bounded_Stack<T>::push (const T &new_item) if (this->is_full () == 0) { this->stack_[this->top_++] = new_item; - return 1; + return 0; } else - return 0; + return -1; } template <class T> ACE_INLINE int @@ -37,10 +37,10 @@ ACE_Bounded_Stack<T>::pop (T &item) if (this->is_empty () == 0) { item = this->stack_[--this->top_]; - return 1; + return 0; } else - return 0; + return -1; } template <class T> ACE_INLINE int @@ -50,10 +50,10 @@ ACE_Bounded_Stack<T>::top (T &item) const if (this->is_empty () == 0) { item = this->stack_[this->top_ - 1]; - return 1; + return 0; } else - return 0; + return -1; } template <class T> ACE_INLINE size_t @@ -85,10 +85,10 @@ ACE_Fixed_Stack<T, SIZE>::push (const T &new_item) if (this->is_full () == 0) { this->stack_[this->top_++] = new_item; - return 1; + return 0; } else - return 0; + return -1; } template <class T, size_t SIZE> ACE_INLINE int @@ -98,10 +98,10 @@ ACE_Fixed_Stack<T, SIZE>::pop (T &item) if (this->is_empty () == 0) { item = this->stack_[--this->top_]; - return 1; + return 0; } else - return 0; + return -1; } template <class T, size_t SIZE> ACE_INLINE int @@ -111,10 +111,10 @@ ACE_Fixed_Stack<T, SIZE>::top (T &item) const if (this->is_empty () == 0) { item = this->stack_[this->top_ - 1]; - return 1; + return 0; } else - return 0; + return -1; } template <class T, size_t SIZE> ACE_INLINE size_t @@ -139,10 +139,10 @@ ACE_Unbounded_Stack<T>::top (T &item) const if (this->is_empty () == 0) { item = this->head_->next_->item_; - return 1; + return 0; } else - return 0; + return -1; } template <class T> ACE_INLINE int |