小编Sar*_*lus的帖子

重新表格

我试图通过删除旧表并创建一个具有相同内容的新的更大的表来重新表格.我创建了一个reHash函数,但是这个函数会导致内存泄漏,导致程序在执行函数时崩溃.我找不到我的错误.

void HashMap::reHash()
{
int OldCapacity = cap;
cap = cap * 2 + 1; //set new capacity
Node** newHashTable = new Node*[cap]; //create a temporary table to hold info
for (int i = 0; i < cap; i++)
{
    newHashTable[i] = nullptr;
}

const Node* n;
//fill in the new temp table with old info
for (int i = 0; i < OldCapacity; ++i)
{
    n = HashTable[i];
    while (n != nullptr)
    {
        //initialize new node
        Node* nod = …
Run Code Online (Sandbox Code Playgroud)

c++ hash hashtable

2
推荐指数
1
解决办法
9478
查看次数

C++中以下函数的返回类型是什么?

Typename是什么意思?该函数应该返回什么?

typename BSTMap<KEY,T>::TN* BSTMap<KEY,T>::find_key (TN* root, const KEY& key) const {..}
Run Code Online (Sandbox Code Playgroud)

c++

0
推荐指数
1
解决办法
69
查看次数

标签 统计

c++ ×2

hash ×1

hashtable ×1