From: Francesco Chemolli Date: Tue, 30 Dec 2014 14:23:21 +0000 (+0100) Subject: Added default arguments to Splay::destroy X-Git-Tag: merge-candidate-3-v1~384^2~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fb3eae94bd11978bd86b25e4a7631f9bc38ed3da;p=thirdparty%2Fsquid.git Added default arguments to Splay::destroy Added documentation to Splay::find Added Splay::empty() Removed obsolete tests in test-suite/splay.cc --- diff --git a/include/splay.h b/include/splay.h index eae7380d33..30f346281e 100644 --- a/include/splay.h +++ b/include/splay.h @@ -15,6 +15,8 @@ #include + +// private class of Splay. Do not use directly template class SplayNode { @@ -30,7 +32,7 @@ public: Value data; mutable SplayNode *left; mutable SplayNode *right; - void destroy(SPLAYFREE *); + void destroy(SPLAYFREE * = DefaultFree); void walk(SPLAYWALKEE *, void *callerState); bool empty() const { return this == NULL; } SplayNode const * start() const; @@ -40,6 +42,8 @@ public: SplayNode * 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 SplayNode * 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 * head; template 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::DefaultFree); SplayNode 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; diff --git a/test-suite/splay.cc b/test-suite/splay.cc index 573946347e..3265786a7a 100644 --- a/test-suite/splay.cc +++ b/test-suite/splay.cc @@ -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 */