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


Java ImmutableSortedSet.naturalOrder方法代码示例

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


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

示例1: create

import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
/**
 * Returns a new {@link CustomFitter} with bounds corresponding to the Fibonacci sequence.
 *
 * @param maxBucketSize the maximum bucket size to create (rounded down to the nearest Fibonacci
 *     number)
 * @throws IllegalArgumentException if {@code maxBucketSize <= 0}
 */
public static CustomFitter create(long maxBucketSize) {
  checkArgument(maxBucketSize > 0, "maxBucketSize must be greater than 0");

  ImmutableSortedSet.Builder<Double> boundaries = ImmutableSortedSet.naturalOrder();
  boundaries.add(Double.valueOf(0));
  long i = 1;
  long j = 2;
  long k = 3;
  while (i <= maxBucketSize) {
    boundaries.add(Double.valueOf(i));
    i = j;
    j = k;
    k = i + j;
  }

  return CustomFitter.create(boundaries.build());
}
 
开发者ID:google,项目名称:java-monitoring-client-library,代码行数:25,代码来源:FibonacciFitter.java

示例2: create

import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
/**
 * Create a new {@link ExponentialFitter}.
 *
 * @param numFiniteIntervals the number of intervals, excluding the underflow and overflow
 *     intervals
 * @param base the base of the exponent
 * @param scale a multiplicative factor for the exponential function
 * @throws IllegalArgumentException if {@code numFiniteIntervals <= 0}, {@code width <= 0} or
 *     {@code base <= 1}
 */
public static ExponentialFitter create(int numFiniteIntervals, double base, double scale) {
  checkArgument(numFiniteIntervals > 0, "numFiniteIntervals must be greater than 0");
  checkArgument(scale != 0, "scale must not be 0");
  checkArgument(base > 1, "base must be greater than 1");
  checkDouble(base);
  checkDouble(scale);

  ImmutableSortedSet.Builder<Double> boundaries = ImmutableSortedSet.naturalOrder();

  for (int i = 0; i < numFiniteIntervals + 1; i++) {
    boundaries.add(scale * Math.pow(base, i));
  }

  return new AutoValue_ExponentialFitter(base, scale, boundaries.build());
}
 
开发者ID:google,项目名称:java-monitoring-client-library,代码行数:26,代码来源:ExponentialFitter.java

示例3: ParentChildIndexFieldData

