[concurrency-interest] COWList snapshot.
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:
> 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,
COWAList.snapshot can return Arrays.asImmutableList(getArray())
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest