本文整理匯總了Java中gnu.trove.set.hash.TIntHashSet.size方法的典型用法代碼示例。如果您正苦於以下問題:Java TIntHashSet.size方法的具體用法?Java TIntHashSet.size怎麽用?Java TIntHashSet.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gnu.trove.set.hash.TIntHashSet
的用法示例。
在下文中一共展示了TIntHashSet.size方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: jaccardIndex
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
public static double jaccardIndex(TIntHashSet a, TIntHashSet b) {
TIntHashSet union = new TIntHashSet(a);
union.addAll(b);
// count up intersection:
AtomicInteger count = new AtomicInteger();
a.forEach(x -> {
if(b.contains(x)) {
count.incrementAndGet();
}
return true;
});
double unionSize = union.size();
double isectSize = count.get();
return isectSize / unionSize;
}
示例2: removeFilteredFluorophores
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
/**
* Remove all fluorophores which were not drawn
*
* @param fluorophores
* @param localisations
* @return
*/
private List<? extends FluorophoreSequenceModel> removeFilteredFluorophores(
List<? extends FluorophoreSequenceModel> fluorophores, List<LocalisationModel> localisations)
{
if (fluorophores == null)
return null;
// movingMolecules will be created with an initial capacity to hold all the unique IDs
TIntHashSet idSet = new TIntHashSet((movingMolecules != null) ? movingMolecules.capacity() : 0);
for (LocalisationModel l : localisations)
idSet.add(l.getId());
List<FluorophoreSequenceModel> newFluorophores = new ArrayList<FluorophoreSequenceModel>(idSet.size());
for (FluorophoreSequenceModel f : fluorophores)
{
if (idSet.contains(f.getId()))
newFluorophores.add(f);
}
return newFluorophores;
}
示例3: cmpCosineSim
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
private float cmpCosineSim(TIntFloatHashMap v1, TIntFloatHashMap v2) {
TIntHashSet inters = new TIntHashSet();
inters.addAll(v1.keySet());
inters.retainAll(v2.keySet());
if (inters.size() == 0)
return 0;
else {
int i = 0;
TIntIterator it = inters.iterator();
float num = 0;
float norm_v1 = 0;
float norm_v2 = 0;
while (it.hasNext()) {
i = it.next();
num += v1.get(i) * v2.get(i);
}
for (int k1 : v1.keys())
norm_v1 += (v1.get(k1) * v1.get(k1));
for (int k2 : v2.keys())
norm_v2 += (v2.get(k2) * v2.get(k2));
return num / (float) (Math.sqrt(norm_v1) * Math.sqrt(norm_v2));
}
}
示例4: simJaccard
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
public double simJaccard(TIntHashSet s1, TIntHashSet s2) {
int com = 0;
if(s1==null||s2==null)
return 0;
TIntIterator it = s1.iterator();
for ( int i = s1.size(); i-- > 0; ) {
int v = it.next();
if(s2.contains(v))
com++;
}
double sim = com*1.0/(s1.size()+s2.size()-com);
return sim;
}