mavibot/src/main/java/org/apache/directory/mavibot/btree/InMemoryLeaf.java [758:797]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        valueHolder = newLeaf.values[pos];
        V replacedValue = null;

        if ( !valueExists && btree.isAllowDuplicates() )
        {
            valueHolder.add( value );
            newLeaf.values[pos] = valueHolder;
        }
        else if ( valueExists && btree.isAllowDuplicates() )
        {
            // As strange as it sounds, we need to remove the value to reinject it.
            // There are cases where the value retrieval just use one part of the
            // value only (typically for LDAP Entries, where we use the DN)
            replacedValue = valueHolder.remove( value );
            valueHolder.add( value );
        }
        else if ( !btree.isAllowDuplicates() )
        {
            replacedValue = valueHolder.replaceValueArray( value );
        }

        // Create the result
        InsertResult<K, V> result = new ModifyResult<K, V>( newLeaf, replacedValue );
        result.addCopiedPage( this );

        return result;
    }


    /**
     * Adds a new <K, V> into a copy of the current page at a given position. We return the
     * modified page. The new page will have one more element than the current page.
     *
     * @param revision The revision of the modified page
     * @param key The key to insert
     * @param value The value to insert
     * @param pos The position into the page
     * @return The modified page with the <K,V> element added
     */
    private Page<K, V> addElement( long revision, K key, V value, int pos )
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



mavibot/src/main/java/org/apache/directory/mavibot/btree/PersistedLeaf.java [956:995]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        valueHolder = newLeaf.values[pos];
        V replacedValue = null;

        if ( !valueExists && btree.isAllowDuplicates() )
        {
            valueHolder.add( value );
            newLeaf.values[pos] = valueHolder;
        }
        else if ( valueExists && btree.isAllowDuplicates() )
        {
            // As strange as it sounds, we need to remove the value to reinject it.
            // There are cases where the value retrieval just use one part of the
            // value only (typically for LDAP Entries, where we use the DN)
            replacedValue = valueHolder.remove( value );
            valueHolder.add( value );
        }
        else if ( !btree.isAllowDuplicates() )
        {
            replacedValue = valueHolder.replaceValueArray( value );
        }

        // Create the result
        InsertResult<K, V> result = new ModifyResult<K, V>( newLeaf, replacedValue );
        result.addCopiedPage( this );

        return result;
    }


    /**
     * Adds a new <K, V> into a copy of the current page at a given position. We return the
     * modified page. The new page will have one more element than the current page.
     *
     * @param revision The revision of the modified page
     * @param key The key to insert
     * @param value The value to insert
     * @param pos The position into the page
     * @return The modified page with the <K,V> element added
     */
    private Page<K, V> addElement( long revision, K key, V value, int pos )
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



