STL 堆栈和 priority_queue 的插入器
问题描述
std::vector
、std::list
和 std::deque
有 std::back_inserter
,并且 std::set
有 std::inserter
.
std::vector
, std::list
and std::deque
have std::back_inserter
, and std::set
has std::inserter
.
对于 std::stack
和 std::priority_queue
我会假设等效的插入器是 push()
但我可以似乎找不到要调用的正确函数.
For std::stack
and std::priority_queue
I would assume the equivalent inserter would be a push()
but I can't seem to find the correct function to call.
我的意图是能够将以下函数与正确的插入迭代器一起使用:
My intent is to be able to use the following function with the correct insert iterator:
推荐答案
你总是可以走自己的路,自己实现一个迭代器.我尚未验证此代码,但它应该可以工作.强调我还没有验证".
You can always go your own way and implement an iterator yourself. I haven't verified this code but it should work. Emphasis on "I haven't verified."
我还要添加以下函数来帮助使用它:
I'd also add in the following function to help use it:
这篇关于STL 堆栈和 priority_queue 的插入器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!