本文整理匯總了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());
}
示例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());
}
示例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();
}
}
示例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();
}
示例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());
}
示例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();
}
示例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());
}
示例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();
}
示例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);
}