We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6b35d99 commit 3dceccbCopy full SHA for 3dceccb
1 file changed
core/src/main/java/fj/Ord.java
@@ -637,4 +637,25 @@ public Ordering f(final A a2) {
637
}
638
});
639
640
+
641
+ /**
642
+ * An order instance that uses {@link Object#hashCode()} for computing the order.
643
+ *
644
+ * @return An order instance that is based on {@link Object#hashCode()}.
645
+ */
646
+ public static <A> Ord<A> hashOrd() {
647
+ return Ord.<A> ord(new F<A, F<A, Ordering>>() {
648
+ @Override
649
+ public F<A, Ordering> f(final A a) {
650
+ return new F<A, Ordering>() {
651
652
+ public Ordering f(final A a2) {
653
+ final int x = a.hashCode() - a2.hashCode();
654
+ return x < 0 ? Ordering.LT : x == 0 ? Ordering.EQ : Ordering.GT;
655
+ }
656
+ };
657
658
+ });
659
660
661
0 commit comments