/** * {@inheritDoc} */ public boolean contains( V checkedValue ) { // First, deserialize the value if it's still a byte[] checkAndDeserialize(); return super.contains( checkedValue ); }
/** * @return a cursor on top of the values */ public ValueCursor<V> getCursor() { // Check that the values are deserialized before doing anything checkAndDeserialize(); return super.getCursor(); }
/** * {@inheritDoc} */ public void add( V value ) { // First check that we have a loaded BTree checkAndDeserialize(); super.add( value ); // The raw value is not anymore up to date with the content isRawUpToDate = false; raw = null; }
/** * {@inheritDoc} */ public int size() { checkAndDeserialize(); if ( valueArray == null ) { return ( int ) valueBtree.getNbElems(); } else { return valueArray.length; } }
/** * Remove a value from an array */ private V removeFromArray( V value ) { checkAndDeserialize(); // First check that the value is not already present in the ValueHolder int pos = findPos( value ); if ( pos < 0 ) { // The value does not exists : nothing to do return null; } // Ok, we just have to delete the new element at the right position // First, copy the array V[] newValueArray = ( V[] ) Array.newInstance( valueSerializer.getType(), valueArray.length - 1 ); System.arraycopy( valueArray, 0, newValueArray, 0, pos ); System.arraycopy( valueArray, pos + 1, newValueArray, pos, valueArray.length - pos - 1 ); // Get the removed element V removedValue = valueArray[pos]; // And switch the arrays valueArray = newValueArray; return removedValue; }