numbers.push_back(10);

numbers.push_front(20);

numbers.push_back(30);

numbers.push_front(40);

deque<int>::iterator it = find(numbers.begin(), numbers.end(), 20); if(it!=numbers.end())

{ // Do your stuff. Here I am simply deleting the element

it = numbers.erase(it); // Note: Always save returned iterator from erase/insert method, otherwise

// iterator will point to deleted resource, which leads to undefined behaviour.

}

If std::find cannot find the specific value, it will return the "end" of the iterator pair.

else if (std::find(visited.begin(), visited.end(), x) == visited.end())

{ // process the case where 'x' _is_not_ found between // visited.begin() and visited.end

If you want to know if x is in the deque, just reverse the condition.

else if (std::find(visited.begin(), visited.end(), x) != visited.end()

{ // process the case where 'x' _is_ found between // visited.begin() and visited.end()