[concurrency-interest] COWList snapshot.

Martin Buchholz martinrb at google.com
Fri Feb 21 18:55:59 EST 2014


On Fri, Feb 21, 2014 at 3:17 PM, Jason Mehrens <jason_mehrens at hotmail.com>wrote:

> Martin,
> Looks correct. Since the snapshot can't change I assume it should
> implement RandomAccess? Maybe override iterator() and listIterator() to
> return COWIterator for fun and profit?
>

Immutable List iterator is much simpler.


> As Henri pointed out, you can use
> Collections.unmodifiableList(Arrays.asList(getArray())). Arrays.asList
> doesn't perform any safe coping of the input array.
>
>
Ohhh, light bulb just lit up.... ding ding ding ... Yeah, that does indeed
look very simple...

Back to the drawing board.  We add the much more fundamental
Arrays.asImmutableList(T...) that everyone has been asking for elsewhere,
and then
COWAList.snapshot can return Arrays.asImmutableList(getArray())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20140221/a3a5666d/attachment.html>


More information about the Concurrency-interest mailing list