A question. In 'Exploring Java Hidden Costs' ->...
# android
m
A question. In 'Exploring Java Hidden Costs' -> 'Collections' was mentioned that
sparse array doesn’t have a load factor, but it does implicitly because these arrays are trees. They’re binary trees. They’re not filled. They’re not contiguous. 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.
What is this about? As I can see,
SparseArray
leaves some unoccupied spaces only in
mGarbage
state: it is transient, inconsistent state; javadoc says that
there can be gaps in the indices
but, as I can see, that does not mean that there are any gaps in the arrays. Their ends can be empty, but without garbage their beginnings are full, and, before growing, array is 100% full. And, of course, binary search does not require any gaps, it requires only the array to be sorted. If anyone knows, please, help me understand, because I'm making a translation of this article / presentation and trying to be precise.