Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hashtable构造函数可能有问题 #136

Open
sjz-hub opened this issue Jul 24, 2023 · 2 comments
Open

hashtable构造函数可能有问题 #136

sjz-hub opened this issue Jul 24, 2023 · 2 comments

Comments

@sjz-hub
Copy link

sjz-hub commented Jul 24, 2023

template <class Iter, typename std::enable_if<
mystl::is_input_iterator::value, int>::type = 0>
hashtable(Iter first, Iter last,
size_type bucket_count,
const Hash& hash = Hash(),
const KeyEqual& equal = KeyEqual())
:size_(mystl::distance(first, last)), mlf_(1.0f), hash_(hash), equal_(equal)
{
init(mystl::max(bucket_count, static_cast<size_type>(mystl::distance(first, last))));
}
这段代码,这个init()明显就没有复制[first,last)的内容

@Adeshen
Copy link

Adeshen commented Jul 24, 2023 via email

@Alinshans
Copy link
Owner

是的,这里应该要做一次copy insert的,而且还得加上是否multi的判断

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants