#ifndef SQUID_SPLAY_H
#define SQUID_SPLAY_H
-#if defined(__cplusplus)
-
#include "fatal.h"
-
#include <stack>
-
// private class of Splay. Do not use directly
template <class V>
class SplayNode
{
-
public:
typedef V Value;
typedef int SPLAYCMP(Value const &a, Value const &b);
template <class V>
class Splay
{
-
public:
typedef V Value;
typedef int SPLAYCMP(Value const &a, Value const &b);
typedef const SplayConstIterator<V> const_iterator;
Splay():head(NULL), elements (0) {}
- 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);
template <class Visitor> void visit(Visitor &v) const;
size_t elements;
+private:
+ mutable SplayNode<V> * head;
};
SQUIDCEXTERN int splayLastResult;
return toVisit.top()->data;
}
-#endif /* cplusplus */
-
#endif /* SQUID_SPLAY_H */
DelayTagged::~DelayTagged()
{
DelayPools::deregisterForUpdates (this);
- buckets.head->destroy (DelayTaggedFree);
+ buckets->destroy (DelayTaggedFree);
}
static Splay<DelayTaggedBucket::Pointer>::SPLAYCMP DelayTaggedCmp;
DelayTaggedFree(DelayTaggedBucket::Pointer &)
{}
-void
-DelayTaggedStatsWalkee(DelayTaggedBucket::Pointer const ¤t, void *state)
-{
- current->stats ((StoreEntry *)state);
-}
+struct DelayTaggedStatsVisitor {
+ StoreEntry *sentry;
+ explicit DelayTaggedStatsVisitor(StoreEntry *se) sentry(se) {}
+ void operator() (DelayTaggedBucket::Pointer const ¤t) {
+ current->stats(sentry);
+ }
+};
void
DelayTagged::stats(StoreEntry * sentry)
storeAppendPrintf(sentry, "\t\tCurrent: ");
- if (!buckets.head) {
+ if (buckets.empty()) {
storeAppendPrintf (sentry, "Not used yet.\n\n");
return;
}
- buckets.head->walk(DelayTaggedStatsWalkee, sentry);
+ DelayTaggedStatsVisitor visitor(sentry);
+ buckets.visit(visitor);
storeAppendPrintf(sentry, "\n\n");
}