/** * Creates a new <code>TShortHashSet</code> instance containing the * elements of <tt>array</tt>. * * @param array an array of <code>short</code> primitives */ public TShortHashSet( short[] array ) { this( Math.max( array.length, DEFAULT_CAPACITY ) ); addAll( array ); }
/** * Creates a new <code>TShortHashSet</code> instance that is a copy * of the existing Collection. * * @param collection a <tt>Collection</tt> that will be duplicated. */ public TShortHashSet( Collection<? extends Short> collection ) { this( Math.max( collection.size(), DEFAULT_CAPACITY ) ); addAll( collection ); }
/** * Creates a new <code>TShortHashSet</code> instance that is a copy * of the existing set. * * @param collection a <tt>TShortSet</tt> that will be duplicated. */ public TShortHashSet( TShortCollection collection ) { this( Math.max( collection.size(), DEFAULT_CAPACITY ) ); if ( collection instanceof TShortHashSet ) { TShortHashSet hashset = ( TShortHashSet ) collection; this._loadFactor = hashset._loadFactor; this.no_entry_value = hashset.no_entry_value; //noinspection RedundantCast if ( this.no_entry_value != ( short ) 0 ) { Arrays.fill( _set, this.no_entry_value ); } setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) ); } addAll( collection ); }
/** * Creates a new <code>TShortHashSet</code> instance containing the * elements of <tt>array</tt>. * * @param array an array of <code>short</code> primitives */ public TShortHashSet( short[] array ) { this( Math.max( array.length, DEFAULT_CAPACITY ) ); addAll( array ); }
/** * Creates a new <code>TShortHashSet</code> instance containing the * elements of <tt>array</tt>. * * @param array an array of <code>short</code> primitives */ public TShortHashSet( short[] array ) { this( Math.max( array.length, DEFAULT_CAPACITY ) ); addAll( array ); }
/** * Creates a new <code>TShortHashSet</code> instance containing the * elements of <tt>array</tt>. * * @param array an array of <code>short</code> primitives */ public TShortHashSet( short[] array ) { this( Math.max( array.length, DEFAULT_CAPACITY ) ); addAll( array ); }
/** * Creates a new <code>TShortHashSet</code> instance containing the * elements of <tt>array</tt>. * * @param array an array of <code>short</code> primitives */ public TShortHashSet( short[] array ) { this( Math.max( array.length, DEFAULT_CAPACITY ) ); addAll( array ); }
/** * Creates a new <code>TShortHashSet</code> instance that is a copy * of the existing Collection. * * @param collection a <tt>Collection</tt> that will be duplicated. */ public TShortHashSet( Collection<? extends Short> collection ) { this( Math.max( collection.size(), DEFAULT_CAPACITY ) ); addAll( collection ); }
/** * Creates a new <code>TShortHashSet</code> instance that is a copy * of the existing Collection. * * @param collection a <tt>Collection</tt> that will be duplicated. */ public TShortHashSet( Collection<? extends Short> collection ) { this( Math.max( collection.size(), DEFAULT_CAPACITY ) ); addAll( collection ); }
/** * Creates a new <code>TShortHashSet</code> instance that is a copy * of the existing Collection. * * @param collection a <tt>Collection</tt> that will be duplicated. */ public TShortHashSet( Collection<? extends Short> collection ) { this( Math.max( collection.size(), DEFAULT_CAPACITY ) ); addAll( collection ); }
/** * Creates a new <code>TShortHashSet</code> instance that is a copy * of the existing Collection. * * @param collection a <tt>Collection</tt> that will be duplicated. */ public TShortHashSet( Collection<? extends Short> collection ) { this( Math.max( collection.size(), DEFAULT_CAPACITY ) ); addAll( collection ); }
/** * Creates a new <code>TShortHashSet</code> instance that is a copy * of the existing set. * * @param collection a <tt>TShortSet</tt> that will be duplicated. */ public TShortHashSet( TShortCollection collection ) { this( Math.max( collection.size(), DEFAULT_CAPACITY ) ); if ( collection instanceof TShortHashSet ) { TShortHashSet hashset = ( TShortHashSet ) collection; this._loadFactor = hashset._loadFactor; this.no_entry_value = hashset.no_entry_value; //noinspection RedundantCast if ( this.no_entry_value != ( short ) 0 ) { Arrays.fill( _set, this.no_entry_value ); } setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) ); } addAll( collection ); }
/** * Creates a new <code>TShortHashSet</code> instance that is a copy * of the existing set. * * @param collection a <tt>TShortSet</tt> that will be duplicated. */ public TShortHashSet( TShortCollection collection ) { this( Math.max( collection.size(), DEFAULT_CAPACITY ) ); if ( collection instanceof TShortHashSet ) { TShortHashSet hashset = ( TShortHashSet ) collection; this._loadFactor = hashset._loadFactor; this.no_entry_value = hashset.no_entry_value; //noinspection RedundantCast if ( this.no_entry_value != ( short ) 0 ) { Arrays.fill( _set, this.no_entry_value ); } setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) ); } addAll( collection ); }
/** * Creates a new <code>TShortHashSet</code> instance that is a copy * of the existing set. * * @param collection a <tt>TShortSet</tt> that will be duplicated. */ public TShortHashSet( TShortCollection collection ) { this( Math.max( collection.size(), DEFAULT_CAPACITY ) ); if ( collection instanceof TShortHashSet ) { TShortHashSet hashset = ( TShortHashSet ) collection; this._loadFactor = hashset._loadFactor; this.no_entry_value = hashset.no_entry_value; //noinspection RedundantCast if ( this.no_entry_value != ( short ) 0 ) { Arrays.fill( _set, this.no_entry_value ); } setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) ); } addAll( collection ); }
/** * Creates a new <code>TShortHashSet</code> instance that is a copy * of the existing set. * * @param collection a <tt>TShortSet</tt> that will be duplicated. */ public TShortHashSet( TShortCollection collection ) { this( Math.max( collection.size(), DEFAULT_CAPACITY ) ); if ( collection instanceof TShortHashSet ) { TShortHashSet hashset = ( TShortHashSet ) collection; this._loadFactor = hashset._loadFactor; this.no_entry_value = hashset.no_entry_value; //noinspection RedundantCast if ( this.no_entry_value != ( short ) 0 ) { Arrays.fill( _set, this.no_entry_value ); } setUp( saturatedCast( fastCeil( DEFAULT_CAPACITY / (double) _loadFactor ) ) ); } addAll( collection ); }
@Override public double compare(final short[] h1, final short[] h2) { TShortHashSet union = new TShortHashSet(h1); union.addAll(h2); TShortHashSet intersection = new TShortHashSet(h1); intersection.retainAll(h2.clone()); //retainAll sorts the input, so we need to make a copy return 1.0 - (((double)intersection.size()) / (double)union.size()); } },
@Override public double compare(final short[] h1, final short[] h2) { TShortHashSet union = new TShortHashSet(h1); union.addAll(h2); TShortHashSet intersection = new TShortHashSet(h1); intersection.retainAll(h2.clone()); //retainAll sorts the input, so we need to make a copy return 1.0 - (((double)intersection.size()) / (double)union.size()); } },
private Object handleOpPush(CacheLine line, Object extra, int change) { if ((change & LINE_MODIFIED_CHANGED) == 0) { assert line.is(CacheLine.MODIFIED); return PENDING; } if (line.getState().isLessThan(State.O)) { LOG.info("Attempt to push line {} while state is only {}", hex(line.getId()), line.getState()); return null; // throw new IllegalStateException("Line " + line.getId() + " is not owned by this cache."); } setState(line, State.O); short[] toNodes = (short[]) extra; line.sharers.addAll(toNodes); for (short node : toNodes) { send(Message.PUT(node, line.id, line.version, readOnly(line.data))); line.rewind(); } return null; }
@Override public double compare(final SparseShortArray h1, final SparseShortArray h2) { short[] h1v = h1.values(); short[] h2v = h2.values(); TShortHashSet union = new TShortHashSet(h1v); union.addAll(h2v); if (h1v.length != h1.length || h2v.length != h2.length) union.add((short)0); TShortHashSet intersection = new TShortHashSet(h1v); intersection.retainAll(h2v); if (h1v.length != h1.length && h2v.length != h2.length) union.add((short)0); return 1.0 - (((double)intersection.size()) / (double)union.size()); } },
@Override public double compare(final SparseShortArray h1, final SparseShortArray h2) { short[] h1v = h1.values(); short[] h2v = h2.values(); TShortHashSet union = new TShortHashSet(h1v); union.addAll(h2v); if (h1v.length != h1.length || h2v.length != h2.length) union.add((short)0); TShortHashSet intersection = new TShortHashSet(h1v); intersection.retainAll(h2v); if (h1v.length != h1.length && h2v.length != h2.length) union.add((short)0); return 1.0 - (((double)intersection.size()) / (double)union.size()); } },