开发者

can someone explain the last argument of this function for me?

it's a constructor for a hash, but i don't understand the last argument. what is it doing?

std开发者_C百科::fill(hash_table_, hash_table_ + HASH_TABLE_SIZE, (node *)NULL)

can you just do this in a for loop somehow?

for (int i = 0; i < HASH_TABLE_SIZE; i++){
    //whatever that last argument is doing
    hash_table_++;
}

trying to understand how fill works with hash. thanks!


That line fills your hash table with NULLs.

Yes, you can also use a loop, but it is more work and more error-prone.


It sets the whole hash table to the last argument (NULL), a loop for that will be:

for (int i = 0; i < HASH_TABLE_SIZE; i++)
{
    *(hash_table_ + i) = (node *)NULL;
}


i don't understand the last argument. what is it doing?

std::fill(hash_table_, hash_table_ + HASH_TABLE_SIZE, (node *)NULL)

Is it filling a hash table with NULL pointers to node.

can you just do this in a for loop somehow?

for (int i = 0; i < HASH_TABLE_SIZE; i++){
    hash_table_[i] = (node*)NULL;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