On Wed, Jun 23, 2010 at 3:30 PM, Jason Hsueh <[email protected]> wrote:
> On Wed, Jun 23, 2010 at 3:01 PM, Dheeraj Pandey <[email protected] > > 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! > I'm not sure this is true. Are you thinking of Jon's RepeatedFieldBuilder thing? That's actually more of an implementation detail, not a new public interface. Although it would make it easier to provide a nicer API as a subsequent change. > (b) providing a more optimized implementation that is not O(n) on a delete. >> > Repeated fields are backed by ArrayLists. To provide better than O(n) delete we would have to use some other data structure, which would likely be much less efficient for more common usage patterns. This is, in fact, the whole point: in the past we provided a remove-by-index operation, and people mistakenly thought that it was somehow more efficient than rebuilding the whole list, even though it wasn't! -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
