The new Objects class
Paulo Levi
i30817 at gmail.com
Mon Jan 11 19:32:48 UTC 2010
Possibly two overloadings?
One that takes a array
public static int hash(Object[] values)
The other*
*hash(Object value1, Object value2, Object... restOfValues)
The one object case is just
object.hashcode() right?
On Mon, Jan 11, 2010 at 10:20 AM, Marek Kozieł <develop4lasu at gmail.com>wrote:
> 2010/1/10 Neal Gafter <neal at gafter.com>:
> > On Sun, Jan 10, 2010 at 12:14 AM, Paulo Levi <i30817 at gmail.com> wrote:
> >> Just seen the new Objects class in the java.util.
> >>
> >> I'd like to ask why does the
> >>
> >> public static int hash(Object... values)
> >>
> >> method, has the warning:
> >> Warning: When a single object reference is supplied, the returned value
> does
> >> not equal the hash code of that object reference. This value can be
> computed
> >> by calling hashCode(Object).
> >>
> >> When it could be rewritten as :
> >>
> >> public static int hash(Object value1, Object value2, Object...
> restOfValues)
> >>
> >> to avoid that.
> >
> > That would make it hard to pass an array.
> >
> Hello.
>
> Name "hashForArray" would not be better?
>
> If there is need for efficiency improvements other methods can be
> added to do not force arrays creation for low number of arguments:
>
> public static int hash(Object value)
> public static int hash(Object value, Object value1)
> public static int hash(Object value, Object value1, Object value3)
> public static int hash(Object... values)
> public static int hash() // maybe ?
>
>
> But I'm not sure if we need that, probably time will tell...
>
> --
> Pozdrowionka. / Regards.
> Lasu aka Marek Kozieł
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20100111/f27924d3/attachment.html>
More information about the core-libs-dev
mailing list