/** {@inheritDoc} */ public void putAll( Map<? extends Long, ? extends Integer> map ) { ensureCapacity( map.size() ); // could optimize this for cases when map instanceof THashMap for ( Map.Entry<? extends Long, ? extends Integer> entry : map.entrySet() ) { this.put( entry.getKey().longValue(), entry.getValue().intValue() ); } }
/** {@inheritDoc} */ public long[] keys() { long[] keys = new long[size()]; long[] k = _set; byte[] states = _states; for ( int i = k.length, j = 0; i-- > 0; ) { if ( states[i] == FULL ) { keys[j++] = k[i]; } } return keys; }
/** {@inheritDoc} */ public long[] toArray( long[] dest ) { return TLongIntHashMap.this.keys( dest ); }
/** {@inheritDoc} */ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // VERSION in.readByte(); // SUPER super.readExternal( in ); // NUMBER OF ENTRIES int size = in.readInt(); setUp( size ); // ENTRIES while (size-- > 0) { long key = in.readLong(); int val = in.readInt(); put(key, val); } } } // TLongIntHashMap
/** {@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; }
private Alphabet (int capacity) { this.map = new TLongIntHashMap(capacity); numEntries = 0; }
public CircularFingerprinter.FP[] getFingerprintDetails() { final CircularFingerprinter.FP[] ary = new CircularFingerprinter.FP[HASH_SET.size()]; for (int k=0; k < circularFingerprinter.getFPCount(); ++k) { final CircularFingerprinter.FP fp = circularFingerprinter.getFP(k); if (HASH_SET.containsKey(fp.hashCode)) { ary[HASH_SET.get(fp.hashCode)] = fp; } } return ary; }
/** {@inheritDoc} */ @Override public String toString() { final StringBuilder buf = new StringBuilder( "{" ); forEachEntry( new TLongIntProcedure() { private boolean first = true; public boolean execute( long key, int value ) { if ( first ) first = false; else buf.append( ", " ); buf.append(key); buf.append("="); buf.append(value); return true; } }); buf.append( "}" ); return buf.toString(); }
/** * Find a bucket number using a key * @param key * @return Non zero bucket number. Zero if 'not found' */ int getBucketNumber(long key) { return hash.get(key); }
/** {@inheritDoc} */ public boolean containsAll( Collection<?> collection ) { for ( Object element : collection ) { if ( element instanceof Long ) { long ele = ( ( Long ) element ).longValue(); if ( ! TLongIntHashMap.this.containsKey( ele ) ) { return false; } } else { return false; } } return true; }
/** {@inheritDoc} */ public boolean containsAll( long[] array ) { for ( long element : array ) { if ( ! TLongIntHashMap.this.contains( element ) ) { return false; } } return true; }
/** {@inheritDoc} */ public void clear() { TLongIntHashMap.this.clear(); }
/** * Creates a new <code>TLongIntHashMap</code> instance containing * all of the entries in the map passed in. * * @param keys a <tt>long</tt> array containing the keys for the matching values. * @param values a <tt>int</tt> array containing the values. */ public TLongIntHashMap( long[] keys, int[] values ) { super( Math.max( keys.length, values.length ) ); int size = Math.min( keys.length, values.length ); for ( int i = 0; i < size; i++ ) { this.put( keys[i], values[i] ); } }
/** {@inheritDoc} */ public boolean increment( long key ) { return adjustValue( key, ( int ) 1 ); }
private Alphabet (int capacity) { this.map = new TLongIntHashMap(capacity); numEntries = 0; }
/** {@inheritDoc} */ @Override public String toString() { final StringBuilder buf = new StringBuilder( "{" ); forEachEntry( new TLongIntProcedure() { private boolean first = true; public boolean execute( long key, int value ) { if ( first ) first = false; else buf.append( ", " ); buf.append(key); buf.append("="); buf.append(value); return true; } }); buf.append( "}" ); return buf.toString(); }
protected int get(long key) { return hash.get(key); }
/** {@inheritDoc} */ public boolean containsAll( TLongCollection collection ) { TLongIterator iter = collection.iterator(); while ( iter.hasNext() ) { if ( ! TLongIntHashMap.this.containsKey( iter.next() ) ) { return false; } } return true; }