Removing out of bound exception from the method containsIndex(int) in
sparse arrays.