summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog-99b13
-rw-r--r--ace/Containers_T.cpp18
-rw-r--r--ace/Containers_T.h37
-rw-r--r--ace/Containers_T.i14
-rw-r--r--tests/DLList_Test.cpp15
-rw-r--r--tests/Map_Manager_Test.cpp6
6 files changed, 95 insertions, 8 deletions
diff --git a/ChangeLog-99b b/ChangeLog-99b
index 0bf2146b121..5ecc52271e8 100644
--- a/ChangeLog-99b
+++ b/ChangeLog-99b
@@ -1,3 +1,16 @@
+Thu Jul 1 21:49:39 1999 Matthew J Braun <mjb2@cs.wustl.edu>
+
+ * ace/Containers_T.i,h,cpp
+ Added reset () methods to the derived classes of
+ ACE_Double_Linked_List_Iterator because the behavior of the base
+ class's version was not sufficient (and would cause way fun
+ segfaults when used).
+
+ * tests/Map_Manager_Test.cpp
+ * tests/DLList_Test.cpp
+ ACE_const_cast'ed some string literals to char *'s to appease
+ the evil monstrosity that is SC 5.0.
+
Wed Jun 30 18:11:41 1999 Ossama Othman <othman@cs.wustl.edu>
* ace/OS.i (strncasecmp):
diff --git a/ace/Containers_T.cpp b/ace/Containers_T.cpp
index bf85900e970..e5c4d04a295 100644
--- a/ace/Containers_T.cpp
+++ b/ace/Containers_T.cpp
@@ -797,6 +797,15 @@ ACE_Double_Linked_List_Iterator<T>::ACE_Double_Linked_List_Iterator (ACE_Double_
// the list
}
+template <class T> void
+ACE_Double_Linked_List_Iterator<T>::reset (ACE_Double_Linked_List<T> &dll)
+{
+ this->ACE_Double_Linked_List_Iterator_Base <T>::reset (dll);
+ this->current_ = ACE_static_cast (T*, dll.head_->next_);
+ // Advance current_ out of the null area and onto the first item in
+ // the list
+}
+
template <class T> int
ACE_Double_Linked_List_Iterator<T>::first (void)
{
@@ -888,6 +897,15 @@ ACE_Double_Linked_List_Reverse_Iterator<T>::ACE_Double_Linked_List_Reverse_Itera
// the list
}
+template <class T> void
+ACE_Double_Linked_List_Reverse_Iterator<T>::reset (ACE_Double_Linked_List<T> &dll)
+{
+ this->ACE_Double_Linked_List_Iterator_Base <T>::reset (dll);
+ this->current_ = ACE_static_cast (T*, dll.head_->prev_);
+ // Advance current_ out of the null area and onto the last item in
+ // the list
+}
+
template <class T> int
ACE_Double_Linked_List_Reverse_Iterator<T>::first (void)
{
diff --git a/ace/Containers_T.h b/ace/Containers_T.h
index 8ab9a975890..acfadb4c9b5 100644
--- a/ace/Containers_T.h
+++ b/ace/Containers_T.h
@@ -620,6 +620,15 @@ public:
// = Initialization method.
ACE_Double_Linked_List_Iterator (ACE_Double_Linked_List<T> &);
+ void reset (ACE_Double_Linked_List<T> &);
+ // Retasks the iterator to iterate over a new
+ // Double_Linked_List. This allows clients to reuse an iterator
+ // without incurring the constructor overhead. If you do use this,
+ // be aware that if there are more than one reference to this
+ // iterator, the other "clients" may be very bothered when their
+ // iterator changes.
+ // @@ Here be dragons. Comments?
+
int first (void);
// Move to the first element in the list. Returns 0 if the
// list is empty, else 1.
@@ -674,6 +683,15 @@ public:
// = Initialization method.
ACE_Double_Linked_List_Reverse_Iterator (ACE_Double_Linked_List<T> &);
+ void reset (ACE_Double_Linked_List<T> &);
+ // Retasks the iterator to iterate over a new
+ // Double_Linked_List. This allows clients to reuse an iterator
+ // without incurring the constructor overhead. If you do use this,
+ // be aware that if there are more than one reference to this
+ // iterator, the other "clients" may be very bothered when their
+ // iterator changes.
+ // @@ Here be dragons. Comments?
+
int first (void);
// Move to the first element in the list. Returns 0 if the
// list is empty, else 1.
@@ -864,6 +882,7 @@ class ACE_DLList : public ACE_DLList_Base
friend class ACE_DLList_Reverse_Iterator<T>;
public:
+
void operator= (ACE_DLList<T> &l);
// Delegates to ACE_Double_Linked_List.
@@ -926,6 +945,15 @@ public:
// = Initialization method.
ACE_DLList_Iterator (ACE_DLList<T> &l);
+ void reset (ACE_DLList<T> &l);
+ // Retasks the iterator to iterate over a new
+ // Double_Linked_List. This allows clients to reuse an iterator
+ // without incurring the constructor overhead. If you do use this,
+ // be aware that if there are more than one reference to this
+ // iterator, the other "clients" may be very bothered when their
+ // iterator changes.
+ // @@ Here be dragons. Comments?
+
// = Iteration methods.
int advance (void);
// Move forward by one element in the set. Returns 0 when all the
@@ -970,6 +998,15 @@ public:
// = Initialization method.
ACE_DLList_Reverse_Iterator (ACE_DLList<T> &l);
+ void reset (ACE_DLList<T> &l);
+ // Retasks the iterator to iterate over a new
+ // Double_Linked_List. This allows clients to reuse an iterator
+ // without incurring the constructor overhead. If you do use this,
+ // be aware that if there are more than one reference to this
+ // iterator, the other "clients" may be very bothered when their
+ // iterator changes.
+ // @@ Here be dragons. Comments?
+
// = Iteration methods.
int advance (void);
// Move forward by one element in the set. Returns 0 when all the
diff --git a/ace/Containers_T.i b/ace/Containers_T.i
index 6439b00ed82..b9ef057be2c 100644
--- a/ace/Containers_T.i
+++ b/ace/Containers_T.i
@@ -495,6 +495,13 @@ ACE_DLList_Iterator<T>::ACE_DLList_Iterator (ACE_DLList<T> &l)
{
}
+template <class T> ACE_INLINE void
+ACE_DLList_Iterator<T>::reset (ACE_DLList<T> &l)
+{
+ list_ = l;
+ this->ACE_Double_Linked_List_Iterator <ACE_DLList_Node>::reset ((ACE_DLList_Base &)l);
+}
+
template <class T> ACE_INLINE int
ACE_DLList_Iterator<T>::next (T *&ptr)
{
@@ -540,6 +547,13 @@ ACE_DLList_Reverse_Iterator<T>::ACE_DLList_Reverse_Iterator (ACE_DLList<T> &l)
{
}
+template <class T> ACE_INLINE void
+ACE_DLList_Reverse_Iterator<T>::reset (ACE_DLList<T> &l)
+{
+ list_ = l;
+ this->ACE_Double_Linked_List_Reverse_Iterator <ACE_DLList_Node>::reset ((ACE_DLList_Base &)l);
+}
+
template <class T> ACE_INLINE int
ACE_DLList_Reverse_Iterator<T>::advance (void)
{
diff --git a/tests/DLList_Test.cpp b/tests/DLList_Test.cpp
index 2f32608ef5b..7b37922e623 100644
--- a/tests/DLList_Test.cpp
+++ b/tests/DLList_Test.cpp
@@ -34,12 +34,15 @@ typedef ACE_DLList_Iterator<STRING> STRLIST_ITERATOR;
static STRING string_table[] =
{
- ASYS_TEXT ("hello"),
- ASYS_TEXT ("guten Tag"),
- ASYS_TEXT ("goodbye"),
- ASYS_TEXT ("auf wiedersehen"),
- ASYS_TEXT ("funny"),
- ASYS_TEXT ("lustig"),
+ // Note: all these casts are to appease SC 5.0 which is not pleased
+ // with using string literals (i.e. const char *'s) as char
+ // *'s. It's ugly, but necessary.
+ ASYS_TEXT (ACE_const_cast (char *, "hello")),
+ ASYS_TEXT (ACE_const_cast (char *, "guten Tag")),
+ ASYS_TEXT (ACE_const_cast (char *, "goodbye")),
+ ASYS_TEXT (ACE_const_cast (char *, "auf wiedersehen")),
+ ASYS_TEXT (ACE_const_cast (char *, "funny")),
+ ASYS_TEXT (ACE_const_cast (char *, "lustig")),
0
};
diff --git a/tests/Map_Manager_Test.cpp b/tests/Map_Manager_Test.cpp
index d73bf26a6e3..69ca50608fb 100644
--- a/tests/Map_Manager_Test.cpp
+++ b/tests/Map_Manager_Test.cpp
@@ -843,10 +843,12 @@ run_test (void (*ptf) (size_t, size_t, int),
if (test_iterators)
test_iterators_string =
- ASYS_TEXT ("includes executing iterators");
+ ASYS_TEXT (ACE_const_cast (char*,
+ "includes executing iterators"));
else
test_iterators_string =
- ASYS_TEXT ("doesn't include executing iterators");
+ ASYS_TEXT (ACE_const_cast (char*,
+ "doesn't include executing iterators"));
ACE_DEBUG ((LM_DEBUG,
ASYS_TEXT ("time to test a map of size %d for %d iterations using %s (%s)\n"),