On Dec 11, 2017, at 6:00 PM, John Rose <john.r.r...@oracle.com> wrote: > > class Arrays { > // people who want x.toArray can also use x.copy(Arrays::make): > static <T> T[] make(SequenceContent<T,T[]> content) { … }
Correction; that one needs an array type to know what to make: static <T> T[] make(SequenceContent<T,T[]> content, Class<? extends T[]> arrayClass) { … } > // ArrayList.copy uses this one internally as "myContent": > static <T> SequenceContent<T> slice(T[] a, int start, int end) { … } > } > class List<T> { > // people who want x.asUnmodifiableList can also use x.copy(List::make): > default SequenceCopier<T,List<T>> make(SequenceContent<T,T[]> content) { … } > > // external access to a sized snapshot of a list: > default SequenceContent<T> sizedContent() { … } > } Also, sizedContent is there for completeness but doesn't carry as much weight as the other three. It might be derived from Collection::copy applied to the identity function, unless there are scoping rules on the operand to Collection::copy.