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


Java Collections.frequency方法代码示例

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


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

示例1: calculateRange

import java.util.Collections; //导入方法依赖的package包/类
@Override
public Integer[] calculateRange(String beginValue, String endValue) {
	try {
		int startPartition, endPartition;
		Calendar partitionTime = Calendar.getInstance();
		SimpleDateFormat format = new SimpleDateFormat(dateFormat);
		partitionTime.setTime(format.parse(beginValue));
		startPartition = ((partitionTime.get(Calendar.YEAR) - beginDate.get(Calendar.YEAR))
				* 12 + partitionTime.get(Calendar.MONTH)
				- beginDate.get(Calendar.MONTH));
		partitionTime.setTime(format.parse(endValue));
		endPartition = ((partitionTime.get(Calendar.YEAR) - beginDate.get(Calendar.YEAR))
				* 12 + partitionTime.get(Calendar.MONTH)
				- beginDate.get(Calendar.MONTH));

		List<Integer> list = new ArrayList<>();

		while (startPartition <= endPartition) {
			Integer nodeValue = reCalculatePartition(startPartition);
			if (Collections.frequency(list, nodeValue) < 1)
				list.add(nodeValue);
			startPartition++;
		}
		int size = list.size();
		return (list.toArray(new Integer[size]));
	} catch (ParseException e) {
		LOGGER.error(e);
		return new Integer[0];
	}
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:31,代码来源:PartitionByMonth.java

示例2: isAValidTris

import java.util.Collections; //导入方法依赖的package包/类
/**
 * Checks if <code>chosenCards</code> is a valid tris.
 *
 * @param chosenCards
 * @return
 */
public boolean isAValidTris(String[] chosenCards) {
    for (Card[] validCardArray : deck.getTris().keySet()) {
        boolean success = true;
        for (Card card : validCardArray) {
            /**
             * The tris is valid if and only each cards appears the same
             * number of times in <code>chosenCards</code> as it does in
             * <code>validCardArray</code>.
             */
            success = success && (Collections.frequency(Arrays.asList(deck.getCardsByNames(chosenCards)), card)) == (Collections.frequency(Arrays.asList(validCardArray), card));
        }
        if (success) {
            return success;
        }

    }
    return false;
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-B,代码行数:25,代码来源:CardsPhase.java

示例3: compareResultsForThisListOfStimuli

import java.util.Collections; //导入方法依赖的package包/类
private void compareResultsForThisListOfStimuli() {
  int removes = Collections.frequency(Arrays.asList(stimuli), remove);
  if ((!features.contains(IteratorFeature.SUPPORTS_REMOVE) && removes > 1)
      || (stimuli.length >= 5 && removes > 2)) {
    // removes are the most expensive thing to test, since they often throw exceptions with stack
    // traces, so we test them a bit less aggressively
    return;
  }

  MultiExceptionListIterator reference = new MultiExceptionListIterator(expectedElements);
  I target = newTargetIterator();
  for (int i = 0; i < stimuli.length; i++) {
    try {
      stimuli[i].executeAndCompare(reference, target);
      verify(reference.getElements());
    } catch (AssertionFailedError cause) {
      Helpers.fail(cause, "failed with stimuli " + subListCopy(stimuli, i + 1));
    }
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:21,代码来源:AbstractIteratorTester.java

示例4: test

import java.util.Collections; //导入方法依赖的package包/类
@Override
public int test(Document document) {
    int x[] = new int[vocabulary.size()];
    for (int i = 0; i < x.length; i++) {
        x[i] = Collections.frequency(document.getTerms(), vocabulary.get(i));
    }

    double pr = weights[0];

    for (int i = 1; i <= x.length; i++) {
        pr += (weights[i] * x[i - 1]);
    }

    return (pr > 0) ? Document.Class.HAM : Document.Class.SPAM;
}
 
开发者ID:MarkXLII,项目名称:CS-436_580L_Introduction-to-Machine-Learning,代码行数:16,代码来源:LrModel.java

示例5: constructDataMatrix

import java.util.Collections; //导入方法依赖的package包/类
private int[][] constructDataMatrix(List<Document> trainingDataSet, List<String> vocabulary) {
    int data[][] = new int[trainingDataSet.size()][vocabulary.size() + 2];
    for (int i = 0; i < trainingDataSet.size(); i++) {
        Document document = trainingDataSet.get(i);
        data[i][0] = DUMMY_THRESHOLD;
        for (int j = 1; j <= vocabulary.size(); j++) {
            data[i][j] = Collections.frequency(document.getTerms(), vocabulary.get(j - 1));
        }
        data[i][vocabulary.size() + 1] = document.getDocumentClass();
    }
    return data;
}
 
开发者ID:MarkXLII,项目名称:CS-436_580L_Introduction-to-Machine-Learning,代码行数:13,代码来源:SimplePerceptrons.java

示例6: test

import java.util.Collections; //导入方法依赖的package包/类
@Override
public int test(Document document) {
    int x[] = new int[vocabulary.size()];
    for (int i = 0; i < x.length; i++) {
        x[i] = Collections.frequency(document.getTerms(), vocabulary.get(i));
    }

    double o = weights[0];
    for (int i = 1; i < x.length; i++) {
        o += (x[i - 1] * weights[i]);
    }

    return (o > 0) ? Document.Class.HAM : Document.Class.SPAM;
}
 
开发者ID:MarkXLII,项目名称:CS-436_580L_Introduction-to-Machine-Learning,代码行数:15,代码来源:PerceptronModel.java

示例7: getBonusForTris

import java.util.Collections; //导入方法依赖的package包/类
/**
 * Given a tris of cards it returns the corresponding bonus; if it doesn't
 * find the tris it throws an excption.
 *
 * @param cards
 * @return
 */
public int getBonusForTris(Card[] cards) throws TrisNotFoundException {

    for (Card[] set : tris.keySet()) {
        boolean success = true;
        for (Card card : set) {
            success = success && (Collections.frequency(Arrays.asList(set), card)) == (Collections.frequency(Arrays.asList(cards), card));
        }
        if (success) {
            return tris.get(set);
        }
    }
    throw new TrisNotFoundException();
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-B,代码行数:21,代码来源:BonusDeck.java

示例8: canPlayThisTris

import java.util.Collections; //导入方法依赖的package包/类
/**
 * Tells wheter the player has enough cards to play the tris
 * <code>cards</code>.
 *
 * @param cards
 * @return
 */
public boolean canPlayThisTris(Card[] cards) {

    boolean success = true;
    for (Card card : cards) {
        success = success && (Collections.frequency(bonusCards, card)) >= (Collections.frequency(Arrays.asList(cards), card));
    }
    return success;
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-B,代码行数:16,代码来源:Player.java

示例9: hasFailed

import java.util.Collections; //导入方法依赖的package包/类
private boolean hasFailed() {
    int size = responseHistory.size();
    if (size < HISTORY_SIZE) {
        return false;
    } else if (size > HISTORY_SIZE) {
        logger.warn("Unexpected responseHistory size: {}", size);
        return false;
    } else {
        int occurrences = Collections.frequency(responseHistory, Boolean.FALSE);
        return occurrences >= HISTORY_SIZE;
    }
}
 
开发者ID:Sixt,项目名称:ja-micro,代码行数:13,代码来源:CircuitBreakerState.java

示例10: waitForMotivation

import java.util.Collections; //导入方法依赖的package包/类
private static void waitForMotivation()
{
	int i = SIR_RANDY.nextInt(NONDIMINISHING_RETURNS.size());
	LITTLE_HOUSE_OF_INTS.add(i);
	int ifreq = Collections.frequency(LITTLE_HOUSE_OF_INTS, i);
	if (ifreq >= BOREDOM_CONSTANT)
	{
		i = findMoreMotivation();
		LITTLE_HOUSE_OF_INTS.add(i);
	}

	Object cake = findRandomCake();
	Consumer<Object> consumer = pick(NONDIMINISHING_RETURNS, i);
	consumer.accept(cake);
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:16,代码来源:PomaMotivator.java

示例11: toUniqueFieldNameVariable

import java.util.Collections; //导入方法依赖的package包/类
public static String toUniqueFieldNameVariable(String fieldName, List<String> processedFieldNames) {
    fieldName = fieldName.replaceAll("[^a-zA-Z0-9]", "_");
    int frequency = Collections.frequency(processedFieldNames, fieldName);
    processedFieldNames.add(fieldName);
    return (frequency > 0) ? fieldName + frequency : fieldName;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:TextUtils.java

示例12: isRepeatedData

import java.util.Collections; //导入方法依赖的package包/类
public boolean isRepeatedData(Object data) {
    return Collections.frequency(datas, data) == 1;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:4,代码来源:ListDataCollectorImpl.java

示例13: matchCount

import java.util.Collections; //导入方法依赖的package包/类
public int matchCount(List<String>names_input,String name)
{
	int count=Collections.frequency(names_input,name);
	return count;
}
 
开发者ID:PacktPublishing,项目名称:Reactive-Programming-With-Java-9,代码行数:6,代码来源:DemoImperative.java


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