added toMutableList, toMutableCollection, toMutableSet

methods to standard library
This commit is contained in:
Svetlana Isakova
2012-09-04 19:07:41 +04:00
parent fedf080a59
commit ce23fe7941
11 changed files with 110 additions and 11 deletions
@@ -243,7 +243,7 @@ public inline fun <in T, C: MutableCollection<in T>> Array<T>.toCollection(resul
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun <T> Array<T>.reverse() : List<T> {
val list = toList()
val list = toMutableList()
Collections.reverse(list)
return list
}
@@ -260,6 +260,15 @@ public inline fun <in T> Array<T>.toCollection() : Collection<T> = toCollection(
/** Copies all elements into a [[Set]] */
public inline fun <in T> Array<T>.toSet() : Set<T> = toCollection(HashSet<T>())
/** Copies all elements into a [[MutableList]] */
public inline fun <in T> Array<T>.toMutableList() : MutableList<T> = toCollection(ArrayList<T>())
/** Copies all elements into a [[List] */
public inline fun <in T> Array<T>.toMutableCollection() : MutableCollection<T> = toCollection(ArrayList<T>())
/** Copies all elements into a [[Set]] */
public inline fun <in T> Array<T>.toMutableSet() : MutableSet<T> = toCollection(HashSet<T>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun <in T> Array<T>.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List<T> {
@@ -243,7 +243,7 @@ public inline fun <C: MutableCollection<Boolean>> BooleanArray.toCollection(resu
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun BooleanArray.reverse() : List<Boolean> {
val list = toList()
val list = toMutableList()
Collections.reverse(list)
return list
}
@@ -260,6 +260,15 @@ public inline fun BooleanArray.toCollection() : Collection<Boolean> = toCollect
/** Copies all elements into a [[Set]] */
public inline fun BooleanArray.toSet() : Set<Boolean> = toCollection(HashSet<Boolean>())
/** Copies all elements into a [[MutableList]] */
public inline fun BooleanArray.toMutableList() : MutableList<Boolean> = toCollection(ArrayList<Boolean>())
/** Copies all elements into a [[List] */
public inline fun BooleanArray.toMutableCollection() : MutableCollection<Boolean> = toCollection(ArrayList<Boolean>())
/** Copies all elements into a [[Set]] */
public inline fun BooleanArray.toMutableSet() : MutableSet<Boolean> = toCollection(HashSet<Boolean>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun BooleanArray.toSortedList(transform: fun(Boolean) : java.lang.Comparable<*>) : List<Boolean> {
@@ -243,7 +243,7 @@ public inline fun <C: MutableCollection<Byte>> ByteArray.toCollection(result: C)
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun ByteArray.reverse() : List<Byte> {
val list = toList()
val list = toMutableList()
Collections.reverse(list)
return list
}
@@ -260,6 +260,15 @@ public inline fun ByteArray.toCollection() : Collection<Byte> = toCollection(Ar
/** Copies all elements into a [[Set]] */
public inline fun ByteArray.toSet() : Set<Byte> = toCollection(HashSet<Byte>())
/** Copies all elements into a [[MutableList]] */
public inline fun ByteArray.toMutableList() : MutableList<Byte> = toCollection(ArrayList<Byte>())
/** Copies all elements into a [[List] */
public inline fun ByteArray.toMutableCollection() : MutableCollection<Byte> = toCollection(ArrayList<Byte>())
/** Copies all elements into a [[Set]] */
public inline fun ByteArray.toMutableSet() : MutableSet<Byte> = toCollection(HashSet<Byte>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun ByteArray.toSortedList(transform: fun(Byte) : java.lang.Comparable<*>) : List<Byte> {
@@ -243,7 +243,7 @@ public inline fun <C: MutableCollection<Char>> CharArray.toCollection(result: C)
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun CharArray.reverse() : List<Char> {
val list = toList()
val list = toMutableList()
Collections.reverse(list)
return list
}
@@ -260,6 +260,15 @@ public inline fun CharArray.toCollection() : Collection<Char> = toCollection(Ar
/** Copies all elements into a [[Set]] */
public inline fun CharArray.toSet() : Set<Char> = toCollection(HashSet<Char>())
/** Copies all elements into a [[MutableList]] */
public inline fun CharArray.toMutableList() : MutableList<Char> = toCollection(ArrayList<Char>())
/** Copies all elements into a [[List] */
public inline fun CharArray.toMutableCollection() : MutableCollection<Char> = toCollection(ArrayList<Char>())
/** Copies all elements into a [[Set]] */
public inline fun CharArray.toMutableSet() : MutableSet<Char> = toCollection(HashSet<Char>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun CharArray.toSortedList(transform: fun(Char) : java.lang.Comparable<*>) : List<Char> {
@@ -243,7 +243,7 @@ public inline fun <C: MutableCollection<Double>> DoubleArray.toCollection(result
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun DoubleArray.reverse() : List<Double> {
val list = toList()
val list = toMutableList()
Collections.reverse(list)
return list
}
@@ -260,6 +260,15 @@ public inline fun DoubleArray.toCollection() : Collection<Double> = toCollectio
/** Copies all elements into a [[Set]] */
public inline fun DoubleArray.toSet() : Set<Double> = toCollection(HashSet<Double>())
/** Copies all elements into a [[MutableList]] */
public inline fun DoubleArray.toMutableList() : MutableList<Double> = toCollection(ArrayList<Double>())
/** Copies all elements into a [[List] */
public inline fun DoubleArray.toMutableCollection() : MutableCollection<Double> = toCollection(ArrayList<Double>())
/** Copies all elements into a [[Set]] */
public inline fun DoubleArray.toMutableSet() : MutableSet<Double> = toCollection(HashSet<Double>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun DoubleArray.toSortedList(transform: fun(Double) : java.lang.Comparable<*>) : List<Double> {
@@ -243,7 +243,7 @@ public inline fun <C: MutableCollection<Float>> FloatArray.toCollection(result:
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun FloatArray.reverse() : List<Float> {
val list = toList()
val list = toMutableList()
Collections.reverse(list)
return list
}
@@ -260,6 +260,15 @@ public inline fun FloatArray.toCollection() : Collection<Float> = toCollection(
/** Copies all elements into a [[Set]] */
public inline fun FloatArray.toSet() : Set<Float> = toCollection(HashSet<Float>())
/** Copies all elements into a [[MutableList]] */
public inline fun FloatArray.toMutableList() : MutableList<Float> = toCollection(ArrayList<Float>())
/** Copies all elements into a [[List] */
public inline fun FloatArray.toMutableCollection() : MutableCollection<Float> = toCollection(ArrayList<Float>())
/** Copies all elements into a [[Set]] */
public inline fun FloatArray.toMutableSet() : MutableSet<Float> = toCollection(HashSet<Float>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun FloatArray.toSortedList(transform: fun(Float) : java.lang.Comparable<*>) : List<Float> {
@@ -243,7 +243,7 @@ public inline fun <C: MutableCollection<Int>> IntArray.toCollection(result: C) :
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun IntArray.reverse() : List<Int> {
val list = toList()
val list = toMutableList()
Collections.reverse(list)
return list
}
@@ -260,6 +260,15 @@ public inline fun IntArray.toCollection() : Collection<Int> = toCollection(Arra
/** Copies all elements into a [[Set]] */
public inline fun IntArray.toSet() : Set<Int> = toCollection(HashSet<Int>())
/** Copies all elements into a [[MutableList]] */
public inline fun IntArray.toMutableList() : MutableList<Int> = toCollection(ArrayList<Int>())
/** Copies all elements into a [[List] */
public inline fun IntArray.toMutableCollection() : MutableCollection<Int> = toCollection(ArrayList<Int>())
/** Copies all elements into a [[Set]] */
public inline fun IntArray.toMutableSet() : MutableSet<Int> = toCollection(HashSet<Int>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun IntArray.toSortedList(transform: fun(Int) : java.lang.Comparable<*>) : List<Int> {
@@ -242,7 +242,7 @@ public inline fun <in T, C: MutableCollection<in T>> Iterator<T>.toCollection(re
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun <T> Iterator<T>.reverse() : List<T> {
val list = toList()
val list = toMutableList()
Collections.reverse(list)
return list
}
@@ -259,6 +259,15 @@ public inline fun <in T> Iterator<T>.toCollection() : Collection<T> = toCollecti
/** Copies all elements into a [[Set]] */
public inline fun <in T> Iterator<T>.toSet() : Set<T> = toCollection(HashSet<T>())
/** Copies all elements into a [[MutableList]] */
public inline fun <in T> Iterator<T>.toMutableList() : MutableList<T> = toCollection(ArrayList<T>())
/** Copies all elements into a [[List] */
public inline fun <in T> Iterator<T>.toMutableCollection() : MutableCollection<T> = toCollection(ArrayList<T>())
/** Copies all elements into a [[Set]] */
public inline fun <in T> Iterator<T>.toMutableSet() : MutableSet<T> = toCollection(HashSet<T>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun <in T> Iterator<T>.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List<T> {
@@ -243,7 +243,7 @@ public inline fun <C: MutableCollection<Long>> LongArray.toCollection(result: C)
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun LongArray.reverse() : List<Long> {
val list = toList()
val list = toMutableList()
Collections.reverse(list)
return list
}
@@ -260,6 +260,15 @@ public inline fun LongArray.toCollection() : Collection<Long> = toCollection(Ar
/** Copies all elements into a [[Set]] */
public inline fun LongArray.toSet() : Set<Long> = toCollection(HashSet<Long>())
/** Copies all elements into a [[MutableList]] */
public inline fun LongArray.toMutableList() : MutableList<Long> = toCollection(ArrayList<Long>())
/** Copies all elements into a [[List] */
public inline fun LongArray.toMutableCollection() : MutableCollection<Long> = toCollection(ArrayList<Long>())
/** Copies all elements into a [[Set]] */
public inline fun LongArray.toMutableSet() : MutableSet<Long> = toCollection(HashSet<Long>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun LongArray.toSortedList(transform: fun(Long) : java.lang.Comparable<*>) : List<Long> {
@@ -243,7 +243,7 @@ public inline fun <C: MutableCollection<Short>> ShortArray.toCollection(result:
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun ShortArray.reverse() : List<Short> {
val list = toList()
val list = toMutableList()
Collections.reverse(list)
return list
}
@@ -260,6 +260,15 @@ public inline fun ShortArray.toCollection() : Collection<Short> = toCollection(
/** Copies all elements into a [[Set]] */
public inline fun ShortArray.toSet() : Set<Short> = toCollection(HashSet<Short>())
/** Copies all elements into a [[MutableList]] */
public inline fun ShortArray.toMutableList() : MutableList<Short> = toCollection(ArrayList<Short>())
/** Copies all elements into a [[List] */
public inline fun ShortArray.toMutableCollection() : MutableCollection<Short> = toCollection(ArrayList<Short>())
/** Copies all elements into a [[Set]] */
public inline fun ShortArray.toMutableSet() : MutableSet<Short> = toCollection(HashSet<Short>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun ShortArray.toSortedList(transform: fun(Short) : java.lang.Comparable<*>) : List<Short> {
+10 -1
View File
@@ -234,7 +234,7 @@ public inline fun <in T, C: MutableCollection<in T>> Iterable<T>.toCollection(re
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun <T> Iterable<T>.reverse() : List<T> {
val list = toList()
val list = toMutableList()
Collections.reverse(list)
return list
}
@@ -251,6 +251,15 @@ public inline fun <in T> Iterable<T>.toCollection() : Collection<T> = toCollecti
/** Copies all elements into a [[Set]] */
public inline fun <in T> Iterable<T>.toSet() : Set<T> = toCollection(HashSet<T>())
/** Copies all elements into a [[MutableList]] */
public inline fun <in T> Iterable<T>.toMutableList() : MutableList<T> = toCollection(ArrayList<T>())
/** Copies all elements into a [[List] */
public inline fun <in T> Iterable<T>.toMutableCollection() : MutableCollection<T> = toCollection(ArrayList<T>())
/** Copies all elements into a [[Set]] */
public inline fun <in T> Iterable<T>.toMutableSet() : MutableSet<T> = toCollection(HashSet<T>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun <in T> Iterable<T>.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List<T> {