Also note that we cannot return a modifiable list even from the Builder's
getter because the caller could then hold on to that list and modify it
after the message is built.  We really need to prevent any kind of
modifications from happening after the message is built.

On Wed, Mar 17, 2010 at 1:31 PM, Kenton Varda <> wrote:

> On Wed, Mar 17, 2010 at 12:59 PM, Ron Reynolds <>wrote:
>> seems odd that you can delete all via clearXXX() or add via addAllXXX()
>> and addXXX() but not remove a single element by index...
> Our experience is that if we provide a way to remove a single element by
> index, people will mistakenly think that the method is more efficient than
> clearing the whole list and rebuilding it, when in fact both operations are
> O(n).  The result of this is that people write loops like:
>   for (all elements) {
>     if (shouldFilter(element)) {
>       remove(element);
>     }
>   }
> This loop is O(n^2).
>> well, here's a work-around - if you put a utility class into the same
>> package as the ProtobufMessages generated class it can access the protected
>> Builder.internalGetResult() - since package-level access is higher than
>> protected-level access...
> Yikes, is that true?  I don't think it is, but if so we need to fix it.
>  I'm pretty sure "protected" is neither higher nor lower than package-level
> -- it means something entirely different.

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

Reply via email to