]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Added default arguments to Splay::destroy
authorFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 30 Dec 2014 14:23:21 +0000 (15:23 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 30 Dec 2014 14:23:21 +0000 (15:23 +0100)
Added documentation to Splay::find
Added Splay::empty()
Removed obsolete tests in test-suite/splay.cc

include/splay.h
test-suite/splay.cc

index eae7380d33f3d8039dd854f06b74f95b4f0b2623..30f346281ef9e4b9f7c5be0c576b60ba0e453338 100644 (file)
@@ -15,6 +15,8 @@
 
 #include <stack>
 
+
+// private class of Splay. Do not use directly
 template <class V>
 class SplayNode
 {
@@ -30,7 +32,7 @@ public:
     Value data;
     mutable SplayNode<V> *left;
     mutable SplayNode<V> *right;
-    void destroy(SPLAYFREE *);
+    void destroy(SPLAYFREE * = DefaultFree);
     void walk(SPLAYWALKEE *, void *callerState);
     bool empty() const { return this == NULL; }
     SplayNode<V> const * start() const;
@@ -40,6 +42,8 @@ public:
 
     SplayNode<V> * insert(Value data, SPLAYCMP * compare);
 
+    /// look in the splay for data for where compare(data,candidate) == true.
+    /// return NULL if not found, a pointer to the sought data if found.
     template <class FindValue> SplayNode<V> * splay(const FindValue &data, int( * compare)(FindValue const &a, Value const &b)) const;
 
     /// recursively visit left nodes, this node, and then right nodes
@@ -68,11 +72,12 @@ public:
 
     mutable SplayNode<V> * head;
     template <class FindValue> Value const *find (FindValue const &, int( * compare)(FindValue const &a, Value const &b)) const;
+
     void insert(Value const &, SPLAYCMP *compare);
 
     void remove(Value const &, SPLAYCMP *compare);
 
-    void destroy(SPLAYFREE *);
+    void destroy(SPLAYFREE * = SplayNode<V>::DefaultFree);
 
     SplayNode<V> const * start() const;
 
@@ -80,6 +85,8 @@ public:
 
     size_t size() const;
 
+    bool empty() { return size() == 0; }
+
     const_iterator begin() const;
 
     const_iterator end() const;
index 573946347efb28c372e80123c90dd685ebcac4de..3265786a7a72344d584af701ecb420c278a58885 100644 (file)
@@ -194,11 +194,6 @@ main(int argc, char *argv[])
         safeTop->walk(SplayCheck::WalkNodeRef, NULL);
 
         safeTop->destroy(destintref);
-        /* check we don't segfault on NULL splay calls */
-        safeTop = NULL;
-        safeTop->splay(intnode(), compareintref);
-        SplayCheck::BeginWalk();
-        safeTop->walk(SplayCheck::WalkNodeRef, NULL);
     }
 
     /* check the check routine */