import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
public ParentChildIndexFieldData(Index index, Settings indexSettings, MappedFieldType.Names fieldNames,
                                 FieldDataType fieldDataType, IndexFieldDataCache cache, MapperService mapperService,
                                 CircuitBreakerService breakerService) {
    super(index, indexSettings, fieldNames, fieldDataType, cache);
    this.breakerService = breakerService;
    if (Version.indexCreated(indexSettings).before(Version.V_2_0_0_beta1)) {
        parentTypes = new TreeSet<>();
        for (DocumentMapper documentMapper : mapperService.docMappers(false)) {
            beforeCreate(documentMapper);
        }
        mapperService.addTypeListener(this);
    } else {
        ImmutableSortedSet.Builder<String> builder = ImmutableSortedSet.naturalOrder();
        for (DocumentMapper mapper : mapperService.docMappers(false)) {
            ParentFieldMapper parentFieldMapper = mapper.parentFieldMapper();
            if (parentFieldMapper.active()) {
                builder.add(parentFieldMapper.type());
            }
        }
        parentTypes = builder.build();
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:23,代码来源:ParentChildIndexFieldData.java

示例4: getDisplayNames

import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
/**
 * Returns the sorted, unique display names of the given types.
 */
public static Iterable<String> getDisplayNames(Iterable<? extends ModelType<?>> types) {
    ImmutableSortedSet.Builder<String> builder = ImmutableSortedSet.naturalOrder();
    for (ModelType<?> type : types) {
        builder.add(type.getDisplayName());
    }
    return builder.build();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:11,代码来源:ModelTypes.java

示例5: extractValidator

import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
@Override
public TaskClassValidator extractValidator(Class<? extends Task> type) {
    ImmutableSet.Builder<TaskPropertyInfo> validatedPropertiesBuilder = ImmutableSet.builder();
    ImmutableSet.Builder<String> nonAnnotatedPropertiesBuilder = ImmutableSortedSet.naturalOrder();
    Queue<TypeEntry> queue = new ArrayDeque<TypeEntry>();
    queue.add(new TypeEntry(null, type));
    while (!queue.isEmpty()) {
        TypeEntry entry = queue.remove();
        parseProperties(entry.parent, entry.type, validatedPropertiesBuilder, nonAnnotatedPropertiesBuilder, queue);
    }
    return new TaskClassValidator(validatedPropertiesBuilder.build(), nonAnnotatedPropertiesBuilder.build());
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:13,代码来源:DefaultTaskClassValidatorExtractor.java

示例6: collectFileProperties

import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
public static <T extends TaskFilePropertySpec> SortedSet<T> collectFileProperties(String displayName, Iterator<? extends T> fileProperties) {
    Set<String> names = Sets.newHashSet();
    ImmutableSortedSet.Builder<T> builder = ImmutableSortedSet.naturalOrder();
    while (fileProperties.hasNext()) {
        T propertySpec = fileProperties.next();
        String propertyName = propertySpec.getPropertyName();
        if (!names.add(propertyName)) {
            throw new IllegalArgumentException(String.format("Multiple %s file properties with name '%s'", displayName, propertyName));
        }
        builder.add(propertySpec);
    }
    return builder.build();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:14,代码来源:TaskPropertyUtils.java

示例7: create

import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
/**
 * Create a new {@link LinearFitter}.
 *
 * @param numFiniteIntervals the number of intervals, excluding the underflow and overflow
 *     intervals
 * @param width the width of each interval
 * @param offset the start value of the first interval
 * @throws IllegalArgumentException if {@code numFiniteIntervals <= 0} or {@code width <= 0}
 */
public static LinearFitter create(int numFiniteIntervals, double width, double offset) {
  checkArgument(numFiniteIntervals > 0, "numFiniteIntervals must be greater than 0");
  checkArgument(width > 0, "width must be greater than 0");
  checkDouble(offset);

  ImmutableSortedSet.Builder<Double> boundaries = ImmutableSortedSet.naturalOrder();

  for (int i = 0; i < numFiniteIntervals + 1; i++) {
    boundaries.add(width * i + offset);
  }

  return new AutoValue_LinearFitter(width, offset, boundaries.build());
}
 
开发者ID:google,项目名称:java-monitoring-client-library,代码行数:23,代码来源:LinearFitter.java

示例8: extractPJSpans

import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
private static ImmutableSortedSet<CharOffsetSpan> extractPJSpans(final String part) {
  final ImmutableSortedSet.Builder<CharOffsetSpan> spans = ImmutableSortedSet.naturalOrder();
  for (final String spanString : commaSplitter.split(part.trim())) {
    final List<String> spanParts = ImmutableList.copyOf(dashSplitter.split(spanString));
    checkState(spanParts.size() == 2,
        "Expected two components to the span, but got " + spanParts.size());
    final int start = Integer.parseInt(spanParts.get(0));
    final int end = Integer.parseInt(spanParts.get(1));
    spans.add(CharOffsetSpan.fromOffsetsOnly(start, end));
  }
  return spans.build();
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:13,代码来源:SingleFileQueryAssessmentsLoader.java

示例9: scanImports

import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
/**
 * Scans a sequence of import lines. The parsing uses this approximate grammar:
 * <p>
 * <pre>{@code
 * <imports> -> (<end-of-line> | <import>)*
 * <import> -> "import" <whitespace> ("static" <whitespace>)?
 *    <identifier> ("." <identifier>)* ("." "*")? <whitespace>? ";"
 *    <whitespace>? <line-comment>? <end-of-line>
 * }</pre>
 *
 * @param i the index to start parsing at.
 * @return the result of parsing the imports.
 * @throws FormatterException if imports could not parsed according to the grammar.
 */
private ImportsAndIndex scanImports(int i) throws FormatterException {
    int afterLastImport = i;
    ImmutableSortedSet.Builder<Import> imports = ImmutableSortedSet.naturalOrder();
    // JavaInput.buildToks appends a zero-width EOF token after all tokens. It won't match any
    // of our tests here and protects us from running off the end of the toks list. Since it is
    // zero-width it doesn't matter if we include it in our string concatenation at the end.
    while (i < toks.size() && tokenAt(i).equals("import")) {
        i++;
        if (isSpaceToken(i)) {
            i++;
        }
        boolean isStatic = tokenAt(i).equals("static");
        if (isStatic) {
            i++;
            if (isSpaceToken(i)) {
                i++;
            }
        }
        if (!isIdentifierToken(i)) {
            throw new FormatterException("Unexpected token after import: " + tokenAt(i));
        }
        StringAndIndex imported = scanImported(i);
        String importedName = imported.string;
        i = imported.index;
        if (isSpaceToken(i)) {
            i++;
        }
        if (!tokenAt(i).equals(";")) {
            throw new FormatterException("Expected ; after import");
        }
        while (tokenAt(i).equals(";")) {
            // Extra semicolons are not allowed by the JLS but are accepted by javac.
            i++;
        }
        StringBuilder trailing = new StringBuilder();
        if (isSpaceToken(i)) {
            trailing.append(tokenAt(i));
            i++;
        }
        if (isSlashSlashCommentToken(i)) {
            trailing.append(tokenAt(i));
            i++;
        }
        if (!isNewlineToken(i)) {
            throw new FormatterException("Extra tokens after import: " + tokenAt(i));
        }
        trailing.append(tokenAt(i));
        i++;
        imports.add(new Import(importedName, trailing.toString(), isStatic));
        // Remember the position just after the import we just saw, before skipping blank lines.
        // If the next thing after the blank lines is not another import then we don't want to
        // include those blank lines in the text to be replaced.
        afterLastImport = i;
        while (isNewlineToken(i) || isSpaceToken(i)) {
            i++;
        }
    }
    return new ImportsAndIndex(imports.build(), afterLastImport);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:74,代码来源:ImportOrderer.java


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