summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog28
-rw-r--r--ChangeLogs/ChangeLog-02a28
-rw-r--r--ChangeLogs/ChangeLog-03a28
-rw-r--r--ace/Hash_Map_Manager_T.cpp75
-rw-r--r--ace/Hash_Map_Manager_T.h154
-rw-r--r--ace/Hash_Map_Manager_T.i187
-rw-r--r--tests/Collection_Test.cpp3
-rw-r--r--tests/Hash_Map_Manager_Test.cpp29
8 files changed, 514 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 19f947be0ab..b10d78fd7cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,29 @@
+Tue Aug 07 16:40:12 2001 Johnny Willemsen <jwillemsen@remedy.nl>
+
+ * ace/Hash_Map_Manager_T.*:
+ Added const_iterator to the Hash_Map_Manager so that it is
+ possible to iterate over a hash map in a const method
+
+ The operator= of the iterator now check the value of this to
+ check that the iterator instance is assigned to itself
+
+ * tests/Hash_Map_Manager_Test.cpp
+ Extended this test to test the new const_iterator capabilities of
+ the hash map
+
+ * ace/Unbounded_Set.cpp:
+ Implemented missing operator* for the const iterator
+
+ * tests/Collection_test.cpp:
+ Extended test to test the operator* of the
+ Unbounded_Set_Const_Iterator
+
Mon Aug 6 19:58:48 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
* ace/config-hpux-11.00.h: Added #define for ACE_HAS_TERM_IOCTLS.
Thanks to Torbjorn Backstrom <torbjorn.k.backstrom@volvo.com>
for reporting this.
-
+
* ace/OS.h: Added a #include for <sys/modem.h> for HP/UX. Thanks
to Torbjorn Backstrom <torbjorn.k.backstrom@volvo.com> for
reporting this.
@@ -29,7 +49,7 @@ Mon Aug 06 17:17:33 2001 Ossama Othman <ossama@uci.edu>
regression testing happy until the on-the-fly generation is
implemented. Once we start generating this file on-the-fly
this file should disappear.
-
+
* tests/Service_Config_Test.cpp (run_test):
When using full Unicode support, use the version of the Service
@@ -62,9 +82,9 @@ Sun Aug 5 14:31:10 2001 Balachandran Natarajan <bala@cs.wustl.edu>
Service_Config_Test in static builds.
Fri Aug 04 3:33:31 2001 Yamuna Krishnamurthy <yamuna@cs.wustl.edu>
-
+
* ace/QoS/SOCK_Dgram_Mcast_QoS.h:
- * ace/QoS/SOCK_Dgram_Mcast_QoS.cpp:
+ * ace/QoS/SOCK_Dgram_Mcast_QoS.cpp:
Made the open method public so we can open UDP sockets for
non-multicast addresses.
diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a
index 19f947be0ab..b10d78fd7cd 100644
--- a/ChangeLogs/ChangeLog-02a
+++ b/ChangeLogs/ChangeLog-02a
@@ -1,9 +1,29 @@
+Tue Aug 07 16:40:12 2001 Johnny Willemsen <jwillemsen@remedy.nl>
+
+ * ace/Hash_Map_Manager_T.*:
+ Added const_iterator to the Hash_Map_Manager so that it is
+ possible to iterate over a hash map in a const method
+
+ The operator= of the iterator now check the value of this to
+ check that the iterator instance is assigned to itself
+
+ * tests/Hash_Map_Manager_Test.cpp
+ Extended this test to test the new const_iterator capabilities of
+ the hash map
+
+ * ace/Unbounded_Set.cpp:
+ Implemented missing operator* for the const iterator
+
+ * tests/Collection_test.cpp:
+ Extended test to test the operator* of the
+ Unbounded_Set_Const_Iterator
+
Mon Aug 6 19:58:48 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
* ace/config-hpux-11.00.h: Added #define for ACE_HAS_TERM_IOCTLS.
Thanks to Torbjorn Backstrom <torbjorn.k.backstrom@volvo.com>
for reporting this.
-
+
* ace/OS.h: Added a #include for <sys/modem.h> for HP/UX. Thanks
to Torbjorn Backstrom <torbjorn.k.backstrom@volvo.com> for
reporting this.
@@ -29,7 +49,7 @@ Mon Aug 06 17:17:33 2001 Ossama Othman <ossama@uci.edu>
regression testing happy until the on-the-fly generation is
implemented. Once we start generating this file on-the-fly
this file should disappear.
-
+
* tests/Service_Config_Test.cpp (run_test):
When using full Unicode support, use the version of the Service
@@ -62,9 +82,9 @@ Sun Aug 5 14:31:10 2001 Balachandran Natarajan <bala@cs.wustl.edu>
Service_Config_Test in static builds.
Fri Aug 04 3:33:31 2001 Yamuna Krishnamurthy <yamuna@cs.wustl.edu>
-
+
* ace/QoS/SOCK_Dgram_Mcast_QoS.h:
- * ace/QoS/SOCK_Dgram_Mcast_QoS.cpp:
+ * ace/QoS/SOCK_Dgram_Mcast_QoS.cpp:
Made the open method public so we can open UDP sockets for
non-multicast addresses.
diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a
index 19f947be0ab..b10d78fd7cd 100644
--- a/ChangeLogs/ChangeLog-03a
+++ b/ChangeLogs/ChangeLog-03a
@@ -1,9 +1,29 @@
+Tue Aug 07 16:40:12 2001 Johnny Willemsen <jwillemsen@remedy.nl>
+
+ * ace/Hash_Map_Manager_T.*:
+ Added const_iterator to the Hash_Map_Manager so that it is
+ possible to iterate over a hash map in a const method
+
+ The operator= of the iterator now check the value of this to
+ check that the iterator instance is assigned to itself
+
+ * tests/Hash_Map_Manager_Test.cpp
+ Extended this test to test the new const_iterator capabilities of
+ the hash map
+
+ * ace/Unbounded_Set.cpp:
+ Implemented missing operator* for the const iterator
+
+ * tests/Collection_test.cpp:
+ Extended test to test the operator* of the
+ Unbounded_Set_Const_Iterator
+
Mon Aug 6 19:58:48 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
* ace/config-hpux-11.00.h: Added #define for ACE_HAS_TERM_IOCTLS.
Thanks to Torbjorn Backstrom <torbjorn.k.backstrom@volvo.com>
for reporting this.
-
+
* ace/OS.h: Added a #include for <sys/modem.h> for HP/UX. Thanks
to Torbjorn Backstrom <torbjorn.k.backstrom@volvo.com> for
reporting this.
@@ -29,7 +49,7 @@ Mon Aug 06 17:17:33 2001 Ossama Othman <ossama@uci.edu>
regression testing happy until the on-the-fly generation is
implemented. Once we start generating this file on-the-fly
this file should disappear.
-
+
* tests/Service_Config_Test.cpp (run_test):
When using full Unicode support, use the version of the Service
@@ -62,9 +82,9 @@ Sun Aug 5 14:31:10 2001 Balachandran Natarajan <bala@cs.wustl.edu>
Service_Config_Test in static builds.
Fri Aug 04 3:33:31 2001 Yamuna Krishnamurthy <yamuna@cs.wustl.edu>
-
+
* ace/QoS/SOCK_Dgram_Mcast_QoS.h:
- * ace/QoS/SOCK_Dgram_Mcast_QoS.cpp:
+ * ace/QoS/SOCK_Dgram_Mcast_QoS.cpp:
Made the open method public so we can open UDP sockets for
non-multicast addresses.
diff --git a/ace/Hash_Map_Manager_T.cpp b/ace/Hash_Map_Manager_T.cpp
index dbab8a02a2c..a45e064d336 100644
--- a/ace/Hash_Map_Manager_T.cpp
+++ b/ace/Hash_Map_Manager_T.cpp
@@ -443,4 +443,79 @@ ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>:
return this->index_ >= 0;
}
+// ------------------------------------------------------------
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Const_Iterator_Base_Ex)
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> void
+ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump_i (void) const
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump_i");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("index_ = %d "), this->index_));
+ ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("next_ = %x"), this->next_));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::forward_i (void)
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::forward_i");
+
+ if (this->map_man_->table_ == 0)
+ return -1;
+ // Handle initial case specially.
+ else if (this->index_ == -1)
+ {
+ this->index_++;
+ return this->forward_i ();
+ }
+ else if (this->index_ >= ACE_static_cast (ssize_t, this->map_man_->total_size_))
+ return 0;
+
+ 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_].next_;
+ if (this->next_ != &this->map_man_->table_[this->index_])
+ break;
+ }
+ }
+
+ return this->index_ < ACE_static_cast (ssize_t, this->map_man_->total_size_);
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> int
+ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::reverse_i (void)
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::reverse_i");
+
+ if (this->map_man_->table_ == 0)
+ return -1;
+ else 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;
+
+ 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_].prev_;
+ if (this->next_ != &this->map_man_->table_[this->index_])
+ break;
+ }
+ }
+
+ return this->index_ >= 0;
+}
+
#endif /* ACE_HASH_MAP_MANAGER_T_CPP */
diff --git a/ace/Hash_Map_Manager_T.h b/ace/Hash_Map_Manager_T.h
index 4483dcb54ed..56b715913f8 100644
--- a/ace/Hash_Map_Manager_T.h
+++ b/ace/Hash_Map_Manager_T.h
@@ -69,10 +69,18 @@ class ACE_Hash_Map_Iterator_Base_Ex;
// Forward decl.
template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
+class ACE_Hash_Map_Const_Iterator_Base_Ex;
+
+// Forward decl.
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
class ACE_Hash_Map_Iterator_Ex;
// Forward decl.
template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
+class ACE_Hash_Map_Const_Iterator_Ex;
+
+// Forward decl.
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
class ACE_Hash_Map_Reverse_Iterator_Ex;
// Forward decl.
@@ -101,6 +109,8 @@ class ACE_Hash_Map_Manager_Ex
public:
friend class ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
friend class ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
+ friend class ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
+ friend class ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
friend class ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
friend class ACE_Hash_Map_Bucket_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>;
@@ -114,12 +124,16 @@ public:
// = ACE-style iterator typedefs.
typedef ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
ITERATOR;
+ typedef ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
+ CONST_ITERATOR;
typedef ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
REVERSE_ITERATOR;
// = STL-style iterator typedefs.
typedef ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
iterator;
+ typedef ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
+ const_iterator;
typedef ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
reverse_iterator;
@@ -248,7 +262,7 @@ public:
INT_ID &old_int_id,
ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry);
- /// Locate <ext_id> and pass out parameter via <int_id>.
+ /// Locate <ext_id> and pass out parameter via <int_id>.
/// Return 0 if found, returns -1 if not found.
int find (const EXT_ID &ext_id,
INT_ID &int_id) const;
@@ -269,11 +283,13 @@ public:
int unbind (const EXT_ID &ext_id);
/// Break any association of <ext_id>. Returns the value of <int_id>
- /// in case the caller needs to deallocate memory.
+ /// in case the caller needs to deallocate memory. Return 0 if the
+ /// unbind was successfully, and returns -1 if failures occur.
int unbind (const EXT_ID &ext_id,
INT_ID &int_id);
- /// Remove entry from map.
+ /// Remove entry from map. Return 0 if the unbind was successfully,
+ /// and returns -1 if failures occur.
int unbind (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *entry);
/// Return the current size of the map.
@@ -506,6 +522,70 @@ protected:
};
/**
+ * @class ACE_Hash_Map_Const_Iterator_Base_Ex
+ *
+ * @brief Base const iterator for the <ACE_Hash_Map_Manager_Ex>
+ *
+ * This class factors out common code from its templatized
+ * subclasses.
+ */
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
+class ACE_Hash_Map_Const_Iterator_Base_Ex
+{
+public:
+ // = Initialization method.
+ /// Contructor. If head != 0, the iterator constructed is positioned
+ /// at the head of the map, it is positioned at the end otherwise.
+ ACE_Hash_Map_Const_Iterator_Base_Ex (const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &mm,
+ int head);
+
+ // = ITERATION methods.
+
+ /// Pass back the next <entry> that hasn't been seen in the Set.
+ /// Returns 0 when all items have been seen, else 1.
+ int next (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&next_entry) const;
+
+ /// Returns 1 when all items have been seen, else 0.
+ int done (void) const;
+
+ /// Returns a reference to the interal element <this> is pointing to.
+ ACE_Hash_Map_Entry<EXT_ID, INT_ID>& operator* (void) const;
+
+ /// Returns reference the Hash_Map_Manager_Ex that is being iterated
+ /// over.
+ const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>& map (void);
+
+ /// Check if two iterators point to the same position
+ int operator== (const ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &) const;
+ int operator!= (const ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &) const;
+
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
+protected:
+ /// Move forward by one element in the set. Returns 0 when there's
+ /// no more item in the set after the current items, else 1.
+ int forward_i (void);
+
+ /// Move backward by one element in the set. Returns 0 when there's
+ /// no more item in the set before the current item, else 1.
+ int reverse_i (void);
+
+ /// Dump the state of an object.
+ void dump_i (void) const;
+
+ /// Map we are iterating over.
+ const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> *map_man_;
+
+ /// Keeps track of how far we've advanced in the table.
+ ssize_t index_;
+
+ /// Keeps track of how far we've advanced in a linked list in each
+ /// table slot.
+ ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next_;
+};
+
+/**
* @class ACE_Hash_Map_Iterator_Ex
*
* @brief Forward iterator for the <ACE_Hash_Map_Manager_Ex>.
@@ -552,6 +632,52 @@ public:
};
/**
+ * @class ACE_Hash_Map_Const_Iterator_Ex
+ *
+ * @brief Const forward iterator for the <ACE_Hash_Map_Manager_Ex>.
+ *
+ * This class does not perform any internal locking of the
+ * <ACE_Hash_Map_Manager_Ex> it is iterating upon since locking is
+ * inherently inefficient and/or error-prone within an STL-style
+ * iterator. If you require locking, you can explicitly use an
+ * <ACE_Guard> or <ACE_Read_Guard> on the <ACE_Hash_Map_Manager_Ex>'s
+ * internal lock, which is accessible via its <mutex> method.
+ */
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK>
+class ACE_Hash_Map_Const_Iterator_Ex : public ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
+{
+public:
+ // = Initialization method.
+ ACE_Hash_Map_Const_Iterator_Ex (const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &mm,
+ int tail = 0);
+
+ // = Iteration methods.
+ /// Move forward by one element in the set. Returns 0 when all the
+ /// items in the set have been seen, else 1.
+ int advance (void);
+
+ /// Dump the state of an object.
+ void dump (void) const;
+
+ // = STL styled iteration, compare, and reference functions.
+
+ /// Prefix advance.
+ ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator++ (void);
+
+ /// Postfix advance.
+ ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator++ (int);
+
+ /// Prefix reverse.
+ ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &operator-- (void);
+
+ /// Postfix reverse.
+ ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> operator-- (int);
+
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+};
+
+/**
* @class ACE_Hash_Map_Bucket_Iterator
*
* @brief Forward iterator for the <ACE_Hash_Map_Manager_Ex> which only
@@ -721,6 +847,28 @@ public:
};
/**
+ * @class ACE_Hash_Map_Const_Iterator
+ *
+ * @brief Wrapper for backward compatibility.
+ */
+template <class EXT_ID, class INT_ID, class ACE_LOCK>
+class ACE_Hash_Map_Const_Iterator : public ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK>
+{
+public:
+ // = Initialization method.
+ /// Construct from map
+ ACE_Hash_Map_Const_Iterator (const ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> &mm,
+ int tail = 0);
+
+ /// Construct from base
+ ACE_Hash_Map_Const_Iterator (const ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> &base);
+
+ /// Assignment from base
+ ACE_Hash_Map_Const_Iterator<EXT_ID, INT_ID, ACE_LOCK> &
+ operator= (const ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> &base);
+};
+
+/**
* @class ACE_Hash_Map_Reverse_Iterator
*
* @brief Wrapper for backward compatibility.
diff --git a/ace/Hash_Map_Manager_T.i b/ace/Hash_Map_Manager_T.i
index 2bd2911aba5..43ab4c15ce2 100644
--- a/ace/Hash_Map_Manager_T.i
+++ b/ace/Hash_Map_Manager_T.i
@@ -454,6 +454,89 @@ ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>:
|| this->map_man_ != rhs.map_man_;
}
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE
+ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::ACE_Hash_Map_Const_Iterator_Base_Ex (const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &mm,
+ int head)
+ : map_man_ (&mm),
+ index_ (head != 0 ? -1 : ACE_static_cast (ssize_t, mm.total_size_)),
+ next_ (0)
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::ACE_Hash_Map_Const_Iterator_Base_Ex");
+
+ if (mm.table_ != 0)
+ this->next_ = &mm.table_[head != 0 ? 0 : mm.total_size_ - 1];
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE int
+ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::next (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry) const
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::next");
+
+ if (this->map_man_->table_ != 0
+ && this->index_ < ACE_static_cast (ssize_t, this->map_man_->total_size_)
+ && this->index_ >= 0
+ && this->next_ != &this->map_man_->table_[this->index_])
+ {
+ entry = this->next_;
+ return 1;
+ }
+ else
+ return 0;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE int
+ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::done (void) const
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::done");
+
+ return this->map_man_->table_ == 0
+ || this->index_ >= ACE_static_cast (ssize_t, this->map_man_->total_size_)
+ || this->index_ < 0;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE
+ACE_Hash_Map_Entry<EXT_ID, INT_ID> &
+ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::operator* (void) const
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::operator*");
+ ACE_Hash_Map_Entry<EXT_ID, INT_ID> *retv = 0;
+
+ int result = this->next (retv);
+
+ ACE_UNUSED_ARG (result);
+ ACE_ASSERT (result != 0);
+
+ return *retv;
+}
+
+// Returns the reference to the hash_map_manager_ex that is being
+// iterated over.
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE
+const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>&
+ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::map (void)
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::map");
+ return *this->map_man_;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE int
+ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::operator== (const ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &rhs) const
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::operator==");
+ return this->map_man_ == rhs.map_man_
+ && this->index_ == rhs.index_
+ && this->next_ == rhs.next_;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE int
+ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::operator!= (const ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &rhs) const
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::operator!=");
+ return this->next_ != rhs.next_
+ || this->index_ != rhs.index_
+ || this->map_man_ != rhs.map_man_;
+}
+
ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Iterator_Ex)
template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE void
@@ -524,6 +607,76 @@ ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::oper
return retv;
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Const_Iterator_Ex)
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE void
+ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump (void) const
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump");
+
+ this->dump_i ();
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE
+ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::ACE_Hash_Map_Const_Iterator_Ex (const ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &mm,
+ int tail)
+ : ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> (mm,
+ tail == 0 ? 1 : 0)
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::ACE_Hash_Map_Const_Iterator_Ex");
+ if (tail == 0)
+ this->forward_i ();
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE int
+ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::advance (void)
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::advance");
+ return this->forward_i ();
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE
+ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &
+ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::operator++ (void)
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::operator++ (void)");
+
+ this->forward_i ();
+ return *this;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE
+ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
+ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::operator++ (int)
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::operator++ (int)");
+
+ ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> retv (*this);
+ this->forward_i ();
+ return retv;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE
+ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &
+ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::operator-- (void)
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::operator-- (void)");
+
+ this->reverse_i ();
+ return *this;
+}
+
+template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE
+ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>
+ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::operator-- (int)
+{
+ ACE_TRACE ("ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::operator-- (int)");
+
+ ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> retv (*this);
+ this->reverse_i ();
+ return retv;
+}
+
template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE
ACE_Hash_Map_Bucket_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::ACE_Hash_Map_Bucket_Iterator (ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> &mm,
const EXT_ID &ext_id,
@@ -745,9 +898,39 @@ ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>::ACE_Hash_Map_Iterator (const AC
template <class EXT_ID, class INT_ID, class ACE_LOCK> ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK> &
ACE_Hash_Map_Iterator<EXT_ID, INT_ID, ACE_LOCK>::operator= (const ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> &rhs)
{
- ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> &base = *this;
+ if (this != &rhs)
+ {
+ ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> &base = *this;
- base = rhs;
+ base = rhs;
+ }
+
+ return *this;
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK>
+ACE_Hash_Map_Const_Iterator<EXT_ID, INT_ID, ACE_LOCK>::ACE_Hash_Map_Const_Iterator (const ACE_Hash_Map_Manager<EXT_ID, INT_ID, ACE_LOCK> &mm,
+ int tail)
+ : ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> (mm,
+ tail)
+{
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK>
+ACE_Hash_Map_Const_Iterator<EXT_ID, INT_ID, ACE_LOCK>::ACE_Hash_Map_Const_Iterator (const ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> &base)
+ : ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> (base)
+{
+}
+
+template <class EXT_ID, class INT_ID, class ACE_LOCK> ACE_Hash_Map_Const_Iterator<EXT_ID, INT_ID, ACE_LOCK> &
+ACE_Hash_Map_Const_Iterator<EXT_ID, INT_ID, ACE_LOCK>::operator= (const ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> &rhs)
+{
+ if (this != &rhs)
+ {
+ ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, ACE_Hash<EXT_ID>, ACE_Equal_To<EXT_ID>, ACE_LOCK> &base = *this;
+
+ base = rhs;
+ }
return *this;
}
diff --git a/tests/Collection_Test.cpp b/tests/Collection_Test.cpp
index 0b7fdcc1618..8b0cd1a623a 100644
--- a/tests/Collection_Test.cpp
+++ b/tests/Collection_Test.cpp
@@ -40,6 +40,9 @@ void iterate_const(const UNBOUNDED_SET& set)
iterator.next (data);
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%d\n"),
(*data)));
+ DATA *data_second = *iterator;
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%d\n"),
+ (*data_second)));
iterator.advance ();
}
}
diff --git a/tests/Hash_Map_Manager_Test.cpp b/tests/Hash_Map_Manager_Test.cpp
index 3f1d167ed3b..e1af3bb4a43 100644
--- a/tests/Hash_Map_Manager_Test.cpp
+++ b/tests/Hash_Map_Manager_Test.cpp
@@ -43,14 +43,18 @@ static const size_t STRING_TABLE_SIZE =
template class ACE_Hash_Map_Entry<const ACE_TCHAR *, const ACE_TCHAR *>;
template class ACE_Hash_Map_Manager_Ex<const ACE_TCHAR *, const ACE_TCHAR *, ACE_Hash<const ACE_TCHAR *>, ACE_Equal_To<const ACE_TCHAR *>, ACE_Null_Mutex>;
template class ACE_Hash_Map_Iterator_Base_Ex<const ACE_TCHAR *, const ACE_TCHAR *, ACE_Hash<const ACE_TCHAR *>, ACE_Equal_To<const ACE_TCHAR *>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Const_Iterator_Base_Ex<const ACE_TCHAR *, const ACE_TCHAR *, ACE_Hash<const ACE_TCHAR *>, ACE_Equal_To<const ACE_TCHAR *>, ACE_Null_Mutex>;
template class ACE_Hash_Map_Iterator_Ex<const ACE_TCHAR *, const ACE_TCHAR *, ACE_Hash<const ACE_TCHAR *>, ACE_Equal_To<const ACE_TCHAR *>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Const_Iterator_Ex<const ACE_TCHAR *, const ACE_TCHAR *, ACE_Hash<const ACE_TCHAR *>, ACE_Equal_To<const ACE_TCHAR *>, ACE_Null_Mutex>;
template class ACE_Hash_Map_Reverse_Iterator_Ex<const ACE_TCHAR *, const ACE_TCHAR *, ACE_Hash<const ACE_TCHAR *>, ACE_Equal_To<const ACE_TCHAR *>, ACE_Null_Mutex>;
template class ACE_Static_Allocator<STRING_TABLE_SIZE>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#pragma instantiate ACE_Hash_Map_Entry<const ACE_TCHAR *, const ACE_TCHAR *>
#pragma instantiate ACE_Hash_Map_Manager_Ex<const ACE_TCHAR *, const ACE_TCHAR *, ACE_Hash<const ACE_TCHAR *>, ACE_Equal_To<const ACE_TCHAR *>, ACE_Null_Mutex>
#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<const ACE_TCHAR *, const ACE_TCHAR *, ACE_Hash<const ACE_TCHAR *>, ACE_Equal_To<const ACE_TCHAR *>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Const_Iterator_Base_Ex<const ACE_TCHAR *, const ACE_TCHAR *, ACE_Hash<const ACE_TCHAR *>, ACE_Equal_To<const ACE_TCHAR *>, ACE_Null_Mutex>
#pragma instantiate ACE_Hash_Map_Iterator_Ex<const ACE_TCHAR *, const ACE_TCHAR *, ACE_Hash<const ACE_TCHAR *>, ACE_Equal_To<const ACE_TCHAR *>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Const_Iterator_Ex<const ACE_TCHAR *, const ACE_TCHAR *, ACE_Hash<const ACE_TCHAR *>, ACE_Equal_To<const ACE_TCHAR *>, ACE_Null_Mutex>
#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<const ACE_TCHAR *, const ACE_TCHAR *, ACE_Hash<const ACE_TCHAR *>, ACE_Equal_To<const ACE_TCHAR *>, ACE_Null_Mutex>
#pragma instantiate ACE_Static_Allocator<STRING_TABLE_SIZE>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
@@ -69,6 +73,12 @@ typedef ACE_Hash_Map_Iterator_Ex<const ACE_TCHAR *,
ACE_Equal_To<const ACE_TCHAR *>,
ACE_Null_Mutex> HASH_STRING_ITER;
+typedef ACE_Hash_Map_Const_Iterator_Ex<const ACE_TCHAR *,
+ const ACE_TCHAR *,
+ ACE_Hash<const ACE_TCHAR *>,
+ ACE_Equal_To<const ACE_TCHAR *>,
+ ACE_Null_Mutex> HASH_STRING_CONST_ITER;
+
typedef ACE_Hash_Map_Reverse_Iterator_Ex<const ACE_TCHAR *,
const ACE_TCHAR *,
ACE_Hash<const ACE_TCHAR *>,
@@ -101,7 +111,6 @@ static String_Table string_table[] =
}
};
-
static int
run_test (void)
{
@@ -168,6 +177,24 @@ run_test (void)
}
}
+ // And now test the const iterator
+ {
+ HASH_STRING_ENTRY *entry;
+ size_t i = 0;
+
+ for (HASH_STRING_CONST_ITER hash_iter (hash);
+ hash_iter.next (entry) != 0;
+ hash_iter.advance ())
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("const iterating (%d): [%s, %s]\n"),
+ i,
+ entry->ext_id_,
+ entry->int_id_));
+ i++;
+ }
+ }
+
hash.unbind (string_table[2].key_, entry);
// Check the <find> operation again.