You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Thomas Mueller (JIRA)" <ji...@apache.org> on 2006/12/20 12:07:22 UTC
[jira] Updated: (JCR-687) UUID compareTo and hashCode
[ 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