Home

kkirtac a écrit :
> Hello, i want to reach a specified index in a list, as we can achieve
> this by the "[]" operator in a std::vector. I couldnt find a way to do
> it without iterators, stepping one by one..i need to point to a
> specified index and retrieve the value and then remove the value of
> the entry...

Use the std::advance algorithm:

list<T>::iterator it=list.begin();
int n=42;

std::advance(it,n);

//it is 42th element or list.end()

Michael

previous
next

Reentrancy of Python interpreter
Re: An ordered dictionary for the Python library?
Re: What is the solution..?
Re: Starting a thread before wxPython bootup ... interesting.
Re: Accessing elements of static array by name
Fundacja Hobbit
Krwinka
Dzieci Niczyje
Nasze Dzieci
Fundacja Sloneczko