C++ 中的单链表标准库或其他广泛使用的库?
好像C++标准库里只有双向链表(没有单链表)吧?是否有广泛使用的带有单链表的 C++ 库?
Seems that there is only doubly linked list (but no singly linked list) in the C++ standard library, right? Is there any widely-used C++ libraries with singly linked list?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有
slist
来自 Boost 的类,它是一个单链表实现。There is the
slist
class from Boost that is a singly linked list implementation.仅供参考...
时间已经过去,C++11 为我们带来了 std:: forward_list 容器实现为单链表,与 C 中的实现相比,本质上没有任何开销。
与
std::list
相比,此容器在以下情况下提供更节省空间的存储:不需要双向迭代。警告:缺少
push_back
方法(std::forward_list 和 std: :forward_list::push_back)Just for reference...
Time has passed and C++11 has brought us the std::forward_list container that is implemented as a singly-linked list and essentially does not have any overhead compared to its implementation in C.
Compared to
std::list
this container provides more space efficient storage when bidirectional iteration is not needed.Warning: missing
push_back
method (std::forward_list and std::forward_list::push_back)有 slist,它是一个 SGI 扩展(
__gnu_cxx::清单
)There is slist, which is an SGI extension (
__gnu_cxx::slist
)