SparseFloatArray

SparseFloatArray map integers to floats similar to android.util.SparseIntArray

Constructors

Link copied to clipboard
constructor()
Creates a new SparseFloatArray containing no mappings.
constructor(initialCapacity: Int)
Creates a new SparseFloatArray containing no mappings that will not require any additional memory allocation to store the specified number of mappings.

Functions

Link copied to clipboard
open fun append(key: Int, value: Float)
Puts a key/value pair into the array, optimizing for the case where the key is greater than all existing keys in the array.
Link copied to clipboard
open fun clear()
Removes all key-value mappings from this SparseFloatArray.
Link copied to clipboard
Link copied to clipboard
open fun copyKeys(): Array<Int>
Provides a copy of keys.
Link copied to clipboard
open fun delete(key: Int)
Removes the mapping from the specified key, if there was any.
Link copied to clipboard
open fun get(key: Int): Float
Gets the float mapped from the specified key, or 0f if no such mapping has been made.
open fun get(key: Int, valueIfKeyNotFound: Float): Float
Gets the float mapped from the specified key, or the specified value if no such mapping has been made.
Link copied to clipboard
open fun indexOfKey(key: Int): Int
Returns the index for which keyAt would return the specified key, or a negative number if the specified key is not mapped.
Link copied to clipboard
open fun indexOfValue(value: Float): Int
Returns an index for which valueAt would return the specified key, or a negative number if no keys map to the specified value.
Link copied to clipboard
open fun keyAt(index: Int): Int
Given an index in the range 0...size()-1, returns the key from the index th key-value mapping that this SparseFloatArray stores.
Link copied to clipboard
open fun put(key: Int, value: Float)
Adds a mapping from the specified key to the specified value, replacing the previous mapping from the specified key if there was one.
Link copied to clipboard
open fun removeAt(index: Int)
Removes the mapping at the given index.
Link copied to clipboard
open fun setValueAt(index: Int, value: Float)
Directly set the value at a particular index.
Link copied to clipboard
open fun size(): Int
Returns the number of key-value mappings that this SparseFloatArray currently stores.
Link copied to clipboard
open fun toString(): String
This implementation composes a string by iterating over its mappings.
Link copied to clipboard
open fun valueAt(index: Int): Float
Given an index in the range 0...size()-1, returns the value from the index th key-value mapping that this SparseFloatArray stores.