本文整理汇总了Java中gnu.trove.map.TIntFloatMap.size方法的典型用法代码示例。如果您正苦于以下问题:Java TIntFloatMap.size方法的具体用法?Java TIntFloatMap.size怎么用?Java TIntFloatMap.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.map.TIntFloatMap
的用法示例。
在下文中一共展示了TIntFloatMap.size方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TIntFloatHashMap
import gnu.trove.map.TIntFloatMap; //导入方法依赖的package包/类
/**
* Creates a new <code>TIntFloatHashMap</code> instance containing
* all of the entries in the map passed in.
*
* @param map a <tt>TIntFloatMap</tt> that will be duplicated.
*/
public TIntFloatHashMap( TIntFloatMap map ) {
super( map.size() );
if ( map instanceof TIntFloatHashMap ) {
TIntFloatHashMap hashmap = ( TIntFloatHashMap ) map;
this._loadFactor = hashmap._loadFactor;
this.no_entry_key = hashmap.no_entry_key;
this.no_entry_value = hashmap.no_entry_value;
//noinspection RedundantCast
if ( this.no_entry_key != ( int ) 0 ) {
Arrays.fill( _set, this.no_entry_key );
}
//noinspection RedundantCast
if ( this.no_entry_value != ( float ) 0 ) {
Arrays.fill( _values, this.no_entry_value );
}
setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
}
putAll( map );
}
示例2: compare
import gnu.trove.map.TIntFloatMap; //导入方法依赖的package包/类
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);
}
示例3: getSortedIndices
import gnu.trove.map.TIntFloatMap; //导入方法依赖的package包/类
public static int[] getSortedIndices(TIntFloatMap vector)
{
// NOTE: it's probably possible to do this using purely primitive
// operations without having to resort to pushing things into an
// Index[]. However, this code is much cleaner to have and since we
// sort at most once per vector and the result is memoized, we don't
// lose too much from the Object-based sorting.
Index[] keyValPairs = new Index[vector.size()];
TIntFloatIterator iter = vector.iterator();
int i = 0;
while (iter.hasNext())
{
iter.advance();
keyValPairs[i++] = new Index(iter.key(), iter.value());
}
Arrays.sort(keyValPairs);
int[] sortedIndices = new int[keyValPairs.length];
for (i = 0; i < keyValPairs.length; ++i)
sortedIndices[i] = keyValPairs[i].key;
return sortedIndices;
}
示例4: normalizeVector
import gnu.trove.map.TIntFloatMap; //导入方法依赖的package包/类
/**
* Normalizes the probability values in a vector so that to sum to 1.0
* @param vector
* @return
*/
public static TIntFloatMap normalizeVector(TIntFloatMap vector)
{
float total = 0;
TFloatIterator iter = vector.valueCollection().iterator();
while (iter.hasNext())
total += iter.next();
TIntFloatMap normalized = new TIntFloatHashMap(vector.size());
TIntFloatIterator iter2 = vector.iterator();
while (iter2.hasNext())
{
iter2.advance();
normalized.put(iter2.key(), iter2.value() / total);
}
return normalized;
}
示例5: equals
import gnu.trove.map.TIntFloatMap; //导入方法依赖的package包/类
/** {@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;
}
示例6: equals
import gnu.trove.map.TIntFloatMap; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
if ( ! ( other instanceof TIntFloatMap ) ) {
return false;
}
TIntFloatMap that = ( TIntFloatMap ) other;
if ( that.size() != this.size() ) {
return false;
}
TFloatOffheapArray values = _values;
TByteOffheapArray states = _states;
float this_no_entry_value = getNoEntryValue();
float that_no_entry_value = that.getNoEntryValue();
for ( int i = capacity(); i-- > 0; ) {
if ( states.get( i ) == FULL ) {
int key = _set.get( i );
float that_value = that.get( key );
float this_value = values.get( i );
if ( ( this_value != that_value ) &&
( this_value != this_no_entry_value ) &&
( that_value != that_no_entry_value ) ) {
return false;
}
}
}
return true;
}