Added destructor function (#702)
* Added destructor function * Fixed hash function * Added hash_map_chaining.c file * Amendment submission * Delete hash_map_chaining.c --------- Co-authored-by: Yudong Jin <krahets@163.com>
This commit is contained in:
parent
88a746f493
commit
cf0d4b32ec
@ -20,6 +20,16 @@ class HashMapChaining {
|
||||
HashMapChaining() : size(0), capacity(4), loadThres(2.0 / 3), extendRatio(2) {
|
||||
buckets.resize(capacity);
|
||||
}
|
||||
|
||||
/* 析构方法 */
|
||||
~HashMapChaining() {
|
||||
for (auto &bucket : buckets) {
|
||||
for (Pair *pair : bucket) {
|
||||
// 释放内存
|
||||
delete pair;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 哈希函数 */
|
||||
int hashFunc(int key) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user