/** {@inheritDoc} */ public int[] keys() { int[] keys = new int[size()]; int[] 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 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; }
public int size() { return data.size(); }
/** {@inheritDoc} */ public float[] values( float[] array ) { int size = size(); if ( array.length < size ) { array = new float[size]; } float[] v = _values; byte[] states = _states; for ( int i = v.length, j = 0; i-- > 0; ) { if ( states[i] == FULL ) { array[j++] = v[i]; } } return array; }
/** {@inheritDoc} */ public int[] keys( int[] array ) { int size = size(); if ( array.length < size ) { array = new int[size]; } int[] keys = _set; byte[] states = _states; for ( int i = keys.length, j = 0; i-- > 0; ) { if ( states[i] == FULL ) { array[j++] = keys[i]; } } return array; }
/** {@inheritDoc} */ @Override public boolean equals( Object other ) { if ( ! ( other instanceof TIntFloatMap ) ) { return false; } TIntFloatMap that = ( TIntFloatMap ) 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 ) { int 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; }
if(sv.size() < data.size()){ TIntFloatIterator it = sv.data.iterator(); while(it.hasNext()){
/** * 点积 v.*sv * @param sv * @return */ public float dotProduct(HashSparseVector sv) { float v =0f; if(sv.size() < data.size()){ TIntFloatIterator it = sv.data.iterator(); while(it.hasNext()){ it.advance(); v += data.get(it.key())*it.value(); } }else{ TIntFloatIterator it = data.iterator(); while(it.hasNext()){ it.advance(); v += sv.data.get(it.key())*it.value(); } } return v; }
/** {@inheritDoc} */ public int[] keys() { int[] keys = new int[size()]; int[] 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 int[] keys() { int[] keys = new int[size()]; int[] 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 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} */ @Override 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 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; }
@Override public int used() { return data.size(); }
/** {@inheritDoc} */ @Override public int[] keys() { int[] keys = new int[size()]; int[] 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 int[] keys( int[] array ) { int size = size(); if ( array.length < size ) { array = new int[size]; } int[] keys = _set; byte[] states = _states; for ( int i = keys.length, j = 0; i-- > 0; ) { if ( states[i] == FULL ) { array[j++] = keys[i]; } } return array; }
/** {@inheritDoc} */ public float[] values( float[] array ) { int size = size(); if ( array.length < size ) { array = new float[size]; } float[] v = _values; byte[] states = _states; for ( int i = v.length, j = 0; i-- > 0; ) { if ( states[i] == FULL ) { array[j++] = v[i]; } } return array; }
/** {@inheritDoc} */ public int[] keys() { int[] keys = new int[size()]; if ( keys.length == 0 ) { return keys; // nothing to copy } int[] 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 float[] values() { float[] vals = new float[size()]; if ( vals.length == 0 ) { return vals; // nothing to copy } 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; }
@Override public SparseFloatArray reverse() { //TODO: this could be more efficient and avoid the copy TIntFloatHashMap tmp = new TIntFloatHashMap(data.size()); for (Entry e : entries()) tmp.put(length - e.index, e.value); this.data = tmp; return this; } }