private void writeObject(java.io.ObjectOutputStream s) throws IOException { s.defaultWriteObject(); // Nothing to write final NBSI nbsi = _nbsi; // The One Field is transient final int len = _nbsi._bits.length<<6; s.writeInt(len); // Write max element for( int i=0; i<len; i++ ) s.writeBoolean( _nbsi.contains(i) ); }
private void writeObject(java.io.ObjectOutputStream s) throws IOException { s.defaultWriteObject(); // Nothing to write final NBSI nbsi = _nbsi; // The One Field is transient final int len = _nbsi._bits.length<<6; s.writeInt(len); // Write max element for( int i=0; i<len; i++ ) s.writeBoolean( _nbsi.contains(i) ); }
public boolean contains( final int i ) { if( (i>>6) >= _bits.length ) // Out of bounds? Not in this array! return _new != null && help_copy().contains(i); // Handle every 64th bit via using a nested array NBSI nbsi = this; // The bit array being added into int j = i; // The bit index being added while( (j&63) == 63 ) { // Bit 64? (low 6 bits are all set) nbsi = nbsi._nbsi64; // Recurse j = j>>6; // Strip off low 6 bits (all set) } final long mask = mask(j); long old = nbsi._bits[j>>6]; // Read old bits if( old < 0 ) // Not mutable? // Not mutable: finish copy of word, and retry on copied word return help_copy_impl(i).help_copy().contains(i); // Yes mutable: test & return bit return (old & mask) != 0; }
private void advance() { while( true ) { _idx++; // Next index while( (_idx>>6) >= _nbsi2._bits.length ) { // Index out of range? if( _nbsi2._new == null ) { // New table? _idx = -2; // No, so must be all done return; // } _nbsi2 = _nbsi2._new; // Carry on, in the new table } if( _nbsi2.contains(_idx) ) return; } } public Integer next() {
/** * Test if {@code i} is in the set. This is the lower-case '{@code int}' * version of {@link #contains} - no autoboxing. * @return <tt>true</tt> if i was int the set. */ public boolean contains( final int i ) { return i >= 0 && _nbsi.contains(i); } /**
public boolean contains( final int i ) { if( (i>>6) >= _bits.length ) // Out of bounds? Not in this array! return _new != null && help_copy().contains(i); // Handle every 64th bit via using a nested array NBSI nbsi = this; // The bit array being added into int j = i; // The bit index being added while( (j&63) == 63 ) { // Bit 64? (low 6 bits are all set) nbsi = nbsi._nbsi64; // Recurse j = j>>6; // Strip off low 6 bits (all set) } final long mask = mask(j); long old = nbsi._bits[j>>6]; // Read old bits if( old < 0 ) // Not mutable? // Not mutable: finish copy of word, and retry on copied word return help_copy_impl(i).help_copy().contains(i); // Yes mutable: test & return bit return (old & mask) != 0; }
private void advance() { while( true ) { _idx++; // Next index while( (_idx>>6) >= _nbsi2._bits.length ) { // Index out of range? if( _nbsi2._new == null ) { // New table? _idx = -2; // No, so must be all done return; // } _nbsi2 = _nbsi2._new; // Carry on, in the new table } if( _nbsi2.contains(_idx) ) return; } } public Integer next() {
/** * Test if {@code i} is in the set. This is the lower-case '{@code int}' * version of {@link #contains} - no autoboxing. * @return <tt>true</tt> if i was int the set. */ public boolean contains( final int i ) { return i >= 0 && _nbsi.contains(i); } /**