[K/N] Inline Array constructor
As a part of efforts to stabilize Native stdlib. Merge-request: KT-MR-9643 Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
9374202ebc
commit
f14f88b7ff
@@ -26,8 +26,8 @@ public final class Array<T> {
|
|||||||
* The function [init] is called for each array element sequentially starting from the first one.
|
* The function [init] is called for each array element sequentially starting from the first one.
|
||||||
* It should return the value for an array element given its index.
|
* It should return the value for an array element given its index.
|
||||||
*/
|
*/
|
||||||
@Suppress("TYPE_PARAMETER_AS_REIFIED")
|
@Suppress("TYPE_PARAMETER_AS_REIFIED", "WRONG_MODIFIER_TARGET")
|
||||||
public constructor(size: Int, init: (Int) -> T): this(size) {
|
public inline constructor(size: Int, init: (Int) -> T): this(size) {
|
||||||
var index = 0
|
var index = 0
|
||||||
while (index < size) {
|
while (index < size) {
|
||||||
this[index] = init(index)
|
this[index] = init(index)
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ public final class ByteArray {
|
|||||||
* The function [init] is called for each array element sequentially starting from the first one.
|
* The function [init] is called for each array element sequentially starting from the first one.
|
||||||
* It should return the value for an array element given its index.
|
* It should return the value for an array element given its index.
|
||||||
*/
|
*/
|
||||||
public constructor(size: Int, init: (Int) -> Byte): this(size) {
|
@Suppress("WRONG_MODIFIER_TARGET")
|
||||||
|
public inline constructor(size: Int, init: (Int) -> Byte): this(size) {
|
||||||
for (i in 0..size - 1) {
|
for (i in 0..size - 1) {
|
||||||
this[i] = init(i)
|
this[i] = init(i)
|
||||||
}
|
}
|
||||||
@@ -94,7 +95,8 @@ public final class CharArray {
|
|||||||
* The function [init] is called for each array element sequentially starting from the first one.
|
* The function [init] is called for each array element sequentially starting from the first one.
|
||||||
* It should return the value for an array element given its index.
|
* It should return the value for an array element given its index.
|
||||||
*/
|
*/
|
||||||
public constructor(size: Int, init: (Int) -> Char): this(size) {
|
@Suppress("WRONG_MODIFIER_TARGET")
|
||||||
|
public inline constructor(size: Int, init: (Int) -> Char): this(size) {
|
||||||
for (i in 0..size - 1) {
|
for (i in 0..size - 1) {
|
||||||
this[i] = init(i)
|
this[i] = init(i)
|
||||||
}
|
}
|
||||||
@@ -158,7 +160,8 @@ public final class ShortArray {
|
|||||||
* The function [init] is called for each array element sequentially starting from the first one.
|
* The function [init] is called for each array element sequentially starting from the first one.
|
||||||
* It should return the value for an array element given its index.
|
* It should return the value for an array element given its index.
|
||||||
*/
|
*/
|
||||||
public constructor(size: Int, init: (Int) -> Short): this(size) {
|
@Suppress("WRONG_MODIFIER_TARGET")
|
||||||
|
public inline constructor(size: Int, init: (Int) -> Short): this(size) {
|
||||||
for (i in 0..size - 1) {
|
for (i in 0..size - 1) {
|
||||||
this[i] = init(i)
|
this[i] = init(i)
|
||||||
}
|
}
|
||||||
@@ -222,7 +225,8 @@ public final class IntArray {
|
|||||||
* The function [init] is called for each array element sequentially starting from the first one.
|
* The function [init] is called for each array element sequentially starting from the first one.
|
||||||
* It should return the value for an array element given its index.
|
* It should return the value for an array element given its index.
|
||||||
*/
|
*/
|
||||||
public constructor(size: Int, init: (Int) -> Int): this(size) {
|
@Suppress("WRONG_MODIFIER_TARGET")
|
||||||
|
public inline constructor(size: Int, init: (Int) -> Int): this(size) {
|
||||||
for (i in 0..size - 1) {
|
for (i in 0..size - 1) {
|
||||||
this[i] = init(i)
|
this[i] = init(i)
|
||||||
}
|
}
|
||||||
@@ -286,7 +290,8 @@ public final class LongArray {
|
|||||||
* The function [init] is called for each array element sequentially starting from the first one.
|
* The function [init] is called for each array element sequentially starting from the first one.
|
||||||
* It should return the value for an array element given its index.
|
* It should return the value for an array element given its index.
|
||||||
*/
|
*/
|
||||||
public constructor(size: Int, init: (Int) -> Long): this(size) {
|
@Suppress("WRONG_MODIFIER_TARGET")
|
||||||
|
public inline constructor(size: Int, init: (Int) -> Long): this(size) {
|
||||||
for (i in 0..size - 1) {
|
for (i in 0..size - 1) {
|
||||||
this[i] = init(i)
|
this[i] = init(i)
|
||||||
}
|
}
|
||||||
@@ -350,7 +355,8 @@ public final class FloatArray {
|
|||||||
* The function [init] is called for each array element sequentially starting from the first one.
|
* The function [init] is called for each array element sequentially starting from the first one.
|
||||||
* It should return the value for an array element given its index.
|
* It should return the value for an array element given its index.
|
||||||
*/
|
*/
|
||||||
public constructor(size: Int, init: (Int) -> Float): this(size) {
|
@Suppress("WRONG_MODIFIER_TARGET")
|
||||||
|
public inline constructor(size: Int, init: (Int) -> Float): this(size) {
|
||||||
for (i in 0..size - 1) {
|
for (i in 0..size - 1) {
|
||||||
this[i] = init(i)
|
this[i] = init(i)
|
||||||
}
|
}
|
||||||
@@ -410,7 +416,8 @@ public final class DoubleArray {
|
|||||||
* The function [init] is called for each array element sequentially starting from the first one.
|
* The function [init] is called for each array element sequentially starting from the first one.
|
||||||
* It should return the value for an array element given its index.
|
* It should return the value for an array element given its index.
|
||||||
*/
|
*/
|
||||||
public constructor(size: Int, init: (Int) -> Double): this(size) {
|
@Suppress("WRONG_MODIFIER_TARGET")
|
||||||
|
public inline constructor(size: Int, init: (Int) -> Double): this(size) {
|
||||||
for (i in 0..size - 1) {
|
for (i in 0..size - 1) {
|
||||||
this[i] = init(i)
|
this[i] = init(i)
|
||||||
}
|
}
|
||||||
@@ -470,7 +477,8 @@ public final class BooleanArray {
|
|||||||
* The function [init] is called for each array element sequentially starting from the first one.
|
* The function [init] is called for each array element sequentially starting from the first one.
|
||||||
* It should return the value for an array element given its index.
|
* It should return the value for an array element given its index.
|
||||||
*/
|
*/
|
||||||
public constructor(size: Int, init: (Int) -> Boolean): this(size) {
|
@Suppress("WRONG_MODIFIER_TARGET")
|
||||||
|
public inline constructor(size: Int, init: (Int) -> Boolean): this(size) {
|
||||||
for (i in 0..size - 1) {
|
for (i in 0..size - 1) {
|
||||||
this[i] = init(i)
|
this[i] = init(i)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user