git://source.jalview.org
/
jalview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
dce490b
)
JAL-3878 Add universal id generator to MathUtils.
author
Mateusz Warowny
<mmzwarowny@dundee.ac.uk>
Tue, 15 Feb 2022 17:37:53 +0000
(18:37 +0100)
committer
Mateusz Warowny
<mmzwarowny@dundee.ac.uk>
Tue, 15 Feb 2022 17:37:53 +0000
(18:37 +0100)
src/jalview/util/MathUtils.java
patch
|
blob
|
history
diff --git
a/src/jalview/util/MathUtils.java
b/src/jalview/util/MathUtils.java
index
ecbb6e1
..
ae0885e
100644
(file)
--- a/
src/jalview/util/MathUtils.java
+++ b/
src/jalview/util/MathUtils.java
@@
-39,4
+39,17
@@
public class MathUtils
return gcd(b, a % b);
}
+
+ private static int uidCounter = (int)(Math.random() * 0xffffffff);
+ /**
+ * Generates a unique 64-bit identifier.
+ */
+ public static long getUID()
+ {
+ long uid = 0L;
+ uid |= ((System.currentTimeMillis() >> 10) & 0xfffffffL) << 36;
+ uid |= (long)(Math.random() * 0xfL) << 32;
+ uid |= ++uidCounter & 0xffffffff;
+ return uid;
+ }
}