translator: purifier println for Byte and Int Arrays

This commit is contained in:
Alexey Stepanov
2016-08-16 11:43:29 +03:00
parent 46324a4030
commit e9138df26b
3 changed files with 47 additions and 3 deletions
+11 -2
View File
@@ -41,12 +41,21 @@ class ByteArray(var size: Int) {
}
fun ByteArray.print() {
println()
var index = 0
print('[')
while (index < size) {
println(get(index))
print(get(index))
index++
if (index < size){
print(';')
print(' ')
}
}
print(']')
}
fun ByteArray.println() {
this.print()
println()
}
+16 -1
View File
@@ -70,6 +70,16 @@ fun print(message: String) {
kotlinclib_print_string(message)
}
/** Prints the given message and newline to the standard output stream. */
fun print(message: ByteArray) {
message.print()
}
/** Prints the given message and newline to the standard output stream. */
fun print(message: IntArray) {
message.print()
}
/** Prints the given message and newline to the standard output stream. */
fun println(message: Int) {
@@ -118,7 +128,12 @@ fun println(message: String) {
/** Prints the given message and newline to the standard output stream. */
fun println(message: ByteArray) {
message.print()
message.println()
}
/** Prints the given message and newline to the standard output stream. */
fun println(message: IntArray) {
message.println()
}
/** Prints newline to the standard output stream. */
+20
View File
@@ -39,6 +39,26 @@ class IntArray(var size: Int) {
}
fun IntArray.print() {
var index = 0
print('[')
while (index < size) {
print(get(index))
index++
if (index < size) {
print(';')
print(' ')
}
}
print(']')
}
fun IntArray.println() {
this.print()
println()
}
fun IntArray.copyOf(newSize: Int): IntArray {
val newInstance = IntArray(newSize)
var index = 0