summaryrefslogtreecommitdiff
path: root/ace
diff options
context:
space:
mode:
authorSimon McQueen <simon.mcqueen@gmail.com>2003-03-26 16:38:08 +0000
committerSimon McQueen <simon.mcqueen@gmail.com>2003-03-26 16:38:08 +0000
commitf6ed44df3ab244305ed5ffecf818596f43c439dc (patch)
tree9d52c20e34ce06abc7c384951c82ff1444c89cd9 /ace
parentd957088a3143a8dd5a1421c3c5b641bb7c54e507 (diff)
downloadATCD-f6ed44df3ab244305ed5ffecf818596f43c439dc.tar.gz
Wed Mar 26 16:15:39 2003 Simon McQueen <sm@prismtechnologies.com>
Diffstat (limited to 'ace')
-rw-r--r--ace/Node.cpp9
-rw-r--r--ace/Node.h1
-rw-r--r--ace/Unbounded_Set.cpp177
-rw-r--r--ace/Unbounded_Set.h47
-rw-r--r--ace/Unbounded_Set.inl4
5 files changed, 37 insertions, 201 deletions
diff --git a/ace/Node.cpp b/ace/Node.cpp
index f13b18cde86..91e989d739b 100644
--- a/ace/Node.cpp
+++ b/ace/Node.cpp
@@ -23,16 +23,14 @@ ACE_Node<T>::~ACE_Node (void)
template <class T>
ACE_Node<T>::ACE_Node (const T &i, ACE_Node<T> *n)
: next_ (n),
- item_ (i),
- deleted_ (false)
+ item_ (i)
{
// ACE_TRACE ("ACE_Node<T>::ACE_Node");
}
template <class T>
ACE_Node<T>::ACE_Node (ACE_Node<T> *n, int)
- : next_ (n),
- deleted_ (false)
+ : next_ (n)
{
// ACE_TRACE ("ACE_Node<T>::ACE_Node");
}
@@ -40,8 +38,7 @@ ACE_Node<T>::ACE_Node (ACE_Node<T> *n, int)
template <class T>
ACE_Node<T>::ACE_Node (const ACE_Node<T> &s)
: next_ (s.next_),
- item_ (s.item_),
- deleted_ (false)
+ item_ (s.item_)
{
// ACE_TRACE ("ACE_Node<T>::ACE_Node");
}
diff --git a/ace/Node.h b/ace/Node.h
index 65532c65ec5..3d69213bf26 100644
--- a/ace/Node.h
+++ b/ace/Node.h
@@ -63,7 +63,6 @@ private:
/// Current value of the item in this node.
T item_;
- bool deleted_;
};
#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
diff --git a/ace/Unbounded_Set.cpp b/ace/Unbounded_Set.cpp
index e13e887e5a4..e1cf0708e6a 100644
--- a/ace/Unbounded_Set.cpp
+++ b/ace/Unbounded_Set.cpp
@@ -88,10 +88,7 @@ ACE_Unbounded_Set<T>::copy_nodes (const ACE_Unbounded_Set<T> &us)
for (ACE_Node<T> *curr = us.head_->next_;
curr != us.head_;
curr = curr->next_)
- {
- if (!curr->deleted_)
- this->insert_tail (curr->item_);
- }
+ this->insert_tail (curr->item_);
}
template <class T> void
@@ -99,63 +96,23 @@ ACE_Unbounded_Set<T>::delete_nodes (void)
{
ACE_Node<T> *curr = this->head_->next_;
- /* The following line is *temporarily* commented out because it
- crashes TAO (cvs of 2003/03/25) FIXME: Repair the problem in TAO.
-
- ACE_ASSERT (number_of_iterators_ == 0);
- */
-
// Keep looking until we've hit the dummy node.
while (curr != this->head_)
{
ACE_Node<T> *temp = curr;
curr = curr->next_;
-
- if (! temp->deleted_)
- this->cur_size_--;
-
- if (number_of_iterators_ == 0)
- {
- ACE_DES_FREE_TEMPLATE (temp,
- this->allocator_->free,
- ACE_Node,
- <T>);
- }
- else
- temp->deleted_ = true;
+ ACE_DES_FREE_TEMPLATE (temp,
+ this->allocator_->free,
+ ACE_Node,
+ <T>);
+ this->cur_size_--;
}
// Reset the list to be a circular list with just a dummy node.
this->head_->next_ = this->head_;
}
-template <class T> void
-ACE_Unbounded_Set<T>::cleanup ()
-{
- /// curr is the address of the chaining
- ACE_Node<T> **curr = &(this->head_->next_);
- ACE_ASSERT (number_of_iterators_ == 0);
-
- // Keep looking until we've hit the dummy node.
- while (*curr != this->head_)
- {
- if ((*curr)->deleted_)
- {
- ACE_Node<T> *temp = *curr;
- *curr = (*curr)->next_; // skip the deleted, curr is still the same
- ACE_DES_FREE_TEMPLATE (temp,
- this->allocator_->free,
- ACE_Node,
- <T>);
- }
- else
- {
- curr = &((*curr)->next_);
- }
- }
-}
-
template <class T>
ACE_Unbounded_Set<T>::~ACE_Unbounded_Set (void)
{
@@ -175,8 +132,7 @@ template <class T>
ACE_Unbounded_Set<T>::ACE_Unbounded_Set (ACE_Allocator *alloc)
: head_ (0),
cur_size_ (0),
- allocator_ (alloc),
- number_of_iterators_ (0)
+ allocator_ (alloc)
{
// ACE_TRACE ("ACE_Unbounded_Set<T>::ACE_Unbounded_Set");
@@ -194,8 +150,7 @@ template <class T>
ACE_Unbounded_Set<T>::ACE_Unbounded_Set (const ACE_Unbounded_Set<T> &us)
: head_ (0),
cur_size_ (0),
- allocator_ (us.allocator_),
- number_of_iterators_ (0)
+ allocator_ (us.allocator_)
{
ACE_TRACE ("ACE_Unbounded_Set<T>::ACE_Unbounded_Set");
@@ -231,7 +186,7 @@ ACE_Unbounded_Set<T>::find (const T &item) const
ACE_Node<T> *temp = this->head_->next_;
// Keep looping until we find the item.
- while (!(temp->item_ == item && !temp->deleted_))
+ while (!(temp->item_ == item))
temp = temp->next_;
// If we found the dummy node then it's not really there, otherwise,
@@ -256,33 +211,24 @@ ACE_Unbounded_Set<T>::remove (const T &item)
// Insert the item to be founded into the dummy node.
this->head_->item_ = item;
- this->head_->deleted_ = false;
ACE_Node<T> *curr = this->head_;
- while (!(curr->next_->item_ == item) || curr->next_->deleted_)
+ while (!(curr->next_->item_ == item))
curr = curr->next_;
if (curr->next_ == this->head_)
return -1; // Item was not found.
else
{
- this->cur_size_--;
ACE_Node<T> *temp = curr->next_;
- if(number_of_iterators_>0)
- {
- temp->deleted_ = true;
- }
- else
- {
- // Skip over the node that we're deleting.
- curr->next_ = temp->next_;
-
- ACE_DES_FREE_TEMPLATE (temp,
- this->allocator_->free,
- ACE_Node,
- <T>);
- }
+ // Skip over the node that we're deleting.
+ curr->next_ = temp->next_;
+ this->cur_size_--;
+ ACE_DES_FREE_TEMPLATE (temp,
+ this->allocator_->free,
+ ACE_Node,
+ <T>);
return 0;
}
}
@@ -301,27 +247,6 @@ ACE_Unbounded_Set<T>::end (void)
return ACE_Unbounded_Set_Iterator<T> (*this, 1);
}
-template <class T> void
-ACE_Unbounded_Set<T>::iterator_add (void) const
-{
- number_of_iterators_++;
-}
-
-template <class T> void
-ACE_Unbounded_Set<T>::iterator_leave (void)
-{
- ACE_ASSERT (number_of_iterators_ > 0);
- number_of_iterators_--;
- if (number_of_iterators_ == 0)
- cleanup ();
-}
-
-template <class T> void
-ACE_Unbounded_Set<T>::const_iterator_leave (void) const
-{
- ACE_ASSERT (number_of_iterators_ > 0);
- number_of_iterators_--;
-}
ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Set_Iterator)
@@ -333,39 +258,10 @@ ACE_Unbounded_Set_Iterator<T>::dump (void) const
template <class T>
ACE_Unbounded_Set_Iterator<T>::ACE_Unbounded_Set_Iterator (ACE_Unbounded_Set<T> &s, int end)
- : current_ (end == 0 ? s.head_->next_ : s.head_),
+ : current_ (end == 0 ? s.head_->next_ : s.head_ ),
set_ (&s)
{
// ACE_TRACE ("ACE_Unbounded_Set_Iterator<T>::ACE_Unbounded_Set_Iterator");
- set_->iterator_add ();
- // the first one may be deleted
- while (this->current_->deleted_ && this->current_ != this->set_->head_)
- this->current_ = this->current_->next_;
-}
-
-template <class T>
-ACE_Unbounded_Set_Iterator<T>::ACE_Unbounded_Set_Iterator (const ACE_Unbounded_Set_Iterator<T> &o)
- : current_ (o.current_), set_ (o.set_)
-{
- set_->iterator_add ();
-}
-
-template <class T> void
-ACE_Unbounded_Set_Iterator<T>::operator= (const ACE_Unbounded_Set_Iterator &o)
-{
- if (this == &o)
- return;
- set_->iterator_leave ();
- this->set_ = o.set_;
- this->current_ = o.current_;
- set_->iterator_add ();
-}
-
-
-template <class T>
-ACE_Unbounded_Set_Iterator<T>::~ACE_Unbounded_Set_Iterator ()
-{
- set_->iterator_leave ();
}
template <class T> int
@@ -373,8 +269,6 @@ ACE_Unbounded_Set_Iterator<T>::advance (void)
{
// ACE_TRACE ("ACE_Unbounded_Set_Iterator<T>::advance");
this->current_ = this->current_->next_;
- while(this->current_->deleted_ && this->current_ != this->set_->head_)
- this->current_ = this->current_->next_;
return this->current_ != this->set_->head_;
}
@@ -383,8 +277,6 @@ ACE_Unbounded_Set_Iterator<T>::first (void)
{
// ACE_TRACE ("ACE_Unbounded_Set_Iterator<T>::first");
this->current_ = this->set_->head_->next_;
- while(this->current_->deleted_ && this->current_ != this->set_->head_)
- this->current_ = this->current_->next_;
return this->current_ != this->set_->head_;
}
@@ -469,37 +361,10 @@ ACE_Unbounded_Set_Const_Iterator<T>::dump (void) const
template <class T>
ACE_Unbounded_Set_Const_Iterator<T>::ACE_Unbounded_Set_Const_Iterator (const ACE_Unbounded_Set<T> &s, int end)
- : current_ (end == 0 ? s.head_->next_ : s.head_),
+ : current_ (end == 0 ? s.head_->next_ : s.head_ ),
set_ (&s)
{
// ACE_TRACE ("ACE_Unbounded_Set_Const_Iterator<T>::ACE_Unbounded_Set_Const_Iterator");
- set_->iterator_add ();
- // the first one may be deleted
- while (this->current_->deleted_ && this->current_ != this->set_->head_)
- this->current_ = this->current_->next_;
-}
-
-template <class T>
-ACE_Unbounded_Set_Const_Iterator<T>::ACE_Unbounded_Set_Const_Iterator(const ACE_Unbounded_Set_Const_Iterator<T> &o):current_(o.current_),set_(o.set_)
-{
- set_->iterator_add ();
-}
-
-template <class T>
-void ACE_Unbounded_Set_Const_Iterator<T>::operator=(const ACE_Unbounded_Set_Const_Iterator& o)
-{
- if (this == &o)
- return;
- set_->iterator_leave ();
- this->set_ = o.set_;
- this->current_ = o.current_;
- set_->iterator_add ();
-}
-
-template <class T>
-ACE_Unbounded_Set_Const_Iterator<T>::~ACE_Unbounded_Set_Const_Iterator()
-{
- set_->const_iterator_leave ();
}
template <class T> int
@@ -507,8 +372,6 @@ ACE_Unbounded_Set_Const_Iterator<T>::advance (void)
{
// ACE_TRACE ("ACE_Unbounded_Set_Const_Iterator<T>::advance");
this->current_ = this->current_->next_;
- while (this->current_->deleted_ && this->current_ != this->set_->head_)
- this->current_ = this->current_->next_;
return this->current_ != this->set_->head_;
}
@@ -517,8 +380,6 @@ ACE_Unbounded_Set_Const_Iterator<T>::first (void)
{
// ACE_TRACE ("ACE_Unbounded_Set_Const_Iterator<T>::first");
this->current_ = this->set_->head_->next_;
- while (this->current_->deleted_ && this->current_ != this->set_->head_)
- this->current_ = this->current_->next_;
return this->current_ != this->set_->head_;
}
diff --git a/ace/Unbounded_Set.h b/ace/Unbounded_Set.h
index 6f35c1228d7..d4c882b6f5c 100644
--- a/ace/Unbounded_Set.h
+++ b/ace/Unbounded_Set.h
@@ -33,9 +33,6 @@ class ACE_Unbounded_Set_Iterator
public:
// = Initialization method.
ACE_Unbounded_Set_Iterator (ACE_Unbounded_Set<T> &s, int end = 0);
- ACE_Unbounded_Set_Iterator (const ACE_Unbounded_Set_Iterator &o);
- void operator= (const ACE_Unbounded_Set_Iterator &o);
- ~ACE_Unbounded_Set_Iterator ();
// = Iteration methods.
@@ -95,9 +92,6 @@ class ACE_Unbounded_Set_Const_Iterator
public:
// = Initialization method.
ACE_Unbounded_Set_Const_Iterator (const ACE_Unbounded_Set<T> &s, int end = 0);
- ACE_Unbounded_Set_Const_Iterator (const ACE_Unbounded_Set_Const_Iterator& o);
- void operator= (const ACE_Unbounded_Set_Const_Iterator& o);
- ~ACE_Unbounded_Set_Const_Iterator ();
// = Iteration methods.
@@ -196,26 +190,26 @@ public:
/// Constructor. Use user specified allocation strategy
/// if specified.
/**
- * Initialize an empty set using the allocation strategy of the user if
- * provided.
+ * Initialize an empty set using the allocation strategy of the user if
+ * provided.
*/
ACE_Unbounded_Set (ACE_Allocator *alloc = 0);
/// Copy constructor.
/**
- * Initialize this set to be an exact copy of the set provided.
+ * Initialize this set to be an exact copy of the set provided.
*/
ACE_Unbounded_Set (const ACE_Unbounded_Set<T> &);
/// Assignment operator.
/**
- * Perform a deep copy of the rhs into the lhs.
+ * Perform a deep copy of the rhs into the lhs.
*/
void operator= (const ACE_Unbounded_Set<T> &);
/// Destructor.
/**
- * Destroy the nodes of the set.
+ * Destroy the nodes of the set.
*/
~ACE_Unbounded_Set (void);
@@ -223,19 +217,19 @@ public:
/// Returns 1 if the container is empty, otherwise returns 0.
/**
- * Constant time is_empty check.
+ * Constant time is_empty check.
*/
int is_empty (void) const;
/// Returns 0.
- /**
- * Always returns 0 since the set can never fill up.
+ /**
+ * Always returns 0 since the set can never fill up.
*/
int is_full (void) const;
// = Classic unordered set operations.
- ///Linear insertion of an item.
+ ///Linear insertion of an item.
/**
* Insert <new_item> into the set (doesn't allow duplicates).
* Returns -1 if failures occur, 1 if item is already present, else
@@ -246,11 +240,11 @@ public:
/// Insert <item> at the tail of the set (doesn't check for
/// duplicates).
/**
- * Constant time insert at the end of the set.
+ * Constant time insert at the end of the set.
*/
int insert_tail (const T &item);
- ///Linear remove operation.
+ ///Linear remove operation.
/**
* 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
@@ -261,13 +255,13 @@ public:
/// Finds if <item> occurs in the set. Returns 0 if find succeeds,
/// else -1.
/**
- * Performs a linear find operation.
+ * Performs a linear find operation.
*/
int find (const T &item) const;
/// Size of the set.
/**
- * Access the size of the set.
+ * Access the size of the set.
*/
size_t size (void) const;
@@ -276,7 +270,7 @@ public:
/// Reset the <ACE_Unbounded_Set> to be empty.
/**
- * Delete the nodes of the set.
+ * Delete the nodes of the set.
*/
void reset (void);
@@ -284,13 +278,6 @@ public:
ACE_Unbounded_Set_Iterator<T> begin (void);
ACE_Unbounded_Set_Iterator<T> end (void);
- /// An Iterator has to register itself here.
- void iterator_add () const;
- /// A non-const Iterator has to unregister itself here.
- void iterator_leave ();
- /// A Const_Iterator has to unregister itself here.
- void const_iterator_leave () const;
-
/// Declare the dynamic allocation hooks.
ACE_ALLOC_HOOK_DECLARE;
@@ -301,9 +288,6 @@ private:
/// Copy nodes into this set.
void copy_nodes (const ACE_Unbounded_Set<T> &);
- /// Really delete all nodes marked for deletion.
- void cleanup ();
-
/// Head of the linked list of Nodes.
ACE_Node<T> *head_;
@@ -312,9 +296,6 @@ private:
/// Allocation strategy of the set.
ACE_Allocator *allocator_;
-
- /// Number of iterators working on this set.
- mutable int number_of_iterators_;
};
#if defined (__ACE_INLINE__)
diff --git a/ace/Unbounded_Set.inl b/ace/Unbounded_Set.inl
index fff0a0fcbb5..3f71cd2b498 100644
--- a/ace/Unbounded_Set.inl
+++ b/ace/Unbounded_Set.inl
@@ -5,9 +5,7 @@ template <class T> ACE_INLINE int
ACE_Unbounded_Set<T>::is_empty (void) const
{
ACE_TRACE ("ACE_Unbounded_Set<T>::is_empty");
- // Does not work if deleted elements are in the list:
- // return this->head_ == this->head_->next_;
- return size() == 0;
+ return this->head_ == this->head_->next_;
}
template <class T> ACE_INLINE int