C++ 中 hash_set::size() 的复杂度是多少? STL?
即计算复杂度。 是否必须计算所有元素? 这取决于实施吗? SGI 规范不保证任何事情。
That is, the computational complexity. Does it have to count all the elements? Does it depend on implementation? The SGI spec doesn't guarantee anything.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当前的 C++ 标准没有指定 hash_set,所以是的,
它取决于实现。 我觉得有点难以想象
可接受的实现,但这是不可能的
然而,恒定时间。
The current C++ standard doesn't specify a hash_set, so yes,
it is implementation dependent. I find it a bit hard to imagine an
acceptable implementation for which this wouldn't be
constant time, however.
据我所知,未指定,但可能是恒定时间。 Microsoft 的实现是恒定时间。
Unspecified, as far as I know, but probably constant time. The Microsoft implementation is constant time.