/** {@inheritDoc} */ @Override public boolean equals( Object other ) { if ( ! ( other instanceof TLongIntMap ) ) { return false; } TLongIntMap that = ( TLongIntMap ) other; if ( that.size() != this.size() ) { return false; } int[] values = _values; byte[] states = _states; int this_no_entry_value = getNoEntryValue(); int that_no_entry_value = that.getNoEntryValue(); for ( int i = values.length; i-- > 0; ) { if ( states[i] == FULL ) { long key = _set[i]; int that_value = that.get( key ); int this_value = values[i]; if ( ( this_value != that_value ) && ( this_value != this_no_entry_value ) && ( that_value != that_no_entry_value ) ) { return false; } } } return true; }
/** * Inserts a key/value pair into the map. * * @param key an <code>Object</code> value * @param value an <code>Object</code> value * @return the previous value associated with <tt>key</tt>, * or Integer(0) if none was found. */ public Integer put( Long key, Integer value ) { long k; int v; if ( key == null ) { k = _map.getNoEntryKey(); } else { k = unwrapKey( key ); } if ( value == null ) { v = _map.getNoEntryValue(); } else { v = unwrapValue( value ); } int retval = _map.put( k, v ); if ( retval == _map.getNoEntryValue() ) { return null; } return wrapValue( retval ); }
public int adjustOrPutValue( long key, int adjust_amount, int put_amount ) { synchronized( mutex ) { return m.adjustOrPutValue( key, adjust_amount, put_amount ); } }
/** * Checks for the present of <tt>key</tt> in the keys of the map. * * @param key an <code>Object</code> value * @return a <code>boolean</code> value */ public boolean containsKey( Object key ) { if ( key == null ) return _map.containsKey( _map.getNoEntryKey() ); return key instanceof Long && _map.containsKey( unwrapKey( key ) ); }
/** * Retrieves the value for <tt>key</tt> * * @param key an <code>Object</code> value * @return the value of <tt>key</tt> or null if no such mapping exists. */ public Integer get( Object key ) { long k; if ( key != null ) { if ( key instanceof Long ) { k = unwrapKey( key ); } else { return null; } } else { k = _map.getNoEntryKey(); } int v = _map.get( k ); // There may be a false positive since primitive maps // cannot return null, so we have to do an extra // check here. if ( v == _map.getNoEntryValue() ) { return null; } else { return wrapValue( v ); } }
degrees.adjustOrPutValue(edge.field0, 1, 1); degrees.adjustOrPutValue(edge.field0, 0, 0); int numVertices = degrees.size(); float initialRank = 1f / numVertices; float dampingRank = (1 - this.dampingFactor) / numVertices; degrees.forEachKey(k -> { initialRanks.putIfAbsent(k, initialRank); return true; degrees.forEachKey(k -> { newRanks.putIfAbsent(k, dampingRank); return true; final long sourceVertex = edge.field0; final long targetVertex = edge.field1; final int degree = degrees.get(sourceVertex); final float currentRank = currentRanks.get(sourceVertex); final float partialRank = this.dampingFactor * currentRank / degree;
/** * Returns the number of entries in the map. * * @return the map's size. */ public int size() { return this._map.size(); }
public int get( long key ) { synchronized( mutex ) { return m.get( key ); } }
public int put( long key, int value ) { synchronized( mutex ) { return m.put( key, value ); } } public int remove( long key ) {
if (n < unigramCounts.size()) { int counts[] = unigramCounts.values(); Arrays.sort(counts); threshold = counts[counts.length - n]; unigramCounts.forEachEntry(new TLongIntProcedure() { @Override public boolean execute(long hash, int count) {
/** * Empties the map. */ public void clear() { this._map.clear(); }
@Override public void handleHighway(LineString geometry, Way way) { if(w2n.containsKey(way.id)) { Envelope env = geometry.getEnvelopeInternal(); short n = new Double((env.getMinX() + 180.0) * 10.0).shortValue(); int fromto = n << 16; n = new Double((env.getMaxX() + 180.0) * 10.0).shortValue(); fromto |= n; w2n.put(way.id, fromto); } highwaysHandler.handleHighway(geometry, way); }
public boolean containsKey( long key ) { synchronized( mutex ) { return m.containsKey( key ); } } public boolean containsValue( int value ){
public boolean forEachKey( TLongProcedure procedure ) { synchronized( mutex ) { return m.forEachKey( procedure ); } } public boolean forEachValue( TIntProcedure procedure ) {
public boolean forEachEntry( TLongIntProcedure procedure ) { synchronized( mutex ) { return m.forEachEntry( procedure ); } } public void transformValues( TIntFunction function ) {
public TLongIntIterator iterator() { return m.iterator(); // Must be manually synched by user! }
public static <T extends DeBruijnNodeBase> long getExpectedReferencePosition(Iterable<T> nodes) { TLongIntMap map = new TLongIntHashMap(); for (DeBruijnNodeBase n : nodes) { for (Support s : n.support) { if (s.isReference) { map.adjustOrPutValue(s.expectedLinearPosition, s.weight, s.weight); } } } if (map.isEmpty()) throw new IllegalStateException("No reference support"); return getKeyWithMaxValue(map); } private static long getKeyWithMaxValue(TLongIntMap map) {
if (subGrams.contains(hash)) { synchronized (counts) { if (counts.containsKey(hash)) { counts.adjustValue(hash, 1); } else {