Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import java.lang.Runtime
|
||||
|
||||
fun box() : String {
|
||||
val processors = Runtime.getRuntime().sure().availableProcessors()
|
||||
var threadNum = 1
|
||||
while(threadNum <= 1024) {
|
||||
System.out?.println(threadNum)
|
||||
if(threadNum < 2 * processors)
|
||||
threadNum += 1
|
||||
else
|
||||
threadNum *= 2
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import java.util.concurrent.*
|
||||
import java.util.concurrent.atomic.*
|
||||
|
||||
fun thread(block: fun():Unit ) {
|
||||
val thread = object: Thread() {
|
||||
override fun run() {
|
||||
block()
|
||||
}
|
||||
}
|
||||
thread.start()
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
val ref = AtomicInteger()
|
||||
val cdl = CountDownLatch(11)
|
||||
for(i in 0..10) {
|
||||
thread {
|
||||
var current = 0
|
||||
do {
|
||||
current = ref.synchronized {
|
||||
val v = ref.get() + 1
|
||||
if(v < 100)
|
||||
ref.set(v+1)
|
||||
v
|
||||
}
|
||||
}
|
||||
while(current < 100)
|
||||
cdl.countDown()
|
||||
}
|
||||
}
|
||||
cdl.await()
|
||||
return if(ref.get() == 100) "OK" else ref.get().toString()
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace one_extends_base
|
||||
|
||||
open class Base<T>(name : T?) {
|
||||
var myName : T?
|
||||
{
|
||||
$myName = name
|
||||
}
|
||||
}
|
||||
open class One<T, K>(name : T?, second : K?) : Base<T?>(name) {
|
||||
var mySecond : K?
|
||||
{
|
||||
$mySecond = second
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = if(One<String, Int>("ola", 0).myName == "ola") "OK" else "fail"
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace demo2
|
||||
|
||||
fun print(o : Any?) {}
|
||||
|
||||
fun test(i : Int) {
|
||||
var monthString : String? = "<empty>"
|
||||
when (i) {
|
||||
1 => {
|
||||
print(1)
|
||||
print(2)
|
||||
print(3)
|
||||
print(4)
|
||||
print(5)
|
||||
}
|
||||
else => {
|
||||
monthString = "Invalid month"
|
||||
}
|
||||
}
|
||||
print(monthString)
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
for (i in 1..12) test(i)
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
val <T> Array<T>.length : Int get() = this.size
|
||||
|
||||
fun box() = if(Array(10, {1}).length == 10) "OK" else "fail"
|
||||
@@ -0,0 +1,14 @@
|
||||
// KT-860 ConcurrentModificationException in frontend
|
||||
// +JDK
|
||||
|
||||
namespace std.util
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun <T, U: Collection<in T>> Iterator<T>.to(container: U) : U {
|
||||
while(hasNext)
|
||||
container.add(next())
|
||||
return container
|
||||
}
|
||||
|
||||
inline fun <T> Iterator<T>.toArrayList() = to(ArrayList<T>())
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace test
|
||||
|
||||
class Clock<A : java.lang.Number>
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace test
|
||||
|
||||
class Clock<A> where A : java.lang.Number, A : java.lang.CharSequence
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace test
|
||||
|
||||
class Clock<A : java.lang.CharSequence>
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace test
|
||||
|
||||
class Clock<A> where A : java.lang.CharSequence, A : java.lang.Number
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace test
|
||||
|
||||
trait Trtrtr
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace test
|
||||
|
||||
fun Int.shuffle() = 1
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace test
|
||||
|
||||
fun <A : java.lang.Number> uno() = 1
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace test
|
||||
|
||||
fun <A> tres() where A : java.lang.Number, A : java.lang.CharSequence = 1
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace test
|
||||
|
||||
fun <A : java.lang.CharSequence> dos() = 1
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace test
|
||||
|
||||
fun <A> cuatro() where A : java.lang.CharSequence, A : java.lang.Number = 1
|
||||
Reference in New Issue
Block a user