On Wed, Jun 23, 2010 at 3:01 PM, Dheeraj Pandey
<dhee...@alumni.utexas.net>wrote:

> Java doesn't have such a thing. Is this by design? If yes, would love to
> understand the rationale of why
> clearing-everything-and-reinserting-(N-1)-values is so much better than:
> (a) providing an API to do so, and
>

There is actually a pending change to provide a much nicer API for this sort
of modification. It will probably be in the next release, so if you can be
patient things should improve soon!


> (b) providing a more optimized implementation that is not O(n) on a delete.
>

This would really be up to the application though: it is often the case that
repeated fields are order dependent, so deletes may be worst case O(n) in
order to shift the elements. Something like SwapElements in the C++
implementation would allow the client to do something more efficient if they
do not care about order, though I'm not sure if the aforementioned change
will provide this.


> Thanks
> Dheeraj
>
>
> On Wed, Jun 23, 2010 at 7:21 AM, Igor Gatis <igorga...@gmail.com> wrote:
>
>> C++ code has the RemoveLast method. If there is such thing in Java, you
>> could remove 1 item by shifting everything one position earlier and than
>> calling RemoveLast. Batch removal can be also accomplished in the same with
>> two counters.
>>
>>
>> On Wed, Jun 23, 2010 at 7:03 AM, Thomas Broyer <t.bro...@gmail.com>wrote:
>>
>>>
>>> On 23 juin, 07:02, Dheeraj <dhee...@gmail.com> wrote:
>>> > How do I delete an entry from a list in a protobuf (repeated field)? I
>>> > can add, I can modify, but I cannot delete using any of the generated
>>> > APIs. A getList() returns an unmodifiable collection.
>>>
>>> Clear the field and then re-add values. You can also set the field
>>> with a List<?> (setField with the FieldDescriptor for your repeated
>>> field), which has the same effect.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Protocol Buffers" group.
>>> To post to this group, send email to proto...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/protobuf?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Protocol Buffers" group.
>> To post to this group, send email to proto...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/protobuf?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to proto...@googlegroups.com.
> To unsubscribe from this group, send email to
> protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to