FastUtil contains optimized collection implementations that avoid autoboxing overhead. To notify programmers of unintended autoboxing, for example when using IntList
, they marked the Integer get(int)
method as deprecated, suggesting to use int getInt(int)
instead. this leads to a deprecation warning when using the array index syntax with such lists:
import it.unimi.dsi.fastutil.ints.IntArrayList
private fun test() {
val list = IntArrayList(listOf(1, 2, 3))
println(list[0]) // deprecation warning on this line
}
I tried redefining get
as an operator function, but this does not seem to work because of "Extension is shadowed by a memeber".
operator fun IntArrayList.get(i: Int): Int {
return this.getInt(i)
}
Is there any other way to use array index syntax without deprecation warning and without suppressing all other deprecations?