Arrays methods

Arne Siegel v.a.ammodytes at googlemail.com
Sat Mar 16 04:28:31 PDT 2013


A slight analogy between Array<T> and Map<int, T> leads to: Arrays.replaceAll(array, fn)


On 13 Mar 2013 at 17:44, Brian Goetz wrote:

> Fill implies "set all elements"; a set name would probably have to say 
> "setAll":
> 
>    Arrays.setAll(array, fn)
>    Arrays.parallelSetAll(array, fn)
> 
> OK?
> 
> On 3/13/2013 5:30 PM, Joe Bowbeer wrote:
> > I agree with the critique of 'fill' names.
> >
> > I like 'set' names.
> >
> >
> >
> >
> > On Wed, Mar 13, 2013 at 1:28 PM, Mike Duigou <mike.duigou at oracle.com
> > <mailto:mike.duigou at oracle.com>> wrote:
> >
> >     Arrays.indexFill(array, fn)
> >     Arrays.indexedFill(array, fn)
> >     Arrays.fillIndexed(array, fn)
> >     Arrays.indexedSet(array, fn)
> >
> >     I think it might be better to stay away from "fill" names because
> >     the current fill methods all have the property that every array
> >     element is assigned the same value. This new operation allows a
> >     different value to be assigned to each element.
> >
> >     Mike
> >
> >     On Mar 13 2013, at 12:25 , Brian Goetz wrote:
> >
> >      >> If we added
> >      >>
> >      >>      <T> void fill(T[], IntFunction<T> gen)
> >      >>
> >      >> then existing calls to
> >      >>
> >      >>   fill(array, null)
> >      >>
> >      >> would become ambiguous.  Doh.  (But the other 17 forms are not
> >      >> problematic.)
> >      >>
> >      >> Any suggestions for alternate names?
> >      >
> >      > Arrays.generate(array, fn)
> >      > Arrays.fillApplying(array, fn)
> >      > Arrays.initialize(array, fn)
> >      > Arrays.setAll(array, fn)
> >      >
> >      > ...
> >
> >




More information about the lambda-libs-spec-observers mailing list