本文整理匯總了Java中gnu.trove.set.hash.TIntHashSet.iterator方法的典型用法代碼示例。如果您正苦於以下問題:Java TIntHashSet.iterator方法的具體用法?Java TIntHashSet.iterator怎麽用?Java TIntHashSet.iterator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gnu.trove.set.hash.TIntHashSet
的用法示例。
在下文中一共展示了TIntHashSet.iterator方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: seekOrCreateClazz
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
private Clazz seekOrCreateClazz(final String fullQName, final Application application,
final TIntHashSet objectIds) {
final String[] splittedName = fullQName.split("\\.");
Map<String, Clazz> appCached = clazzCache.get(application);
if (appCached == null) {
appCached = new HashMap<String, Clazz>();
clazzCache.put(application, appCached);
}
Clazz clazz = appCached.get(fullQName);
if (clazz == null) {
clazz = seekrOrCreateClazzHelper(fullQName, splittedName, application, null, 0);
appCached.put(fullQName, clazz);
}
if (objectIds != null) {
final TIntIterator iterator = objectIds.iterator();
while (iterator.hasNext()) {
clazz.getObjectIds().add(iterator.next());
}
clazz.setInstanceCount(clazz.getObjectIds().size());
}
return clazz;
}
示例2: getNeighborsAtRadius
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
public TIntHashSet getNeighborsAtRadius(final int placeIndex, final int radius, final int xSize,
final int ySize, final boolean isTorus) {
final TIntHashSet currentNeigh = new TIntHashSet();
currentNeigh.add(placeIndex);
for ( int i = 0; i < radius; i++ ) {
final TIntHashSet newNeigh = new TIntHashSet();
TIntIterator it = currentNeigh.iterator();
while (it.hasNext()) {
newNeigh.addAll(getNeighborsAtRadius1(it.next(), xSize, ySize, isTorus));
}
currentNeigh.addAll(newNeigh);
}
currentNeigh.remove(placeIndex);
return currentNeigh;
}
示例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: writeTIntMapTIntHashSet
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
public static void writeTIntMapTIntHashSet(String file, TIntObjectHashMap<TIntHashSet> map){
try{
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
TIntObjectIterator<TIntHashSet> it = map.iterator();
StringBuffer str;
while(it.hasNext()){
str = new StringBuffer();
it.advance();
str.append(it.key() + "\t");
TIntHashSet tmp = it.value();
TIntIterator it1 = tmp.iterator();
while(it1.hasNext())
str.append(it1.next() + ",");
writer.append(str.substring(0, str.length()-1));
writer.newLine();
}
writer.flush();
writer.close();
}
catch(Exception e){
e.printStackTrace();
}
}
示例5: 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;
}
示例6: valid
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
public boolean valid(TIntHashSet set, int yp, TIntHashSet set2) {
intersectTest.label = yp;
intersectTest.prevLabel = -1;
boolean isValid = !conflicting(yp) || set2.forEach(intersectTest);
for(TIntIterator iter = set.iterator(); iter.hasNext();) {
if (!isValid) return false;
intersectTest.label = iter.next();
isValid = set2.forEach(intersectTest);
}
return isValid;
}
示例7: formPathLabels
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
public TIntHashSet formPathLabels(TIntHashSet set, int label, TIntHashSet labelsOnPath) {
if (!conflicting(label))
return set;
labelsOnPath.clear();
labelsOnPath.add(canonicalId(label));
for(TIntIterator iter = set.iterator(); iter.hasNext(); labelsOnPath.add(iter.next()));
// labelsOnPath.addAll(set.toArray());
return labelsOnPath;
}
示例8: formPreviousLabel
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
public TIntHashSet formPreviousLabel(TIntHashSet prevLabelsOnPath, TIntHashSet labelsOnPath, int prevLabel) {
labelsOnPath.clear();
for(TIntIterator iter = prevLabelsOnPath.iterator(); iter.hasNext(); labelsOnPath.add(iter.next()));
if (conflicting(prevLabel))
labelsOnPath.add(canonicalId(prevLabel));
return labelsOnPath;
}
示例9: contained
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
public boolean contained(TIntHashSet labelsOnPath, TIntHashSet prevLabels) {
if (labelsOnPath == null) return true;
for(TIntIterator iter = labelsOnPath.iterator(); iter.hasNext();) {
int thisL = iter.next();
if (prevLabels != null && prevLabels.contains(thisL)) continue;
return false;
}
return true;
}
示例10: search
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
public final ISimilarityResults search(long[] query, AbstractSimPQueue pQueue){
int iHashSet = hashSetPool.acquireTIntHashSet();
TIntHashSet objects = hashSetPool.getHashSet(iHashSet);
for(int i=0;i<l;i++){
int key=gs[i].eval(query);
TIntArrayList bucket = tables[i][key];
if ( bucket!= null) {
for(int iE=0; iE<bucket.size(); iE++ ){
int o=bucket.get(iE);
objects.add(o);
}
}
}
for(TIntIterator it = objects.iterator(); it.hasNext(); ){
int oId=it.next();
int o_offset = oId*AbstractBitsObject.nLongs;
int dist=Hamming.distance_offset(query, data, o_offset, nLongs);
pQueue.offer(id[oId], dist);
}
hashSetPool.releaseTIntHashSet(iHashSet);
return pQueue.getResults();
}
示例11: dirichletMultinomialLikelihoodRatio
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
/** What is the probability that these two observations were drawn from
* the same multinomial with symmetric Dirichlet prior alpha, relative
* to the probability that they were drawn from different multinomials
* both drawn from this Dirichlet?
*/
public static double dirichletMultinomialLikelihoodRatio(TIntIntHashMap countsX,
TIntIntHashMap countsY,
double alpha, double alphaSum) {
// The likelihood for one DCM is
// Gamma( alpha_sum ) prod Gamma( alpha + N_i )
// prod Gamma ( alpha ) Gamma ( alpha_sum + N )
// When we divide this by the product of two other DCMs with the same
// alpha parameter, the first term in the numerator cancels with the
// first term in the denominator. Then moving the remaining alpha-only
// term to the numerator, we get
// prod Gamma(alpha) prod Gamma( alpha + X_i + Y_i )
// Gamma (alpha_sum) Gamma( alpha_sum + X_sum + Y_sum )
// ----------------------------------------------------------
// prod Gamma(alpha + X_i) prod Gamma(alpha + Y_i)
// Gamma( alpha_sum + X_sum ) Gamma( alpha_sum + Y_sum )
double logLikelihood = 0.0;
double logGammaAlpha = logGamma(alpha);
int totalX = 0;
int totalY = 0;
int key, x, y;
TIntHashSet distinctKeys = new TIntHashSet();
distinctKeys.addAll(countsX.keys());
distinctKeys.addAll(countsY.keys());
TIntIterator iterator = distinctKeys.iterator();
while (iterator.hasNext()) {
key = iterator.next();
x = 0;
if (countsX.containsKey(key)) {
x = countsX.get(key);
}
y = 0;
if (countsY.containsKey(key)) {
y = countsY.get(key);
}
totalX += x;
totalY += y;
logLikelihood += logGamma(alpha) + logGamma(alpha + x + y)
- logGamma(alpha + x) - logGamma(alpha + y);
}
logLikelihood += logGamma(alphaSum + totalX) + logGamma(alphaSum + totalY)
- logGamma(alphaSum) - logGamma(alphaSum + totalX + totalY);
return logLikelihood;
}
示例12: dirichletMultinomialLikelihoodRatio
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
/** What is the probability that these two observations were drawn from
* the same multinomial with symmetric Dirichlet prior alpha, relative
* to the probability that they were drawn from different multinomials
* both drawn from this Dirichlet?
*/
public static double dirichletMultinomialLikelihoodRatio(TIntIntHashMap countsX,
TIntIntHashMap countsY,
double alpha, double alphaSum) {
// The likelihood for one DCM is
// Gamma( alpha_sum ) prod Gamma( alpha + N_i )
// prod Gamma ( alpha ) Gamma ( alpha_sum + N )
// When we divide this by the product of two other DCMs with the same
// alpha parameter, the first term in the numerator cancels with the
// first term in the denominator. Then moving the remaining alpha-only
// term to the numerator, we get
// prod Gamma(alpha) prod Gamma( alpha + X_i + Y_i )
// Gamma (alpha_sum) Gamma( alpha_sum + X_sum + Y_sum )
// ----------------------------------------------------------
// prod Gamma(alpha + X_i) prod Gamma(alpha + Y_i)
// Gamma( alpha_sum + X_sum ) Gamma( alpha_sum + Y_sum )
double logLikelihood = 0.0;
//double logGammaAlpha = logGamma(alpha);
int totalX = 0;
int totalY = 0;
int key, x, y;
TIntHashSet distinctKeys = new TIntHashSet();
distinctKeys.addAll(countsX.keys());
distinctKeys.addAll(countsY.keys());
TIntIterator iterator = distinctKeys.iterator();
while (iterator.hasNext()) {
key = iterator.next();
x = 0;
if (countsX.containsKey(key)) {
x = countsX.get(key);
}
y = 0;
if (countsY.containsKey(key)) {
y = countsY.get(key);
}
totalX += x;
totalY += y;
logLikelihood += logGamma(alpha) + logGamma(alpha + x + y)
- logGamma(alpha + x) - logGamma(alpha + y);
}
logLikelihood += logGamma(alphaSum + totalX) + logGamma(alphaSum + totalY)
- logGamma(alphaSum) - logGamma(alphaSum + totalX + totalY);
return logLikelihood;
}
示例13: dirichletMultinomialLikelihoodRatio
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
/**
* What is the probability that these two observations were drawn from the
* same multinomial with symmetric Dirichlet prior alpha, relative to the
* probability that they were drawn from different multinomials both drawn
* from this Dirichlet?
*/
public static double dirichletMultinomialLikelihoodRatio(TIntIntHashMap countsX,
TIntIntHashMap countsY,
double alpha, double alphaSum) {
// The likelihood for one DCM is
// Gamma( alpha_sum ) prod Gamma( alpha + N_i )
// prod Gamma ( alpha ) Gamma ( alpha_sum + N )
// When we divide this by the product of two other DCMs with the same
// alpha parameter, the first term in the numerator cancels with the
// first term in the denominator. Then moving the remaining alpha-only
// term to the numerator, we get
// prod Gamma(alpha) prod Gamma( alpha + X_i + Y_i )
// Gamma (alpha_sum) Gamma( alpha_sum + X_sum + Y_sum )
// ----------------------------------------------------------
// prod Gamma(alpha + X_i) prod Gamma(alpha + Y_i)
// Gamma( alpha_sum + X_sum ) Gamma( alpha_sum + Y_sum )
double logLikelihood = 0.0;
double logGammaAlpha = logGamma(alpha);
int totalX = 0;
int totalY = 0;
int key, x, y;
TIntHashSet distinctKeys = new TIntHashSet();
distinctKeys.addAll(countsX.keys());
distinctKeys.addAll(countsY.keys());
TIntIterator iterator = distinctKeys.iterator();
while (iterator.hasNext()) {
key = iterator.next();
x = 0;
if (countsX.containsKey(key)) {
x = countsX.get(key);
}
y = 0;
if (countsY.containsKey(key)) {
y = countsY.get(key);
}
totalX += x;
totalY += y;
logLikelihood += logGamma(alpha) + logGamma(alpha + x + y)
- logGamma(alpha + x) - logGamma(alpha + y);
}
logLikelihood += logGamma(alphaSum + totalX) + logGamma(alphaSum + totalY)
- logGamma(alphaSum) - logGamma(alphaSum + totalX + totalY);
return logLikelihood;
}