Would keeping track of the number of filled entries and how many of those are zero be an option? You'd have to check each inserted value to see if it is zero, but I feel like that might be a trivial cost in the face of the rest of the operation.