summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-10-02 19:47:21 +0000
committeralberth <alberth@openttd.org>2010-10-02 19:47:21 +0000
commit6802527e02109936e06c31a2b22da1471054a2f5 (patch)
tree0faf59862f449a89199f841375119383af740e05 /src
parent4af4d268d875c0dc09b5e1cea77d52b07dc3ec6e (diff)
downloadopenttd-6802527e02109936e06c31a2b22da1471054a2f5.tar.xz
(svn r20887) -Codechange: Make stat_Hash a method.
Diffstat (limited to 'src')
-rw-r--r--src/pathfinder/npf/queue.cpp10
-rw-r--r--src/pathfinder/npf/queue.h5
2 files changed, 10 insertions, 5 deletions
diff --git a/src/pathfinder/npf/queue.cpp b/src/pathfinder/npf/queue.cpp
index 3075ebf73..5ad5add02 100644
--- a/src/pathfinder/npf/queue.cpp
+++ b/src/pathfinder/npf/queue.cpp
@@ -303,7 +303,7 @@ void Hash::Delete(bool free_values)
}
#ifdef HASH_STATS
-static void stat_Hash(const Hash *h)
+void Hash::PrintStatistics() const
{
uint used_buckets = 0;
uint max_collision = 0;
@@ -312,13 +312,13 @@ static void stat_Hash(const Hash *h)
uint i;
for (i = 0; i < lengthof(usage); i++) usage[i] = 0;
- for (i = 0; i < h->num_buckets; i++) {
+ for (i = 0; i < this->num_buckets; i++) {
uint collision = 0;
- if (h->buckets_in_use[i]) {
+ if (this->buckets_in_use[i]) {
const HashNode *node;
used_buckets++;
- for (node = &h->buckets[i]; node != NULL; node = node->next) collision++;
+ for (node = &this->buckets[i]; node != NULL; node = node->next) collision++;
if (collision > max_collision) max_collision = collision;
}
if (collision >= lengthof(usage)) collision = lengthof(usage) - 1;
@@ -333,7 +333,7 @@ static void stat_Hash(const Hash *h)
"Nodes used: %d\n"
"Non empty buckets: %d\n"
"Max collision: %d\n",
- h->num_buckets, h->size, used_buckets, max_collision
+ this->num_buckets, this->size, used_buckets, max_collision
);
printf("{ ");
for (i = 0; i <= max_collision; i++) {
diff --git a/src/pathfinder/npf/queue.h b/src/pathfinder/npf/queue.h
index 69c1602df..51b097a16 100644
--- a/src/pathfinder/npf/queue.h
+++ b/src/pathfinder/npf/queue.h
@@ -103,6 +103,11 @@ struct Hash {
{
return this->size;
}
+
+protected:
+#ifdef HASH_STATS
+ void PrintStatistics() const;
+#endif
};
#endif /* QUEUE_H */