@Test public void testRemoveAll() { TableCutList list = new TableCutList( 2, true ); list.put( 10, Boolean.TRUE ); list.put( 15, Boolean.TRUE ); list.put( 20, Boolean.TRUE ); list.removeAll( new long[] { 10l }, 0 ); assertThat( list.size(), is( equalTo( 3 ) ) ); list.removeAll( new long[] { 10l, 20l }, 2 ); assertThat( list.size(), is( equalTo( 1 ) ) ); list.removeAll( new long[] { 15l }, 1 ); assertThat( list.size(), is( equalTo( 0 ) ) ); }
public void removeAll( final long[] cutArray, final long cutSize ) { if ( cutSize == 0 ) { return; } int cutIndex = 0; long currentCut = cutArray[0]; int targetPosition = 0; int sourcePosition = 0; for ( ; sourcePosition < size; sourcePosition++ ) { final long key = keys[sourcePosition]; if ( key == currentCut ) { cutIndex += 1; if ( cutIndex == cutSize ) { System.arraycopy( keys, sourcePosition + 1, keys, targetPosition, size - sourcePosition - 1 ); System.arraycopy( entries, sourcePosition + 1, entries, targetPosition, size - sourcePosition - 1 ); targetPosition = size - cutIndex; break; } currentCut = cutArray[cutIndex]; } else { keys[targetPosition] = key; entries[targetPosition] = entries[sourcePosition]; targetPosition += 1; } } Arrays.fill( keys, targetPosition, size, 0 ); Arrays.fill( entries, targetPosition, size, null ); size = targetPosition; if ( size != 0 ) { scaleFactor = ( keys[size - 1] - keys[0] ) / size; } else { scaleFactor = 0; } }
TableCutList implements Cloneable { public void removeAll( final long[] cutArray, final long cutSize ) { if ( cutSize == 0 ) { return; } int cutIndex = 0; long currentCut = cutArray[0]; int targetPosition = 0; int sourcePosition = 0; for ( ; sourcePosition < size; sourcePosition++ ) { final long key = keys[sourcePosition]; if ( key == currentCut ) { cutIndex += 1; if ( cutIndex == cutSize ) { System.arraycopy( keys, sourcePosition + 1, keys, targetPosition, size - sourcePosition - 1 ); System.arraycopy( entries, sourcePosition + 1, entries, targetPosition, size - sourcePosition - 1 ); targetPosition = size - cutIndex; break; } currentCut = cutArray[cutIndex]; } else { keys[targetPosition] = key; entries[targetPosition] = entries[sourcePosition]; targetPosition += 1; } } Arrays.fill( keys, targetPosition, size, 0 ); Arrays.fill( entries, targetPosition, size, null ); size = targetPosition; if ( size != 0 ) { scaleFactor = ( keys[size - 1] - keys[0] ) / size; } else { scaleFactor = 0; } } }
TableCutList implements Cloneable { public void removeAll( final long[] cutArray, final long cutSize ) { if ( cutSize == 0 ) { return; } int cutIndex = 0; long currentCut = cutArray[0]; int targetPosition = 0; int sourcePosition = 0; for ( ; sourcePosition < size; sourcePosition++ ) { final long key = keys[sourcePosition]; if ( key == currentCut ) { cutIndex += 1; if ( cutIndex == cutSize ) { System.arraycopy( keys, sourcePosition + 1, keys, targetPosition, size - sourcePosition - 1 ); System.arraycopy( entries, sourcePosition + 1, entries, targetPosition, size - sourcePosition - 1 ); targetPosition = size - cutIndex; break; } currentCut = cutArray[cutIndex]; } else { keys[targetPosition] = key; entries[targetPosition] = entries[sourcePosition]; targetPosition += 1; } } Arrays.fill( keys, targetPosition, size, 0 ); Arrays.fill( entries, targetPosition, size, null ); size = targetPosition; if ( size != 0 ) { scaleFactor = ( keys[size - 1] - keys[0] ) / size; } else { scaleFactor = 0; } } TableCutList( final int increment, final boolean enableQuickLookup ); }
TableCutList implements Cloneable { public void removeAll( final long[] cutArray, final long cutSize ) { if ( cutSize == 0 ) { return; } int cutIndex = 0; long currentCut = cutArray[0]; int targetPosition = 0; int sourcePosition = 0; for ( ; sourcePosition < size; sourcePosition++ ) { final long key = keys[sourcePosition]; if ( key == currentCut ) { cutIndex += 1; if ( cutIndex == cutSize ) { System.arraycopy( keys, sourcePosition + 1, keys, targetPosition, size - sourcePosition - 1 ); System.arraycopy( entries, sourcePosition + 1, entries, targetPosition, size - sourcePosition - 1 ); targetPosition = size - cutIndex; break; } currentCut = cutArray[cutIndex]; } else { keys[targetPosition] = key; entries[targetPosition] = entries[sourcePosition]; targetPosition += 1; } } Arrays.fill( keys, targetPosition, size, 0 ); Arrays.fill( entries, targetPosition, size, null ); size = targetPosition; if ( size != 0 ) { scaleFactor = ( keys[size - 1] - keys[0] ) / size; } else { scaleFactor = 0; } } 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 void removeAll( final long[] cutArray, final long cutSize ) { if ( cutSize == 0 ) { return; } int cutIndex = 0; long currentCut = cutArray[0]; int targetPosition = 0; int sourcePosition = 0; for ( ; sourcePosition < size; sourcePosition++ ) { final long key = keys[sourcePosition]; if ( key == currentCut ) { cutIndex += 1; if ( cutIndex == cutSize ) { System.arraycopy( keys, sourcePosition + 1, keys, targetPosition, size - sourcePosition - 1 ); System.arraycopy( entries, sourcePosition + 1, entries, targetPosition, size - sourcePosition - 1 ); targetPosition = size - cutIndex; break; } currentCut = cutArray[cutIndex]; } else { keys[targetPosition] = key; entries[targetPosition] = entries[sourcePosition]; targetPosition += 1; } } Arrays.fill( keys, targetPosition, size, 0 ); Arrays.fill( entries, targetPosition, size, null ); size = targetPosition; if ( size != 0 ) { scaleFactor = ( keys[size - 1] - keys[0] ) / size; } else { scaleFactor = 0; } } 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; }