public void set(int index, E value) {
        assert value != null;
        Storage32 newStorage = storage.set(index, value);
        if (newStorage != storage) {
            storage = newStorage;
        }
    }
@Test
    public void testSetSparse16WithCapacityEqualToSize() {
        // add some dense entries
        for (int i = 0; i < ARRAY_STORAGE_32_MAX_SPARSE_SIZE; ++i) {
            set(i);
            verify();
        }

        // go far beyond the last index to trigger dense to sparse conversion
        set(ARRAY_STORAGE_32_MAX_SPARSE_SIZE * 1000);
        verify();

        // keep adding entries to trigger prefix storage creation
        int threshold = computeCapacityAfterInsertion(ARRAY_STORAGE_32_MAX_SPARSE_SIZE * 2);
        for (int i = 0; i < threshold; ++i) {
            set(i);
            verify();
        }

        // trigger dense to sparse conversion in 16-bit storage
        set(ARRAY_STORAGE_32_MAX_SPARSE_SIZE * 4);
        verify();

        // add more to the prefix eventually restoring the density
        for (int i = 0; i < ARRAY_STORAGE_32_MAX_SPARSE_SIZE * 4; ++i) {
            set(i);
            verify();
        }
    }