RFR(s): 8060192: Add default method Collection.toArray(generator) (original) (raw)
John Rose john.r.rose at oracle.com
Tue Dec 12 02:07:06 UTC 2017
- Previous message: RFR(s): 8060192: Add default method Collection.toArray(generator)
- Next message: RFR(s): 8060192: Add default method Collection.toArray(generator)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Dec 11, 2017, at 6:00 PM, John Rose <john.r.rose at oracle.com> wrote:
class Arrays { // people who want x.toArray can also use x.copy(Arrays::make): static T[] make(SequenceContent<T,T[]> content) { … }
Correction; that one needs an array type to know what to make:
static T[] make(SequenceContent<T,T[]> content, Class<? extends T[]> arrayClass) { … }
// ArrayList.copy uses this one internally as "myContent": static SequenceContent slice(T[] a, int start, int end) { … } } class List { // people who want x.asUnmodifiableList can also use x.copy(List::make): default SequenceCopier<T,List> make(SequenceContent<T,T[]> content) { … }
// external access to a sized snapshot of a list: default SequenceContent 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.
- Previous message: RFR(s): 8060192: Add default method Collection.toArray(generator)
- Next message: RFR(s): 8060192: Add default method Collection.toArray(generator)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]