com.google.common.collect.MinMaxPriorityQueue.maximumSize()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中com.google.common.collect.MinMaxPriorityQueue.maximumSize()方法的一些代码示例,展示了MinMaxPriorityQueue.maximumSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MinMaxPriorityQueue.maximumSize()方法的具体详情如下:
包路径:com.google.common.collect.MinMaxPriorityQueue
类名称:MinMaxPriorityQueue
方法名:maximumSize

MinMaxPriorityQueue.maximumSize介绍

[英]Creates and returns a new builder, configured to build MinMaxPriorityQueue instances that are limited to maximumSize elements. Each time a queue grows beyond this bound, it immediately removes its greatest element (according to its comparator), which might be the element that was just added.
[中]创建并返回一个新的生成器,配置为生成限制为maximumSize元素的MinMaxPriorityQueue实例。每次队列增长超过这个界限时,它都会立即删除其最大的元素(根据其比较器),这可能就是刚刚添加的元素。

代码示例

代码示例来源:origin: google/guava

public void testCreation_maximumSize() {
 MinMaxPriorityQueue<Integer> queue = MinMaxPriorityQueue.maximumSize(42).create();
 assertEquals(11, queue.capacity());
 assertEquals(42, queue.maximumSize);
 checkNatural(queue);
}

代码示例来源:origin: google/guava

public void testCreation_maximumSize_withContents() {
 MinMaxPriorityQueue<Integer> queue = MinMaxPriorityQueue.maximumSize(42).create(NUMBERS);
 assertEquals(6, queue.size());
 assertEquals(11, queue.capacity());
 assertEquals(42, queue.maximumSize);
 checkNatural(queue);
}

代码示例来源:origin: dkpro/dkpro-core

/**
 * Returns the n most frequent samples in the distribution. The ordering within in a group of
 * samples with the same frequency is undefined.
 * 
 * @param n
 *            the numer of most frequent samples to return.
 * @return the n most frequent samples in the distribution.
 */
public List<T> getMostFrequentSamples(int n) {
  MinMaxPriorityQueue<TermFreqTuple<T>> topN = MinMaxPriorityQueue.maximumSize(n).create();
  for (T key : this.getKeys()) {
    topN.add(new TermFreqTuple<T>(key, this.getCount(key)));
  }
  
  List<T> topNList = new ArrayList<T>();
  while (!topN.isEmpty()) {
    topNList.add(topN.poll().getKey());
  }
  
  return topNList;
}

代码示例来源:origin: dkpro/dkpro-tc

protected MinMaxPriorityQueue<TermFreqTuple> readIndex() throws ResourceInitializationException
{
  MinMaxPriorityQueue<TermFreqTuple> topN = MinMaxPriorityQueue.maximumSize(getTopN())
      .create();
  try (IndexReader reader = DirectoryReader.open(FSDirectory.open(luceneDir))){
    
    Fields fields = MultiFields.getFields(reader);
    if (fields == null) {
      return topN;
    }
    Terms terms = fields.terms(getFieldName());
    if (terms == null) {
      return topN;
    }
    TermsEnum termsEnum = terms.iterator(null);
    BytesRef text = null;
    while ((text = termsEnum.next()) != null) {
      String term = text.utf8ToString();
      long freq = termsEnum.totalTermFreq();
      if (passesScreening(term)) {
        topN.add(new TermFreqTuple(term, freq));
      }
    }
    reader.close();
  }
  catch (Exception e) {
    throw new ResourceInitializationException(e);
  }
  return topN;
}

代码示例来源:origin: dkpro/dkpro-tc

MinMaxPriorityQueue<TermFreqTuple> topN = MinMaxPriorityQueue.maximumSize(topNgramThreshold)
    .create();
IndexReader reader;

代码示例来源:origin: com.google.guava/guava-tests

public void testCreation_maximumSize() {
 MinMaxPriorityQueue<Integer> queue = MinMaxPriorityQueue
   .maximumSize(42)
   .create();
 assertEquals(11, queue.capacity());
 assertEquals(42, queue.maximumSize);
 checkNatural(queue);
}

代码示例来源:origin: dkpro/dkpro-tc

MinMaxPriorityQueue<TermFreqTuple> topN = MinMaxPriorityQueue.maximumSize(topNgramThreshold)
    .create();
IndexReader reader;

代码示例来源:origin: de.tudarmstadt.ukp.dkpro.tc/dkpro-tc-features-ngram

MinMaxPriorityQueue<TermFreqTuple> topN = MinMaxPriorityQueue.maximumSize(getTopN()).create();

代码示例来源:origin: com.google.guava/guava-tests

public void testCreation_maximumSize_withContents() {
 MinMaxPriorityQueue<Integer> queue = MinMaxPriorityQueue
   .maximumSize(42)
   .create(NUMBERS);
 assertEquals(6, queue.size());
 assertEquals(11, queue.capacity());
 assertEquals(42, queue.maximumSize);
 checkNatural(queue);
}

相关文章