jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Mueller (JIRA)" <j...@apache.org>
Subject [jira] Updated: (JCR-687) UUID compareTo and hashCode
Date Wed, 20 Dec 2006 11:07:22 GMT
     [ http://issues.apache.org/jira/browse/JCR-687?page=all ]

Thomas Mueller updated JCR-687:
-------------------------------

    Attachment: uuid.txt

Corrected compareTo and simplified hashCode implementations.

> UUID compareTo and hashCode
> ---------------------------
>
>                 Key: JCR-687
>                 URL: http://issues.apache.org/jira/browse/JCR-687
>             Project: Jackrabbit
>          Issue Type: Bug
>          Components: core
>            Reporter: Thomas Mueller
>            Priority: Minor
>         Attachments: uuid.txt
>
>
> The current UUID.compareTo implementation is not correct. Usually, 'equals' is used so
this is not a big problem, but I need to create an ordered list of UUIDs and for this I need
compareTo. The current implementation is based on subtraction, but this doesn't always work.
Example:
> //long a = 10, b = 20, c = 0;
> long a = Long.MAX_VALUE, b = Long.MIN_VALUE, c = 0;
> System.out.println((a - b) < 0 ? "a < b" : "a >= b");
> System.out.println((c - a) < 0 ? "c < a" : "c >= a");
> System.out.println((b - c) < 0 ? "b < c" : "b >= c");
> The hashCode implementation is OK, but the multiplication is not required.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message