|
deque::erasepublic member function
iterator erase ( iterator position ); iterator erase ( iterator first, iterator last ); Erase elements Removes from the deque container either a single element (position) or a range of elements ([first,last)).This effectively reduces the container size by the number of elements removed, calling each element's destructor before. Double-ended queues are designed to be efficient removing (and inserting) elements at either the end or the beginning of the sequence. Removals on other positions are usually less efficient than in list containers. If the erasing is performed on the beginning or the end of the sequence, only the iterators and references to the erased elements are invalidated. If the deletion happens in the middle of the deque, all iterators and references are invalidated. ParametersAll parameters are of member type iterator, which in deque containers are defined as a random access iterator type.
Return valueA random access iterator pointing to the new location of the element that followed the last element erased by the function call, which is the container end if the operation erased the last element in the sequence.Example
Output:
ComplexityLinear on the number of elements erased (destructors). Plus, depending on the particular library implemention, additional linear time in up to the number of elements between position and one of the ends of the deque.See also
|