양키지 끝에 도달하면 이중 연결된 목록에서 루프를 빠져 나가는 방법에 문제가 있습니다. 양단 큐에 요소가있는 경우, 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;
}
사이드 참고 : 당신이 이미 할당 및 관리 데이터에 대한 스마트 포인터를 사용 하시겠습니까 ___really___ 있습니까? – Zeta
그것은 내가 원했던 것이 아니라 내 교수가 우리에게해야했던 것입니다. ( –
@ Zeta 믿어주십시오, [이 코드는 많은 링거를 통해 진행되었습니다] (http://stackoverflow.com/questions/19719529/doubly -linked-list-and-how-next-node로 이동하는 방법) – WhozCraig