From a02407b35d3f61cf472088c42591d0cccde55ebd Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Mon, 31 Mar 2025 20:11:54 -0400 Subject: [PATCH] making notes about the function pointer usage --- lectures/22_hash_tables_I/hash_test.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lectures/22_hash_tables_I/hash_test.cpp b/lectures/22_hash_tables_I/hash_test.cpp index a68bc63..7420206 100644 --- a/lectures/22_hash_tables_I/hash_test.cpp +++ b/lectures/22_hash_tables_I/hash_test.cpp @@ -23,6 +23,7 @@ unsigned int betterHash(const std::string& k, unsigned int N) { } // a good hash function should distribute values evenly across N buckets. +// note that function pointers are used here void testCollisions(unsigned int (*hashFunc)(const std::string&, unsigned int), const std::vector& testStrings, unsigned int N) { std::unordered_map bucketCounts; @@ -53,6 +54,7 @@ std::vector generateTestStrings(int count) { return testStrings; } +// note that function pointers are used here void benchmark(unsigned int (*hashFunc)(const std::string&, unsigned int), const std::vector& testStrings, unsigned int N) { clock_t start = clock();