@Override
        public V set(int index, V newValue) {
            Preconditions.checkElementIndex(index, size);
            int arrayIndex = index * gap + offset;
            V old = grid.values[arrayIndex];
            grid.values[arrayIndex] = newValue;
            if (old == null && newValue != null) {
                grid.size++;
            } else if (old != null && newValue == null) {
                grid.size--;
            }
            return old;
        }