]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Summary: Fix iterator-conflict in the name Splay::end
authorrobertc <>
Mon, 22 Sep 2003 09:31:02 +0000 (09:31 +0000)
committerrobertc <>
Mon, 22 Sep 2003 09:31:02 +0000 (09:31 +0000)
Keywords:

Fix iterator-conflict in the name Splay::end

include/splay.h
src/stmem.h
test-suite/mem_hdr_test.cc
test-suite/splay.cc

index bec5f20ba5a2075b777110752bb73581e439fe29..dfc46ddd467a4f7849c7d55c4cb4f8029c3f39bc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: splay.h,v 1.24 2003/09/02 22:57:00 robertc Exp $
+ * $Id: splay.h,v 1.25 2003/09/22 03:31:03 robertc Exp $
  */
 
 #ifndef SQUID_SPLAY_H
@@ -51,7 +51,7 @@ public:
     void destroy(SPLAYFREE *);
     void walk(SPLAYWALKEE *, void *callerState);
     SplayNode<V> const * start() const;
-    SplayNode<V> const * end() const;
+    SplayNode<V> const * finish() const;
 
     SplayNode<V> * remove
         (const Value data, SPLAYCMP * compare);
@@ -65,6 +65,10 @@ typedef SplayNode<void *> splayNode;
 
 template <class V>
 
+class SplayIterator;
+
+template <class V>
+
 class Splay
 {
 
@@ -85,7 +89,7 @@ public:
 
     SplayNode<V> const * start() const;
 
-    SplayNode<V> const * end() const;
+    SplayNode<V> const * finish() const;
 
     size_t size() const;
 
@@ -137,10 +141,10 @@ SplayNode<V>::start() const
 
 template<class V>
 SplayNode<V> const *
-SplayNode<V>::end() const
+SplayNode<V>::finish() const
 {
     if (this && right)
-        return right->end();
+        return right->finish();
 
     return this;
 }
@@ -338,10 +342,10 @@ Splay<V>:: start() const
 
 template <class V>
 SplayNode<V> const *
-Splay<V>:: end() const
+Splay<V>:: finish() const
 {
     if (head)
-        return head->end();
+        return head->finish();
 
     return NULL;
 }
index b47fff8a2938bfa27e775574d21899f9017fc5ff..4a99351501aa2701939d091008a290691d8ca279 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stmem.h,v 1.4 2003/06/26 12:51:57 robertc Exp $
+ * $Id: stmem.h,v 1.5 2003/09/22 03:31:03 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -61,6 +61,10 @@ public:
     /* Not an iterator - thus the start, not begin() */
     mem_node const *start() const;
     mem_node *getBlockContainingLocation (size_t location) const;
+    /* access the contained nodes - easier than punning
+     * as a contianer ourselves 
+     */
+    const Splay<mem_node *> &getNodes() const;
 
     /* Only for use of MemObject */
     void internalAppend(const char *data, int len);
index 1388d0a8967a0a8c2c3588f8bbee418deb45069c..ae950d977af0d3f4d1facfae2016a110c51d9a5a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: mem_hdr_test.cc,v 1.3 2003/09/22 02:43:11 robertc Exp $
+ * $Id: mem_hdr_test.cc,v 1.4 2003/09/22 03:31:02 robertc Exp $
  *
  * DEBUG: section 19    Store Memory Primitives
  * AUTHOR: Robert Collins
@@ -38,6 +38,7 @@
 #include "stmem.h"
 #include "mem_node.h"
 #include <iostream>
+#include "Generic.h"
 
 void
 testLowAndHigh()
@@ -72,14 +73,14 @@ testSplayOfNodes()
     temp5->nodeBuffer.length = 10;
     aSplay.insert (temp5, mem_hdr::NodeCompare);
     assert (aSplay.start()->data == temp5);
-    assert (aSplay.end()->data == temp5);
+    assert (aSplay.finish()->data == temp5);
 
     mem_node *temp0;
     temp0 = new mem_node(0);
     temp0->nodeBuffer.length = 5;
     aSplay.insert (temp0, mem_hdr::NodeCompare);
     assert (aSplay.start()->data == temp0);
-    assert (aSplay.end()->data == temp5);
+    assert (aSplay.finish()->data == temp5);
 
     mem_node *temp14;
     temp14 = new mem_node (14);
@@ -94,6 +95,29 @@ testSplayOfNodes()
     aSplay.destroy(SplayNode<mem_node *>::DefaultFree);
 }
 
+struct mem_node_print
+{
+    mem_node_print(std::ostream &astream) : os(astream) {}
+
+    void operator () (mem_node *aNode)
+    {}
+
+    std::ostream &os;
+};
+
+void
+testHdrVisit()
+{
+    mem_hdr aHeader;
+    char * sampleData = xstrdup ("A");
+    assert (aHeader.write (StoreIOBuffer(1, 100, sampleData)));
+    safe_free (sampleData);
+    sampleData = xstrdup ("B");
+    assert (aHeader.write (StoreIOBuffer(1, 102, sampleData)));
+    safe_free (sampleData);
+    //for_each (aHeader.getNodes().begin(). aHeader.getNodes().end(), mem_node_print(std::cout));
+}
+
 int
 main (int argc, char *argv)
 {
@@ -102,5 +126,7 @@ main (int argc, char *argv)
     assert (mem_node::InUseCount() == 0);
     testSplayOfNodes();
     assert (mem_node::InUseCount() == 0);
+    testHdrVisit();
+    assert (mem_node::InUseCount() == 0);
     return 0;
 }
index cf5761f036cff627f757961b1343062a7747b2ea..0ee0613b86c42bf36d9e44d7efa00411cc21b604 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: splay.cc,v 1.5 2003/06/26 12:52:00 robertc Exp $
+ * $Id: splay.cc,v 1.6 2003/09/22 03:31:02 robertc Exp $
  *
  * based on ftp://ftp.cs.cmu.edu/user/sleator/splaying/top-down-splay.c
  * http://bobo.link.cs.cmu.edu/cgi-bin/splay/splay-cgi.pl
@@ -214,7 +214,7 @@ main(int argc, char *argv[])
         if (safeTop->start() != NULL)
             exit (1);
 
-        if (safeTop->end() != NULL)
+        if (safeTop->finish() != NULL)
             exit (1);
 
         for (int i = 0; i < 100; i++) {
@@ -239,10 +239,10 @@ main(int argc, char *argv[])
         if (safeTop->start()->data.i != 50)
             exit (1);
 
-        if (!safeTop->end())
+        if (!safeTop->finish())
             exit (1);
 
-        if (safeTop->end()->data.i != 10000000)
+        if (safeTop->finish()->data.i != 10000000)
             exit (1);
 
         safeTop->destroy(destintref);