OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library sort_helper; | 5 library sort_helper; |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 | 8 |
9 typedef Sorter | 9 typedef Sorter = void Function(List<num>); |
10 = void Function(List<num>); | 10 typedef Comparer = int Function(num, num); |
11 typedef Comparer | |
12 = int Function(num, num); | |
13 | 11 |
14 class SortHelper { | 12 class SortHelper { |
15 SortHelper(this.sortFunction, this.compareFunction) {} | 13 SortHelper(this.sortFunction, this.compareFunction) {} |
16 | 14 |
17 void run() { | 15 void run() { |
18 testSortIntLists(); | 16 testSortIntLists(); |
19 testSortDoubleLists(); | 17 testSortDoubleLists(); |
20 } | 18 } |
21 | 19 |
22 bool isSorted(List<num> a) { | 20 bool isSorted(List<num> a) { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 146 |
149 for (int i = 0; i < a.length; i++) { | 147 for (int i = 0; i < a.length; i++) { |
150 a[i] = 1.5; | 148 a[i] = 1.5; |
151 } | 149 } |
152 testSort(a); | 150 testSort(a); |
153 } | 151 } |
154 | 152 |
155 Sorter sortFunction; | 153 Sorter sortFunction; |
156 Comparer compareFunction; | 154 Comparer compareFunction; |
157 } | 155 } |
OLD | NEW |