Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
C++ - Most efficient way to remove an element from a Message's repeated array
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
jaypipes  
View profile  
 More options Oct 5 2009, 1:33 pm
From: jaypipes <jaypi...@gmail.com>
Date: Mon, 5 Oct 2009 10:33:07 -0700 (PDT)
Local: Mon, Oct 5 2009 1:33 pm
Subject: C++ - Most efficient way to remove an element from a Message's repeated array
Hi all,

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?

Help is much appreciated,

Jay


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kenton Varda  
View profile  
 More options Oct 5 2009, 3:56 pm
From: Kenton Varda <ken...@google.com>
Date: Mon, 5 Oct 2009 12:56:17 -0700
Local: Mon, Oct 5 2009 3:56 pm
Subject: Re: C++ - Most efficient way to remove an element from a Message's repeated array

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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jaypipes  
View profile  
 More options Oct 5 2009, 4:14 pm
From: jaypipes <jaypi...@gmail.com>
Date: Mon, 5 Oct 2009 13:14:28 -0700 (PDT)
Local: Mon, Oct 5 2009 4:14 pm
Subject: Re: C++ - Most efficient way to remove an element from a Message's repeated array
Gotcha. Thanks for the assistance, Kenton!

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »