public boolean containsKey( int key ) { synchronized( mutex ) { return m.containsKey( key ); } } public boolean containsValue( float value ){
public boolean containsKey( int key ) { return m.containsKey( key ); } public boolean containsValue( float val ) { return m.containsValue( val ); }
/** * 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 Integer && _map.containsKey( unwrapKey( key ) ); }
@Override public boolean containsKey( int key ) { synchronized( mutex ) { return m.containsKey( key ); } } @Override
public boolean containsKey( int key ) { synchronized( mutex ) { return m.containsKey( key ); } } public boolean containsValue( float value ){
public boolean containsKey( int key ) { synchronized( mutex ) { return m.containsKey( key ); } } public boolean containsValue( float value ){
public boolean containsKey( int key ) { synchronized( mutex ) { return m.containsKey( key ); } } public boolean containsValue( float value ){
public boolean containsKey( int key ) { return m.containsKey( key ); } public boolean containsValue( float val ) { return m.containsValue( val ); }
@Override public boolean containsKey( int key ) { return m.containsKey( key ); } @Override
public boolean containsKey( int key ) { return m.containsKey( key ); } public boolean containsValue( float val ) { return m.containsValue( val ); }
public boolean containsKey( int key ) { return m.containsKey( key ); } public boolean containsValue( float val ) { return m.containsValue( val ); }
/** * 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 Integer && _map.containsKey( unwrapKey( key ) ); }
/** * 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 */ @Override public boolean containsKey( Object key ) { if ( key == null ) return _map.containsKey( _map.getNoEntryKey() ); return key instanceof Integer && _map.containsKey( unwrapKey( key ) ); }
/** * 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 Integer && _map.containsKey( unwrapKey( key ) ); }
/** * 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 Integer && _map.containsKey( unwrapKey( key ) ); }
public static double cosineSimilarity(TIntFloatMap X, TIntFloatMap Y) { double xDotX = 0.0; double yDotY = 0.0; double xDotY = 0.0; for (int id : X.keys()) { double x = X.get(id); xDotX += x * x; if (Y.containsKey(id)) { xDotY += x * Y.get(id); } } for (double y : Y.values()) { yDotY += y * y; } return xDotX * yDotY != 0 ? xDotY / Math.sqrt(xDotX * yDotY): 0.0; }
/** * Deletes a key/value pair from the map. * * @param key an <code>Object</code> value * @return the removed value, or null if it was not found in the map */ @Override public Float remove( Object key ) { if (! (key instanceof Integer ) ) { return null; } int k = unwrapKey( key ); if ( _map.containsKey( k ) ) { float v = _map.remove( k ); return wrapValue( v ); } return null; }
/** * 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. */ @Override public Float get( Object key ) { if (! ( key instanceof Integer ) ) { return null; } int k = unwrapKey( key ); float v = _map.get( k ); if (v == _map.getNoEntryValue() && !_map.containsKey( k ) ) { return null; } return wrapValue( v ); }
/** * 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 Float(0) if none was found. */ @Override public Float put( Integer key, Float value ) { int k = unwrapKey( key ); float v = unwrapValue( value ); if ( _map.containsKey( k ) ) { float retval = _map.put( k, v ); return wrapValue( retval); } _map.put( k, v ); return null; }
public double compare( TIntFloatMap v1, TIntFloatMap v2, boolean sorted) { int overlaps = 0; TIntIterator iter = v1.keySet().iterator(); while (iter.hasNext()) { int key = iter.next(); if (v2.containsKey(key)) overlaps++; } return overlaps / (double)(v1.size() + v2.size() - overlaps); }