X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=include%2Fhfta%2Fhash_table.h;fp=include%2Fhfta%2Fhash_table.h;h=cf913e5e3e65b0decc4c07b1eb038d856edba348;hb=f1754ecea2eab7bd0a302042ac82eb11667b166c;hp=e82940cc66f6e7472ff8c250fd5a2cb62fa72374;hpb=8b04ba410b46bc4853dfda7095d2a2229b609003;p=com%2Fgs-lite.git diff --git a/include/hfta/hash_table.h b/include/hfta/hash_table.h index e82940c..cf913e5 100644 --- a/include/hfta/hash_table.h +++ b/include/hfta/hash_table.h @@ -119,7 +119,7 @@ private: public: - hash_table(const size_t n_buckets = 65536, const double load = 0.5) { + hash_table(const size_t n_buckets = 65536, const double load = 1.0) { load_factor = load; int nb; for(nb=2;nb load_factor ) { - delete[] buckets; - // roughly double the size of the table - num_buckets *= 2; + // reize table if its maximum load exceed the load factor + // OR it was less then half of the load factor + size_t min_buckets = 0; + if ((max_load > load_factor) || ((2 * max_load) < load_factor)) { + min_buckets = _max_size / load_factor; + } + + if (min_buckets) { + // find power-of-2 size large than min_buckets; + int nb; + for(nb=2;nb load_factor ) { + // reize table if its maximum load exceed the load factor + // OR it was less then half of the load factor + size_t min_buckets = 0; + if ((max_load > load_factor) || ((2 * max_load) < load_factor)) { + min_buckets = _max_size / load_factor; + } + + if (min_buckets) { + // find power-of-2 size large than min_buckets; + int nb; + for(nb=2;nb