On Mon, Oct 5, 2009 at 10:33 AM, jaypipes <jaypi...@gmail.com> wrote:

> I'm wondering what is the most efficient method to remove an element
> from a Message's vector of repeated elements?  I looked at the
> RepeatedFieldPtr API but would appreciate some example code on how to
> do this in the most efficient way.  I gather from the API that the
> underlying storage is a vector and so does not support efficient index-
> based, random-access deletion from the vector.  Is this correct?

Yes, that is correct.

The most efficient solution is to permute the contents so that the things
you want to remove are at the end, then use RemoveLast().

Note that the underlying storage is an array of *pointers*, so re-arranging
pointers doesn't require copying whole message objects.

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to