fixed mapping sort and max functions from java.util.Collections
This commit is contained in:
@@ -198,6 +198,7 @@ var kotlin = {set:function (receiver, key, value) {
|
||||
}
|
||||
});
|
||||
|
||||
//TODO: should be JS Array-like (https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Predefined_Core_Objects#Working_with_Array-like_objects)
|
||||
Kotlin.ArrayList = Kotlin.$createClass(Kotlin.AbstractList, {
|
||||
initialize: function () {
|
||||
this.array = [];
|
||||
@@ -364,7 +365,7 @@ var kotlin = {set:function (receiver, key, value) {
|
||||
},
|
||||
next: function () {
|
||||
var value = this.$i;
|
||||
this.set_i(this.$i + this.$increment)
|
||||
this.set_i(this.$i + this.$increment);
|
||||
return value;
|
||||
},
|
||||
get_hasNext: function () {
|
||||
@@ -446,6 +447,31 @@ var kotlin = {set:function (receiver, key, value) {
|
||||
return max;
|
||||
};
|
||||
|
||||
Kotlin.collectionsSort = function (mutableList, comparator) {
|
||||
var boundComparator = undefined;
|
||||
if (comparator !== undefined) {
|
||||
boundComparator = comparator.compare.bind(comparator);
|
||||
}
|
||||
|
||||
if (mutableList instanceof Array) {
|
||||
mutableList.sort(boundComparator);
|
||||
}
|
||||
|
||||
//TODO: should be deleted when List will be JS Array-like (https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Predefined_Core_Objects#Working_with_Array-like_objects)
|
||||
var array = [];
|
||||
var it = mutableList.iterator();
|
||||
while (it.hasNext()) {
|
||||
array.push(it.next());
|
||||
}
|
||||
|
||||
array.sort(boundComparator);
|
||||
|
||||
for (var i = 0, n = array.length; i < n; i++) {
|
||||
mutableList.set(i, array[i]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Kotlin.StringBuilder = Kotlin.$createClass(
|
||||
{
|
||||
initialize:function () {
|
||||
|
||||
Reference in New Issue
Block a user