Last valid element in a vector



vector::begin() will return the first element and returns value of type
iterator. Is vector.begin() + vector.size()-1 the only way to get the last
valid element in the vector ? I know rbegin() would return this but i need a
method that returns a value of type iterator (just to keep the code shorter)


.



Relevant Pages

  • Re: STL vector help needed.
    ... places.beginthat returns an iterator to the first element of places. ... Because a string is a kind of container, ... think that you are quite some way from writing real code. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Strings/pointers/arrays.
    ... > max size of the array. ... is the iterator I have a bi-directional iterator? ... reliably do so backwards as there is no 'before the first element' to act as ... Enjoy the exercises, and good luck working through the book:)! ...
    (alt.comp.lang.learn.c-cpp)
  • Checking if iterator points to a specific element
    ... I'm traversing a std::list backwards with a reverse_iterator, ... to check for the case when the iterator points to the first element of ... iterator points to the first list element? ...
    (comp.lang.cpp)
  • Re: std::unique error
    ... it can be solved by passing a suitable predicate to std::unique. ... Copies only the first element from every consecutive group of equal elements referred to by the iterator i in the range [first, ...
    (microsoft.public.vc.stl)
  • Re: vector erase function
    ... > | I looked at some documentation for removing an element for a vector ... > the first element in the range, ... > yields an iterator one past the end of the range. ... the second element to be removed ...
    (alt.comp.lang.learn.c-cpp)

Loading