@Test public void testRemove() { TableCutList list = new TableCutList( 2, true ); list.put( 10, Boolean.TRUE ); list.put( 20, Boolean.TRUE ); assertThat( list.remove( 10 ), is( equalTo( true ) ) ); assertThat( list.get( 10 ), is( equalTo( null ) ) ); assertThat( list.remove( 2 ), is( equalTo( false ) ) ); }
public boolean remove( final long key ) { final int position = findKeyInternal( key ); if ( position < 0 ) { return false; } final int shiftElements = size - position - 1; if ( shiftElements == 0 ) { keys[position] = 0; entries[position] = null; size -= 1; if ( size == 0 ) { scaleFactor = 0; } else { scaleFactor = ( keys[size - 1] - keys[0] ) / size; } return true; } size -= 1; System.arraycopy( keys, position + 1, keys, position, shiftElements ); System.arraycopy( entries, position + 1, entries, position, shiftElements ); keys[size] = 0; entries[size] = null; if ( size == 0 ) { scaleFactor = 0; } else { scaleFactor = ( keys[size - 1] - keys[0] ) / size; } return true; }
TableCutList implements Cloneable { public boolean remove( final long key ) { final int position = findKeyInternal( key ); if ( position < 0 ) { return false; } final int shiftElements = size - position - 1; if ( shiftElements == 0 ) { keys[position] = 0; entries[position] = null; size -= 1; if ( size == 0 ) { scaleFactor = 0; } else { scaleFactor = ( keys[size - 1] - keys[0] ) / size; } return true; } size -= 1; System.arraycopy( keys, position + 1, keys, position, shiftElements ); System.arraycopy( entries, position + 1, entries, position, shiftElements ); keys[size] = 0; entries[size] = null; if ( size == 0 ) { scaleFactor = 0; } else { scaleFactor = ( keys[size - 1] - keys[0] ) / size; } return true; } }
TableCutList implements Cloneable { public boolean remove( final long key ) { final int position = findKeyInternal( key ); if ( position < 0 ) { return false; } final int shiftElements = size - position - 1; if ( shiftElements == 0 ) { keys[position] = 0; entries[position] = null; size -= 1; if ( size == 0 ) { scaleFactor = 0; } else { scaleFactor = ( keys[size - 1] - keys[0] ) / size; } return true; } size -= 1; System.arraycopy( keys, position + 1, keys, position, shiftElements ); System.arraycopy( entries, position + 1, entries, position, shiftElements ); keys[size] = 0; entries[size] = null; if ( size == 0 ) { scaleFactor = 0; } else { scaleFactor = ( keys[size - 1] - keys[0] ) / size; } return true; } TableCutList( final int increment, final boolean enableQuickLookup ); }
TableCutList implements Cloneable { public boolean remove( final long key ) { final int position = findKeyInternal( key ); if ( position < 0 ) { return false; } final int shiftElements = size - position - 1; if ( shiftElements == 0 ) { keys[position] = 0; entries[position] = null; size -= 1; if ( size == 0 ) { scaleFactor = 0; } else { scaleFactor = ( keys[size - 1] - keys[0] ) / size; } return true; } size -= 1; System.arraycopy( keys, position + 1, keys, position, shiftElements ); System.arraycopy( entries, position + 1, entries, position, shiftElements ); keys[size] = 0; entries[size] = null; if ( size == 0 ) { scaleFactor = 0; } else { scaleFactor = ( keys[size - 1] - keys[0] ) / size; } return true; } TableCutList( final int increment, final boolean enableQuickLookup ); TableCutList clone(); void clear(); boolean isEnableQuickLookup(); void setEnableQuickLookup( final boolean enableQuickLookup ); int size(); boolean put( final long key, final Boolean entry ); boolean remove( final long key ); Boolean get( final long key ); Boolean getPrevious( final long key ); boolean containsKey( final long key ); Boolean[] getRawEntries(); long[] getKeys(); long[] getKeys( long[] retval ); int findKeyPosition( final long coordinate, final boolean greater ); int findKeyPosition( final long coordinate, final boolean greater, final int lastFoundPos ); long getKeyAt( final int indexPosition ); Boolean getValueAt( final int indexPosition ); long findKey( final long key, final boolean upperBounds ); void removeAll( final long[] cutArray, final long cutSize ); }
TableCutList implements Cloneable { public boolean remove( final long key ) { final int position = findKeyInternal( key ); if ( position < 0 ) { return false; } final int shiftElements = size - position - 1; if ( shiftElements == 0 ) { keys[position] = 0; entries[position] = null; size -= 1; if ( size == 0 ) { scaleFactor = 0; } else { scaleFactor = ( keys[size - 1] - keys[0] ) / size; } return true; } size -= 1; System.arraycopy( keys, position + 1, keys, position, shiftElements ); System.arraycopy( entries, position + 1, entries, position, shiftElements ); keys[size] = 0; entries[size] = null; if ( size == 0 ) { scaleFactor = 0; } else { scaleFactor = ( keys[size - 1] - keys[0] ) / size; } return true; } TableCutList( final int increment, final boolean enableQuickLookup ); TableCutList clone(); void clear(); boolean isEnableQuickLookup(); void setEnableQuickLookup( final boolean enableQuickLookup ); int size(); boolean put( final long key, final Boolean entry ); boolean remove( final long key ); Boolean get( final long key ); Boolean getPrevious( final long key ); boolean containsKey( final long key ); Boolean[] getRawEntries(); long[] getKeys(); long[] getKeys( long[] retval ); int findKeyPosition( final long coordinate, final boolean greater ); int findKeyPosition( final long coordinate, final boolean greater, final int lastFoundPos ); long getKeyAt( final int indexPosition ); Boolean getValueAt( final int indexPosition ); long findKey( final long key, final boolean upperBounds ); void removeAll( final long[] cutArray, final long cutSize ); static long bin; static long lin; }