File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 1
- import 'package:ribs_core/src/function .dart' ;
1
+ import 'package:ribs_core/ribs_core .dart' ;
2
2
3
3
/// Defines a total ordering for elements of type `A` .
4
4
///
@@ -12,6 +12,9 @@ abstract class Order<A> {
12
12
static Order <A > fromComparable <A extends Comparable <dynamic >>() =>
13
13
Order .from ((A a, A b) => a.compareTo (b));
14
14
15
+ static Order <A > fromOrdered <A extends Ordered <dynamic >>() =>
16
+ Order .from ((A a, A b) => a.compareTo (b));
17
+
15
18
/// Creates a new [Order] that compares 2 elements using [f] .
16
19
factory Order .from (Function2 <A , A , int > f) => _OrderF (f);
17
20
Original file line number Diff line number Diff line change
1
+ abstract class Ordered <A > implements Comparable <A > {
2
+ const Ordered ();
3
+
4
+ @override
5
+ int compareTo (A other);
6
+
7
+ bool operator < (A that) => compareTo (that) < 0 ;
8
+
9
+ bool operator <= (A that) => compareTo (that) <= 0 ;
10
+
11
+ bool operator > (A that) => compareTo (that) > 0 ;
12
+
13
+ bool operator >= (A that) => compareTo (that) >= 0 ;
14
+ }
You can’t perform that action at this time.
0 commit comments