/** * 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 ); }
/** {@inheritDoc} */ public boolean removeAll( short[] array ) { boolean changed = false; for ( int i = array.length; i-- > 0; ) { if ( remove(array[i]) ) { changed = true; } } return changed; }
/** {@inheritDoc} */ public boolean add( short val ) { int index = insertKey(val); if ( index < 0 ) { return false; // already present in set, nothing to add } postInsertHook( consumeFreeSlot ); return true; // yes, we added something }
@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()); } },
/** {@inheritDoc} */ public boolean addAll( short[] array ) { boolean changed = false; for ( int i = array.length; i-- > 0; ) { if ( add( array[i] ) ) { changed = true; } } return changed; }
TShortHashSet tmp = new TShortHashSet(tagSet); if (overriddenTags != null) { for (OSMTag osmTag : overriddenTags) { tmp.remove(osmTag.getId()); if (tmp.isEmpty()) { StringBuilder sb = new StringBuilder(); for (short s : tagSet) { for (short s : tmp.toArray()) { OSMTag tag = this.idToPoiTag.get(Short.valueOf(s)); if (tag.isRenderable()) {
/** * 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 ); }
/** {@inheritDoc} */ public short[] toArray() { short[] result = new short[ size() ]; short[] set = _set; byte[] states = _states; for ( int i = states.length, j = 0; i-- > 0; ) { if ( states[i] == FULL ) { result[j++] = set[i]; } } return result; }
/** {@inheritDoc} */ @SuppressWarnings({"SuspiciousMethodCalls"}) public boolean retainAll( Collection<?> collection ) { boolean modified = false; TShortIterator iter = iterator(); while ( iter.hasNext() ) { if ( ! collection.contains( Short.valueOf ( iter.next() ) ) ) { iter.remove(); modified = true; } } return modified; }
/** {@inheritDoc} */ public boolean containsAll( short[] array ) { for ( int i = array.length; i-- > 0; ) { if ( ! contains( array[i] ) ) { return false; } } return true; }
/** * 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 ); }
public BroadcastEntry(LineMessage message, Set<Short> nodes) { this.message = message; this.nodes = new TShortHashSet(nodes); this.nodes.remove(Comm.SERVER); // NOT TO SERVER LOG.debug("Awaiting ACKS for message {} from nodes {}", message, this.nodes); }
if (LOG.isDebugEnabled()) LOG.debug("Got ACK from {} to message {}", message.getNode(), entry.message); final int numNodes = entry.nodes.size(); if (done) { if (entry.message instanceof LineMessage) { long delay = resendPeriodNanos - sinceLastSent; delay = (delay >= 0 ? delay : 0); for (TShortIterator it = entry.nodes.iterator(); it.hasNext();) { final NodePeer peer = peers.get(it.next()); if (peer.isBroadcast()) {
/** {@inheritDoc} */ public boolean retainAll( short[] array ) { boolean changed = false; Arrays.sort( array ); short[] set = _set; byte[] states = _states; _autoCompactTemporaryDisable = true; for ( int i = set.length; i-- > 0; ) { if ( states[i] == FULL && ( Arrays.binarySearch( array, set[i] ) < 0) ) { removeAt( i ); changed = true; } } _autoCompactTemporaryDisable = false; return changed; }
/** {@inheritDoc} */ public boolean add( short val ) { int index = insertionIndex(val); if ( index < 0 ) { return false; // already present in set, nothing to add } byte previousState = _states[index]; _set[index] = val; _states[index] = FULL; postInsertHook( previousState == FREE ); return true; // yes, we added something }
@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()); } },