added sample comparator code and tidied up some test cases & converted them to the cleaner JUnit 4 style

This commit is contained in:
James Strachan
2012-03-26 11:43:25 +01:00
parent dcae0277f1
commit 5b252aaf39
6 changed files with 57 additions and 69 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ inline fun <in T: java.lang.Comparable<T>> List<T>.sort() : List<T> {
return this
}
inline fun <in T: java.lang.Comparable<T>> List<T>.sort(comparator: java.util.Comparator<T>) : List<T> {
inline fun <in T> List<T>.sort(comparator: java.util.Comparator<T>) : List<T> {
Collections.sort(this, comparator)
return this
}
+1 -3
View File
@@ -58,9 +58,7 @@ private class FunctionComparator<T>(val functions: Array<Function1<T,Any?>>): C
}
override fun compare(o1: T?, o2: T?): Int {
// TODO compile error
//return compareBy<T>(o1, o2, functions)
throw UnsupportedOperationException("TODO")
return compareBy<T>(o1, o2, *functions)
}
override fun equals(obj: Any?): Boolean {