当前位置: 首页>>代码示例>>Java>>正文


Java TIntHashSet.iterator方法代码示例

本文整理汇总了Java中gnu.trove.TIntHashSet.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java TIntHashSet.iterator方法的具体用法?Java TIntHashSet.iterator怎么用?Java TIntHashSet.iterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gnu.trove.TIntHashSet的用法示例。


在下文中一共展示了TIntHashSet.iterator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: save

import gnu.trove.TIntHashSet; //导入方法依赖的package包/类
@Override
public void save(@NotNull DataOutput out, TIntHashSet value) throws IOException {
  out.writeInt(value.size());
  final TIntIterator iterator = value.iterator();
  while (iterator.hasNext()) {
    out.writeInt(iterator.next());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:DetectedFrameworksData.java

示例2: dirichletMultinomialLikelihoodRatio

import gnu.trove.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;
	}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:62,代码来源:Dirichlet.java

示例3: findParametersToRemove

import gnu.trove.TIntHashSet; //导入方法依赖的package包/类
@NotNull
public static TIntArrayList findParametersToRemove(@NotNull PsiMethod method,
                                                   @NotNull final PsiExpression expr,
                                                   @Nullable final PsiExpression[] occurences) {
  final PsiParameter[] parameters = method.getParameterList().getParameters();
  if (parameters.length == 0) return new TIntArrayList();

  PsiMethod[] overridingMethods = OverridingMethodsSearch.search(method, true).toArray(PsiMethod.EMPTY_ARRAY);
  final PsiMethod[] allMethods = ArrayUtil.append(overridingMethods, method);

  final TIntHashSet suspects = new TIntHashSet();
  expr.accept(new JavaRecursiveElementWalkingVisitor() {
    @Override public void visitReferenceExpression(final PsiReferenceExpression expression) {
      super.visitReferenceExpression(expression);
      PsiElement resolved = expression.resolve();
      if (resolved instanceof PsiParameter) {
        int i = ArrayUtil.find(parameters, resolved);
        if (i != -1) {
          suspects.add(i);
        }
      }
    }
  });

  final TIntIterator iterator = suspects.iterator();
  while(iterator.hasNext()) {
    final int paramNum = iterator.next();
    for (PsiMethod psiMethod : allMethods) {
      PsiParameter[] psiParameters = psiMethod.getParameterList().getParameters();
      if (paramNum >= psiParameters.length) continue;
      PsiParameter parameter = psiParameters[paramNum];
      if (!ReferencesSearch.search(parameter, parameter.getResolveScope(), false).forEach(new Processor<PsiReference>() {
        public boolean process(final PsiReference reference) {
          PsiElement element = reference.getElement();
          boolean stillCanBeRemoved = false;
          if (element != null) {
            stillCanBeRemoved = isAncestor(expr, element, false) || PsiUtil.isInsideJavadocComment(getPhysical(element));
            if (!stillCanBeRemoved && occurences != null) {
              for (PsiExpression occurence : occurences) {
                if (isAncestor(occurence, element, false)) {
                  stillCanBeRemoved = true;
                  break;
                }
              }
            }
          }
          if (!stillCanBeRemoved) {
            iterator.remove();
            return false;
          }
         return true;
        }
      })) break;
    }
  }

  return new TIntArrayList(suspects.toArray());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:59,代码来源:Util.java


注:本文中的gnu.trove.TIntHashSet.iterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。