當前位置: 首頁>>代碼示例>>Java>>正文


Java TIntIntHashMap.containsKey方法代碼示例

本文整理匯總了Java中gnu.trove.map.hash.TIntIntHashMap.containsKey方法的典型用法代碼示例。如果您正苦於以下問題:Java TIntIntHashMap.containsKey方法的具體用法?Java TIntIntHashMap.containsKey怎麽用?Java TIntIntHashMap.containsKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gnu.trove.map.hash.TIntIntHashMap的用法示例。


在下文中一共展示了TIntIntHashMap.containsKey方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: notUseAfterLastDef

import gnu.trove.map.hash.TIntIntHashMap; //導入方法依賴的package包/類
private boolean notUseAfterLastDef(int reg,
        MachineBasicBlock mbb,
        int dist,
        TIntIntHashMap distanceMap,
        OutParamWrapper<Integer> lastDef)
{
    lastDef.set(0);
    int lastUse = dist;
    for (DefUseChainIterator itr = mri.getRegIterator(reg); itr.hasNext();)
    {
        MachineOperand mo = itr.getOpearnd();
        MachineInstr mi = itr.getMachineInstr();
        if (!mi.getParent().equals(mbb))
            continue;
        if (!distanceMap.containsKey(mi.index()))
            continue;

        if (mo.isUse() && distanceMap.get(mi.index()) < lastUse)
            lastUse = distanceMap.get(mi.index());
        if (mo.isDef() && distanceMap.get(mi.index()) > lastDef.get())
            lastDef.set(distanceMap.get(mi.index()));
        itr.next();
    }
    return (!(lastUse > lastDef.get() && lastUse < dist));
}
 
開發者ID:JianpingZeng,項目名稱:xcc,代碼行數:26,代碼來源:TwoAddrInstructionPass.java

示例2: isProfitableToReMat

import gnu.trove.map.hash.TIntIntHashMap; //導入方法依賴的package包/類
private boolean isProfitableToReMat(int reg,
        TargetRegisterClass rc,
        MachineInstr mi,
        MachineInstr defMI,
        MachineBasicBlock mbb,
        int loc,
        TIntIntHashMap distanceMap)
{
    boolean otherUse = false;
    for (DefUseChainIterator itr = mri.getUseIterator(reg); itr.hasNext(); )
    {
        MachineOperand useMO = itr.getOpearnd();
        MachineInstr useMI = itr.getMachineInstr();
        MachineBasicBlock useBB = useMI.getParent();
        if (useBB.equals(mbb))
        {
            int idx = useMI.index();
            if (distanceMap.containsKey(idx) && distanceMap.get(idx) == loc)
            {
                otherUse = true;
                if (isTwoAddrUse(useMI, reg))
                    return true;
            }
        }
    }

    if (otherUse)
        return false;

    return mbb.equals(defMI.getParent());
}
 
開發者ID:JianpingZeng,項目名稱:xcc,代碼行數:32,代碼來源:TwoAddrInstructionPass.java

示例3: runOnMachineFunction

import gnu.trove.map.hash.TIntIntHashMap; //導入方法依賴的package包/類
@Override
public boolean runOnMachineFunction(MachineFunction mf)
{
    this.mf = mf;
    ec = new IntEqClasses(mf.getNumBlockIDs()*2);
    for (MachineBasicBlock mbb : mf.getBasicBlocks())
    {
        int outEdge = mbb.getNumber()*2 + 1;
        // Join the outgoing
        for (Iterator<MachineBasicBlock> itr = mbb.succIterator(); itr.hasNext(); )
        {
            ec.join(outEdge, itr.next().getNumber()*2);
        }
    }
    blocks = new TIntArrayList[getNumBundles()];
    for (int i = 0, e; i < getNumBundles(); i++)
        blocks[i] = new TIntArrayList();

    groupID = new TIntIntHashMap();
    for (int i = 0; i < ec.getNumIds(); i++)
    {
        int leading = ec.findLeader(i);
        if (!groupID.containsKey(leading))
            groupID.put(leading, nextID++);
    }

    for (int i = 0, e = mf.getNumBlockIDs(); i < e; i++)
    {
        int b0 = getBundles(i, false);
        int b1 = getBundles(i, true);
        blocks[b0].add(i);
        if (b1 != b0)
            blocks[b1].add(i);
    }
    nextID = 0;
    return false;
}
 
開發者ID:JianpingZeng,項目名稱:xcc,代碼行數:38,代碼來源:EdgeBundles.java

示例4: contains

import gnu.trove.map.hash.TIntIntHashMap; //導入方法依賴的package包/類
public boolean contains(final String groupId, final int timepoint) {
	final TIntIntHashMap countResult = countResults.get(groupId);
	if (countResult == null) {
		return false;
	} else {
		return countResult.containsKey(timepoint);
	}
}
 
開發者ID:pmeisen,項目名稱:dis-timeintervaldataanalyzer,代碼行數:9,代碼來源:CountValuesCollection.java

示例5: buildFeatureVector

import gnu.trove.map.hash.TIntIntHashMap; //導入方法依賴的package包/類
private void buildFeatureVector(int item_id, TIntIntHashMap paths) {

        try {
            double rate = 0;
            double n = 1;
            boolean training = false, validation = false;
            DecimalFormat form = new DecimalFormat("#.####");
            form.setRoundingMode(RoundingMode.CEILING);
            StringBuffer str = new StringBuffer();

            if (trainRatings.containsKey(item_id)) {
                training = true;
                rate = trainRatings.get(item_id);
            } else if (validationRatings.containsKey(item_id)) {
                validation = true;
                rate = validationRatings.get(item_id);
            }

            if (normalize)
                n = norm(paths);

            str.append(rate + " qid:" + user_id + " 1:" + item_id + " ");

            for (int i = 1; i <= path_index.size(); i++) {

                int count = 0;

                if (paths.size() == 1)
                    n = norm(paths);

                if (paths.containsKey(i)) {

                    count = paths.get(i);

                    if (normalize)
                        str.append(i + 1 + ":"
                                + form.format(count / n).replace(",", ".")
                                + " ");
                    else
                        str.append(i + 1 + ":" + count + " ");

                }
            }

            if (training) {
                synchronized (train_file) {
                    train_file.append(str);
                    train_file.newLine();
                }
            } else if (validation) {
                synchronized (validation_file) {
                    validation_file.append(str);
                    validation_file.newLine();
                }
            } else {
                synchronized (test_file) {
                    test_file.append(str);
                    test_file.newLine();
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
開發者ID:sisinflab,項目名稱:lodreclib,代碼行數:66,代碼來源:UserPathExtractorWorker.java

示例6: dirichletMultinomialLikelihoodRatio

import gnu.trove.map.hash.TIntIntHashMap; //導入方法依賴的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:iamxiatian,項目名稱:wikit,代碼行數:62,代碼來源:Dirichlet.java

示例7: dirichletMultinomialLikelihoodRatio

import gnu.trove.map.hash.TIntIntHashMap; //導入方法依賴的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:tweninger,項目名稱:nina,代碼行數:62,代碼來源:Dirichlet.java

示例8: dirichletMultinomialLikelihoodRatio

import gnu.trove.map.hash.TIntIntHashMap; //導入方法依賴的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:hmetaxa,項目名稱:MixLDA,代碼行數:61,代碼來源:Dirichlet.java


注:本文中的gnu.trove.map.hash.TIntIntHashMap.containsKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。