On Tue, 26 Jan 1999, Martin v. Loewis wrote:

> > vector is a type of container, it is used to contain my objects, if I 
> > only use vector to store "reference to object", why do I use a 'vector'?
> 
> You could still use it to get indexed access, sorting, and iterating.
> I typically use vectors of pointers if I know my objects must not
> move (sometimes, copying an object will defeat its semantics).

Can you tell me how I store my objects, vector or set or individual 
objects? If I have 10000 objects. Perhaps set is a good way, but it is 
much different from array.

> Coming back to your original question: vectors can be used to
> substitute arrays. If you modify the array (i.e. re-allocate it), all
> pointers into the old array will be gone. Same with vectors.

It is different. When I re-allocate my array, I know the address is 
invalid, I can do something to keep the correct addresses. But in vector,
when I push_back an element to vector, I do not know the addresses I keeped 
is valid or not.

> If you do not modify the vector in a certain number of ways (extending
> it, etc.), the references to entries will remain valid, just as they
> do in arrays.

If I can not extend it, I will use array, what is the goodness of 
vector?



Sincerely Yours,

FengLou Mao
*******************************
ADD:Mr. FengLou Mao
    Peking University
    BeiJing
    P.R.China
Tel:86-10-62751490
Fax:86-10-62751725

Reply via email to