B
Boltar
Hi
Is there a way of inserting and erasing to/from a vector using an
array index instead of an iterator or alternatively a way to map an
index number to an iterator?
eg:
vector<int> v;
v.push_back(123);
v.push_back(789);
v.insert(1,456);
printf("%d\n",v[1]);
v.erase(1)
So the above would print 456 but 789 would now be at index 2. Then it
would delete 789.
Sorry if this is a dummies question.
B2003
Is there a way of inserting and erasing to/from a vector using an
array index instead of an iterator or alternatively a way to map an
index number to an iterator?
eg:
vector<int> v;
v.push_back(123);
v.push_back(789);
v.insert(1,456);
printf("%d\n",v[1]);
v.erase(1)
So the above would print 456 but 789 would now be at index 2. Then it
would delete 789.
Sorry if this is a dummies question.
B2003