translator: add print to Long and Short arrays

This commit is contained in:
Alexey Stepanov
2016-08-18 12:55:25 +03:00
parent d95535b8fb
commit d29f272e4b
3 changed files with 61 additions and 0 deletions
+22
View File
@@ -1,5 +1,7 @@
import ByteArray
import IntArray
import LongArray
import ShortArray
/*
* Library for console interaction
@@ -85,6 +87,16 @@ fun print(message: IntArray) {
message.print()
}
/** Prints the given message and newline to the standard output stream. */
fun print(message: LongArray) {
message.print()
}
/** Prints the given message and newline to the standard output stream. */
fun print(message: ShortArray) {
message.print()
}
/** Prints the given message and newline to the standard output stream. */
fun println(message: Int) {
@@ -146,6 +158,16 @@ fun println(message: IntArray) {
message.println()
}
/** Prints the given message and newline to the standard output stream. */
fun println(message: LongArray) {
message.println()
}
/** Prints the given message and newline to the standard output stream. */
fun println(message: ShortArray) {
message.println()
}
/** Prints newline to the standard output stream. */
fun println() {
kotlinclib_println()
+19
View File
@@ -43,6 +43,25 @@ class LongArray(var size: Int) {
}
}
fun LongArray.print() {
var index = 0
print('[')
while (index < size) {
print(get(index))
index++
if (index < size) {
print(';')
print(' ')
}
}
print(']')
}
fun LongArray.println() {
this.print()
println()
}
fun LongArray.copyOf(newSize: Int): LongArray {
val newInstance = LongArray(newSize)
var index = 0
+20
View File
@@ -44,6 +44,26 @@ class ShortArray(var size: Int) {
}
fun ShortArray.print() {
var index = 0
print('[')
while (index < size) {
print(get(index))
index++
if (index < size) {
print(';')
print(' ')
}
}
print(']')
}
fun ShortArray.println() {
this.print()
println()
}
fun ShortArray.copyOf(newSize: Int): ShortArray {
val newInstance = ShortArray(newSize)
var index = 0