From 2f841c54f8bf3c1c25f2597348c9a2b403b31c37 Mon Sep 17 00:00:00 2001 From: Vincent Ollivier Date: Mon, 16 Apr 2012 21:24:10 +0200 Subject: [PATCH] Remove 'get_' from HashTable getters --- src/hashtable.h | 12 ++++++------ src/output.cpp | 22 +++++++++++----------- test/unit/test_transpositions.cpp | 10 +++++----- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/hashtable.h b/src/hashtable.h index a24ae6f..a04ae0f 100644 --- a/src/hashtable.h +++ b/src/hashtable.h @@ -58,24 +58,24 @@ class HashTable return SIZE; }; - T get_value_at(int i) const { + T value_at(int i) const { return entries[i].value; }; - Hash get_hash_at(int i) const { + Hash hash_at(int i) const { return entries[i].hash; }; int get_usage() const; - long get_nb_lookups() const { + long nb_lookups() const { return hits + misses; }; - long get_nb_hits() const { + long nb_hits() const { return hits; }; - long get_nb_collisions() const { + long nb_collisions() const { return collisions; }; - long get_nb_misses() const { + long nb_misses() const { return misses; }; }; diff --git a/src/output.cpp b/src/output.cpp index 75983ac..bc7cfd5 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -178,7 +178,7 @@ std::string print_table_stats(const HashTable& table, int table_size) long zeros = 0; long ones = 0; for (int i = 0; i < table.size(); ++i) { - Hash h = table.get_hash_at(i); + Hash h = table.hash_at(i); if (!h) continue; std::bitset<64> b = h; int z = b.count(); @@ -203,22 +203,22 @@ std::string print_table_stats(const HashTable& table, int table_size) stream << get_stat("1's", get_percent(ones, 64 * table.get_usage()), "%"); stream << std::endl; - stream << get_stat("Lookups", table.get_nb_lookups()); + stream << get_stat("Lookups", table.nb_lookups()); stream << std::endl; - stream << get_stat("Hits", table.get_nb_hits()); - stream << get_meta(get_percent(table.get_nb_hits(), - table.get_nb_lookups()), "%"); + stream << get_stat("Hits", table.nb_hits()); + stream << get_meta(get_percent(table.nb_hits(), + table.nb_lookups()), "%"); stream << std::endl; - stream << get_stat("Collisions", table.get_nb_collisions()); - stream << get_meta(get_percent(table.get_nb_collisions(), - table.get_nb_lookups()), "%"); + stream << get_stat("Collisions", table.nb_collisions()); + stream << get_meta(get_percent(table.nb_collisions(), + table.nb_lookups()), "%"); stream << std::endl; - stream << get_stat("Misses", table.get_nb_misses()); - stream << get_meta(get_percent(table.get_nb_misses(), - table.get_nb_lookups()), "%"); + stream << get_stat("Misses", table.nb_misses()); + stream << get_meta(get_percent(table.nb_misses(), + table.nb_lookups()), "%"); stream << std::endl; return stream.str(); diff --git a/test/unit/test_transpositions.cpp b/test/unit/test_transpositions.cpp index 129cf74..ec9f01f 100644 --- a/test/unit/test_transpositions.cpp +++ b/test/unit/test_transpositions.cpp @@ -85,8 +85,8 @@ TEST_F(TranspositionsTest, Constructor) tt.clear(); int n = tt.size(); for (int i = 0; i < n; ++i) { - EXPECT_TRUE(tt.get_value_at(i).is_empty()); - EXPECT_EQ(0, tt.get_hash_at(i)); + EXPECT_TRUE(tt.value_at(i).is_empty()); + EXPECT_EQ(0, tt.hash_at(i)); } } @@ -121,9 +121,9 @@ TEST_F(TranspositionsTest, Lookup) tt.save(h, v, b, d, m); // Check transposition - EXPECT_FALSE(tt.get_value_at(i).is_empty()); - EXPECT_EQ(trans_sent, tt.get_value_at(i)); - EXPECT_EQ(h, tt.get_hash_at(i)); + EXPECT_FALSE(tt.value_at(i).is_empty()); + EXPECT_EQ(trans_sent, tt.value_at(i)); + EXPECT_EQ(h, tt.hash_at(i)); } } } -- 2.11.4.GIT