当双向链表到达双端队列末尾时,我遇到了如何退出循环的问题。如果双端队列中有元素,它将返回 iter 位置。如果不是,它将在双端队列末尾返回迭代器。我真的很感谢你的帮助。谢谢
这是我的搜索功能
unique_ptr<DequeIterator<E>> find(E match)
{
assert(!is_empty());
// the iter will begin from the head.
unique_ptr<DequeIterator<E>> iter(iter_begin());
// Here is where I do not know how to get it quit when
// it gets to the end of the deque.
// ALSO it needs to check the value at the end of
// the deque before it quits too.
while(iter->value() != match)
{
iter->next();
}
return iter;
}