h2/src/main/org/h2/mvstore/Page.java
/**
     * Remove the key and value (or child) at the given index.
     *
     * @param index the index
     */
Remove the key and value (or child) at the given index.
@param index the index
Remove the key and value ( or child ) at the given index . @param index the index
public void remove(int index) {
        int keyIndex = index >= keyCount ? index - 1 : index;
        Object old = keys[keyIndex];
        memory -= map.getKeyType().getMemory(old);
        if ((sharedFlags & SHARED_KEYS) == 0 && keys.length > keyCount - 4) {
            if (keyIndex < keyCount - 1) {
                System.arraycopy(keys, keyIndex + 1, keys, keyIndex, keyCount - keyIndex - 1);
            }
            keys[keyCount - 1] = null;
        } else {
            Object[] newKeys = new Object[keyCount - 1];
            DataUtils.copyExcept(keys, newKeys, keyCount, keyIndex);
            keys = newKeys;
            sharedFlags &= ~SHARED_KEYS;
        }
        if (values != null) {
            old = values[index];
            memory -= map.getValueType().getMemory(old);
            if ((sharedFlags & SHARED_VALUES) == 0 && values.length > keyCount - 4) {
                if (index < keyCount - 1) {
                    System.arraycopy(values, index + 1, values, index, keyCount - index - 1);
                }
                values[keyCount - 1] = null;
            } else {
                Object[] newValues = new Object[keyCount - 1];
                DataUtils.copyExcept(values, newValues, keyCount, index);
                values = newValues;
                sharedFlags &= ~SHARED_VALUES;
            }
            totalCount--;
        }
        keyCount--;
        if (children != null) {
            memory -= DataUtils.PAGE_MEMORY_CHILD;
            long countOffset = counts[index];
            long[] newChildren = new long[childCount - 1];
            DataUtils.copyExcept(children, newChildren, childCount, index);
            children = newChildren;
            Page[] newChildrenPages = new Page[childCount - 1];
            DataUtils.copyExcept(childrenPages, newChildrenPages,
                    childCount, index);
            childrenPages = newChildrenPages;
            long[] newCounts = new long[childCount - 1];
            DataUtils.copyExcept(counts, newCounts, childCount, index);
            counts = newCounts;
            sharedFlags &= ~(SHARED_CHILDREN | SHARED_COUNTS);
            totalCount -= countOffset;
            childCount--;
        }
    }
public void remove ( int index ) { int keyIndex = index >= keyCount ? index - 1 : index ; Object old = keys [ keyIndex ] ; memory -= map . getKeyType ( ) . getMemory ( old ) ; if ( ( sharedFlags & SHARED_KEYS ) == 0 && keys . length > keyCount - 4 ) { if ( keyIndex < keyCount - 1 ) { System . arraycopy ( keys , keyIndex + 1 , keys , keyIndex , keyCount - keyIndex - 1 ) ; } keys [ keyCount - 1 ] = null ; } else { Object [ ] newKeys = new Object [ keyCount - 1 ] ; DataUtils . copyExcept ( keys , newKeys , keyCount , keyIndex ) ; keys = newKeys ; sharedFlags &= ~ SHARED_KEYS ; } if ( values != null ) { old = values [ index ] ; memory -= map . getValueType ( ) . getMemory ( old ) ; if ( ( sharedFlags & SHARED_VALUES ) == 0 && values . length > keyCount - 4 ) { if ( index < keyCount - 1 ) { System . arraycopy ( values , index + 1 , values , index , keyCount - index - 1 ) ; } values [ keyCount - 1 ] = null ; } else { Object [ ] newValues = new Object [ keyCount - 1 ] ; DataUtils . copyExcept ( values , newValues , keyCount , index ) ; values = newValues ; sharedFlags &= ~ SHARED_VALUES ; } totalCount -- ; } keyCount -- ; if ( children != null ) { memory -= DataUtils . PAGE_MEMORY_CHILD ; long countOffset = counts [ index ] ; long [ ] newChildren = new long [ childCount - 1 ] ; DataUtils . copyExcept ( children , newChildren , childCount , index ) ; children = newChildren ; Page [ ] newChildrenPages = new Page [ childCount - 1 ] ; DataUtils . copyExcept ( childrenPages , newChildrenPages , childCount , index ) ; childrenPages = newChildrenPages ; long [ ] newCounts = new long [ childCount - 1 ] ; DataUtils . copyExcept ( counts , newCounts , childCount , index ) ; counts = newCounts ; sharedFlags &= ~ ( SHARED_CHILDREN | SHARED_COUNTS ) ; totalCount -= countOffset ; childCount -- ; } }
Remove the key and value (or child) at the given index.
Remove the key and value ( or child ) at the given index .