Hi, I am trying to get something that will actually delete some contents in a vector?
For example, i have a vector<double> vector1;
and i have a for loop that does whatever which will access the contents in the vector1 when some criteria is met. therefore not accessing the vector in an ordered manner. After that, the remaining elements in the vector will be used somewhere again, multiple times.
How can i achieve this??
Any help will be appreciated, but please be specific. I am not that pro on C++, thanks.
Kent

Sorry, i think there needs to have more detail presented to you guys.
I have a vector struct contains x and y. vectro<struct> vector1. i have already sorted them in a ascending order in terms of x then in terms of y. (coordinates)i.e.
for(int i = 0;i <2;i++)
{
vector1.x; // using function that has x as input.
//i want to something here that takes away the value i have already used from the vector<struct>.
}
For example:
the vector struct contains the following data(x, y):
1,2;
1, 3;
1, 5;
2, 5;
2,11;
2,45;

my function inside the for loop will pick two values, one from the x=1, and one from x=2. But i need to use the remaining struct elements for later use.
I know i can achieve this by just copying the remaining elements into a new vector, but i need to do this multiple times. Is there another method that can do the trick???
Thank you.

A vector has a lot of functions associated with it that you can use, including removing elements (erase):
http://www.cplusplus.com/reference/stl/vector/

You should read up on vector iterators, they are really handy to use. Google is your friend here.

Of course if you don't understand something about it you can always ask ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.