C++ 中 hash_set::size() 的复杂度是多少? STL?

发布于 2024-08-01 20:57:09 字数 53 浏览 2 评论 0原文

即计算复杂度。 是否必须计算所有元素? 这取决于实施吗? 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤独患者 2024-08-08 20:57:09

当前的 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.

夏了南城 2024-08-08 20:57:09

据我所知,未指定,但可能是恒定时间。 Microsoft 的实现是恒定时间。

Unspecified, as far as I know, but probably constant time. The Microsoft implementation is constant time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文