[DISCUSSION] Views of immutable objects.
i30817 at gmail.com
Sun Jul 29 19:14:59 UTC 2007
What about adding a method to String complementing the call toCharArray(),
only it takes 3 arguments:
An char array, a position and a length, that inside uses System.arrayCopy.
This would create the possibility to eliminate news when we just want to
copy Strings, and still preserve immutability.
I'm asking this in string and not using the ChartAt interface for a simple
The only way to copy a string into a char array is (currently) to transform
it into a char and copy it into the original o(2n) or to iterate over all
the chars with o(n* (1 + constantboundCheck)).
CharSequence does not assume that the underlying primitive representation is
a char  so it does not have a method that takes one. Maybe it should,
maybe it shouldn't, but on the other hand i believe that at least string
should have a method like that.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the core-libs-dev