/** {@inheritDoc} */ public void putAll( Map<? extends Long, ? extends Float> map ) { ensureCapacity( map.size() ); // could optimize this for cases when map instanceof THashMap for ( Map.Entry<? extends Long, ? extends Float> entry : map.entrySet() ) { this.put( entry.getKey().longValue(), entry.getValue().floatValue() ); } }
public SparseMatrix(){ vector = new TLongFloatHashMap(100,0.8f); }
/** {@inheritDoc} */ public boolean containsAll( float[] array ) { for ( float element : array ) { if ( ! TLongFloatHashMap.this.containsValue( element ) ) { return false; } } return true; }
/** {@inheritDoc} */ public boolean containsAll( long[] array ) { for ( long element : array ) { if ( ! TLongFloatHashMap.this.contains( element ) ) { return false; } } return true; }
/** {@inheritDoc} */ public boolean containsAll( Collection<?> collection ) { for ( Object element : collection ) { if ( element instanceof Long ) { long ele = ( ( Long ) element ).longValue(); if ( ! TLongFloatHashMap.this.containsKey( ele ) ) { return false; } } else { return false; } } return true; }
/** {@inheritDoc} */ public void clear() { TLongFloatHashMap.this.clear(); }
/** {@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(); float val = in.readFloat(); put(key, val); } } } // TLongFloatHashMap
/** {@inheritDoc} */ @Override public boolean equals( Object other ) { if ( ! ( other instanceof TLongFloatMap ) ) { return false; } TLongFloatMap that = ( TLongFloatMap ) other; if ( that.size() != this.size() ) { return false; } float[] values = _values; byte[] states = _states; float this_no_entry_value = getNoEntryValue(); float that_no_entry_value = that.getNoEntryValue(); for ( int i = values.length; i-- > 0; ) { if ( states[i] == FULL ) { long key = _set[i]; float that_value = that.get( key ); float 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; }
/** {@inheritDoc} */ public float[] values() { float[] vals = new float[size()]; float[] v = _values; byte[] states = _states; for ( int i = v.length, j = 0; i-- > 0; ) { if ( states[i] == FULL ) { vals[j++] = v[i]; } } return vals; }
/** {@inheritDoc} */ public boolean increment( long key ) { return adjustValue( key, ( float ) 1 ); }
public void set(long index, float value) { vector.put(index, value); }
/** {@inheritDoc} */ public float putIfAbsent( long key, float value ) { int index = insertionIndex( key ); if (index < 0) return _values[-index - 1]; return doPut( key, value, index ); }
/** {@inheritDoc} */ public boolean contains( float entry ) { return TLongFloatHashMap.this.containsValue( entry ); }
/** {@inheritDoc} */ public boolean contains( long entry ) { return TLongFloatHashMap.this.contains( entry ); }
/** {@inheritDoc} */ public boolean containsAll( TLongCollection collection ) { TLongIterator iter = collection.iterator(); while ( iter.hasNext() ) { if ( ! TLongFloatHashMap.this.containsKey( iter.next() ) ) { return false; } } return true; }