summaryrefslogtreecommitdiff
path: root/ace/Hash_Map_Manager.cpp
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-04-08 03:06:28 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-04-08 03:06:28 +0000
commit0a5a8665433b3354657b8c356d45d46176b4d290 (patch)
tree791c9e47c7870b4114cbd685de88f416131124cd /ace/Hash_Map_Manager.cpp
parentcbc527f5fd3fe2201800c5739f8921a3f9d087db (diff)
downloadATCD-0a5a8665433b3354657b8c356d45d46176b4d290.tar.gz
reverted to pre-4.5 release versions
Diffstat (limited to 'ace/Hash_Map_Manager.cpp')
-rw-r--r--ace/Hash_Map_Manager.cpp109
1 files changed, 61 insertions, 48 deletions
diff --git a/ace/Hash_Map_Manager.cpp b/ace/Hash_Map_Manager.cpp
index 0eb6fc7ccd5..66ed83145ce 100644
--- a/ace/Hash_Map_Manager.cpp
+++ b/ace/Hash_Map_Manager.cpp
@@ -402,14 +402,12 @@ ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::shared_find (const EXT_ID &ext_i
{
loc = this->hash (ext_id) % this->total_size_;
- ACE_Hash_Map_Entry<EXT_ID, INT_ID> *temp;
+ ACE_Hash_Map_Entry<EXT_ID, INT_ID> *temp = this->table_[loc].next_;
- for (temp = this->table_[loc];
- temp != 0 && this->equal (temp->ext_id_, ext_id) == 0;
- temp = temp->next_)
- continue;
+ while (temp != &this->table_[loc] && this->equal (temp->ext_id_, ext_id) == 0)
+ temp = temp->next_;
- if (temp == 0)
+ if (temp == &this->table_[loc])
{
errno = ENOENT;
return -1;
@@ -426,8 +424,8 @@ ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::find_i (const EXT_ID &ext_id,
INT_ID &int_id)
{
ACE_Hash_Map_Entry<EXT_ID, INT_ID> *entry;
- u_long dummy;
+ u_long dummy;
if (this->shared_find (ext_id, entry, dummy) == -1)
return -1;
else
@@ -441,8 +439,8 @@ template <class EXT_ID, class INT_ID, class ACE_LOCK> int
ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::find_i (const EXT_ID &ext_id)
{
ACE_Hash_Map_Entry<EXT_ID, INT_ID> *entry;
- u_long dummy;
+ u_long dummy;
return this->shared_find (ext_id, entry, dummy);
}
@@ -584,13 +582,13 @@ template <class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_Hash_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK>::ACE_Hash_Map_Iterator_Base (ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> &mm,
int head)
: map_man_ (&mm),
- index_ (head != 0 ? 0 : ACE_static_cast (ssize_t, mm.total_size_ - 1)),
+ index_ (head != 0 ? -1 : ACE_static_cast (ssize_t,
+ mm.total_size_)),
next_ (0)
{
ACE_TRACE ("ACE_Hash_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK>::ACE_Hash_Map_Iterator_Base");
-
if (mm.table_ != 0)
- this->next_ = mm.table_[head != 0 ? 0 : mm.total_size_ - 1];
+ this->next_ = &mm.table_[ (head != 0 ? 0 : mm.total_size_ - 1 ) ];
}
template <class EXT_ID, class INT_ID, class ACE_LOCK> int
@@ -602,7 +600,7 @@ ACE_Hash_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK>::next (ACE_Hash_Map_Entry<E
if (this->map_man_->table_ != 0
&& this->index_ < ACE_static_cast (ssize_t, this->map_man_->total_size_)
&& this->index_ >= 0
- && this->next_ != 0)
+ && this->next_ != &this->map_man_->table_[this->index_])
{
entry = this->next_;
return 1;
@@ -619,43 +617,77 @@ ACE_Hash_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK>::done (void) const
return this->map_man_->table_ == 0
|| this->index_ >= ACE_static_cast (ssize_t, this->map_man_->total_size_)
- || this->index_ < 0;
+ || this->index_ <= -1;
}
template <class EXT_ID, class INT_ID, class ACE_LOCK> int
ACE_Hash_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK>::forward_i (void)
{
ACE_TRACE ("ACE_Hash_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK>::forward_i");
+ ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->map_man_->lock_, -1);
if (this->map_man_->table_ == 0)
return -1;
- if (this->index_ >= ACE_static_cast(ssize_t, this->map_man_->total_size_))
+ // Guard against error condition first.
+ if (this->index_ < 0)
+ {
+ this->index_++;
+ return this->forward_i ();
+ }
+ else if (this->index_ >= ACE_static_cast(ssize_t, this->map_man_->total_size_))
return 0;
- while (this->next_ == 0
- && ++this->index_ < ACE_static_cast (ssize_t, this->map_man_->total_size_))
- this->next_ = this->map_man_->table_[this->index_];
-
- return this->index < this->map_man_->total_size_;
+ this->next_ = this->next_->next_;
+ if (this->next_ == &this->map_man_->table_[this->index_])
+ {
+ while (++this->index_ < ACE_static_cast (ssize_t, this->map_man_->total_size_))
+ {
+ this->next_ = &this->map_man_->table_[this->index_];
+ if (this->next_->next_ != &this->map_man_->table_[this->index_])
+ {
+ this->next_ = this->map_man_->table_[this->index_].next_;
+ return 1;
+ }
+ }
+ return 0;
+ }
+ return 1;
}
template <class EXT_ID, class INT_ID, class ACE_LOCK> int
ACE_Hash_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK>::reverse_i (void)
{
ACE_TRACE ("ACE_Hash_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK>::reverse_i");
+ ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->map_man_->lock_, -1);
if (this->map_man_->table_ == 0)
return -1;
- if (this->index_ < 0)
+ if (this->index_ >= ACE_static_cast (ssize_t, this->map_man_->total_size_))
+ {
+ this->index_--;
+ return this->reverse_i ();
+ }
+ else if (this->index_ < 0)
return 0;
- while (this->next_ == 0
- && --this->index_ >= 0)
- this->next_ = this->map_man_->table_[this->index_];
+ this->next_ = this->next_->prev_;
+ if (this->next_ == &this->map_man_->table_[this->index_])
+ {
+ while (--this->index_ >= 0)
+ {
+ this->next_ = &this->map_man_->table_[this->index_];
+ if (this->next_->prev_ != &this->map_man_->table_[this->index_])
+ {
+ this->next_ = this->map_man_->table_[this->index_].prev_;
+ return 1;
+ }
+ }
+ return 0;
+ }
- return this->index >= 0;
+ return 1;
}
template <class EXT_ID, class INT_ID, class ACE_LOCK>
@@ -710,10 +742,10 @@ ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>::dump (void) const
template <class EXT_ID, class INT_ID, class ACE_LOCK>
ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>::ACE_Hash_Map_Iterator (ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> &mm,
int tail)
- : ACE_Hash_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK> (mm, tail == 0 ? 1 : 0)
+ : ACE_Hash_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK> (mm,
+ (tail == 0 ? 1 : 0))
{
ACE_TRACE ("ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>::ACE_Hash_Map_Iterator");
-
if (tail == 0)
this->forward_i ();
}
@@ -722,8 +754,6 @@ template <class EXT_ID, class INT_ID, class ACE_LOCK> int
ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>::advance (void)
{
ACE_TRACE ("ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>::advance");
- ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->map_man_->lock_, -1);
-
return this->forward_i ();
}
@@ -732,9 +762,6 @@ ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>
ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>::operator++ (void)
{
ACE_TRACE ("ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>::operator++ (void)");
- ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->map_man_->lock_, -1);
-
- // @@ What is this doing?
ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> retv (*this);
this->forward_i ();
@@ -746,8 +773,6 @@ ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>&
ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>::operator++ (int)
{
ACE_TRACE ("ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>::operator++ (int)");
- ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->map_man_->lock_, -1);
-
this->forward_i ();
return *this;
}
@@ -757,9 +782,8 @@ ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>
ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>::operator-- (void)
{
ACE_TRACE ("ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>::operator-- (void)");
- ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->map_man_->lock_, -1);
-
ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> retv (*this);
+
this->reverse_i ();
return retv;
}
@@ -769,8 +793,6 @@ ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>&
ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>::operator-- (int)
{
ACE_TRACE ("ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>::operator-- (int)");
- ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->map_man_->lock_, -1);
-
this->reverse_i ();
return *this;
}
@@ -790,7 +812,6 @@ ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>::ACE_Hash_Map_Reverse_It
: ACE_Hash_Map_Iterator_Base<EXT_ID, INT_ID, ACE_LOCK> (mm, head)
{
ACE_TRACE ("ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>::ACE_Hash_Map_Reverse_Iterator");
-
if (head == 0)
this->reverse_i ();
}
@@ -799,8 +820,6 @@ template <class EXT_ID, class INT_ID, class ACE_LOCK> int
ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>::advance (void)
{
ACE_TRACE ("ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>::advance");
-
- ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->map_man_->lock_, -1);
return this->reverse_i ();
}
@@ -809,9 +828,8 @@ ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>
ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>::operator++ (void)
{
ACE_TRACE ("ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>::operator++ (void)");
- ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->map_man_->lock_, -1);
-
ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> retv (*this);
+
this->reverse_i ();
return retv;
}
@@ -821,8 +839,6 @@ ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>&
ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>::operator++ (int)
{
ACE_TRACE ("ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>::operator++ (int)");
- ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->map_man_->lock_, -1);
-
this->reverse_i ();
return *this;
}
@@ -832,9 +848,8 @@ ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>
ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>::operator-- (void)
{
ACE_TRACE ("ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>::operator-- (void)");
- ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->map_man_->lock_, -1);
-
ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK> retv (*this);
+
this->forward_i ();
return retv;
}
@@ -844,8 +859,6 @@ ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>&
ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>::operator-- (int)
{
ACE_TRACE ("ACE_Hash_Map_Reverse_Iterator<EXT_ID, INT_ID, ACE_LOCK>::operator-- (int)");
- ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->map_man_->lock_, -1);
-
this->forward_i ();
return *this;
}