<@U0BFDUP0E>, in Exploring Java Hidden Costs, what...
# android
m
@jw, in Exploring Java Hidden Costs, what did you mean saying about SparseArray's internals
There are spaces inside of them that are unoccupied. We have to account for that with a little fudge factor, which is similar to the load factor.
? As I can see, while inserting new entries, binary search returns insertion index if the key has not been found, and SparseArray grows its arrays and inserts this value. So, there are some gaps only in transient, garbage state. We can also use
keyAt
,
valueAt
,
setValueAt
, and so on, so the arrays must be contiguous. So, what is 'fudge factor’? Without it SparseArrays are smaller in memory 🙂