本文整理汇总了Java中com.google.common.collect.ImmutableSortedSet.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableSortedSet.Builder方法的具体用法?Java ImmutableSortedSet.Builder怎么用?Java ImmutableSortedSet.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.ImmutableSortedSet
的用法示例。
在下文中一共展示了ImmutableSortedSet.Builder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getSupportedTypes
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
@Override
public Set<ModelType<? extends PUBLIC>> getSupportedTypes() {
ImmutableSortedSet.Builder<ModelType<? extends PUBLIC>> supportedTypes = ImmutableSortedSet.orderedBy(ModelTypes.<PUBLIC>displayOrder());
for (TypeRegistration<?> registration : registrations.values()) {
if (registration.isConstructible()) {
supportedTypes.add(registration.publicType);
}
}
return supportedTypes.build();
}
示例5: getDeclaredBy
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
public Set<ModelType<?>> getDeclaredBy() {
ImmutableSortedSet.Builder<ModelType<?>> declaredBy = new ImmutableSortedSet.Builder<ModelType<?>>(Ordering.usingToString());
for (PropertyAccessorExtractionContext accessor : accessors.values()) {
for (Method method : accessor.getDeclaringMethods()) {
declaredBy.add(ModelType.declaringType(method));
}
}
return declaredBy.build();
}
示例6: 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();
}
示例7: canNotConstructTypeException
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
private ModelTypeInitializationException canNotConstructTypeException(NodeInitializerContext<?> context) {
ImmutableSortedSet.Builder<ModelType<?>> constructibleTypes = ImmutableSortedSet.orderedBy(ModelTypes.displayOrder());
for (NodeInitializerExtractionStrategy extractor : additionalStrategies) {
for (ModelType<?> constructibleType : extractor.supportedTypes()) {
if (context.getConstraints().isSatisfiedBy(constructibleType)) {
constructibleTypes.add(constructibleType);
}
}
}
return new ModelTypeInitializationException(context, schemaStore, ScalarTypes.TYPES, constructibleTypes.build());
}
示例8: 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();
}
示例9: 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());
}
示例10: toDescriptorSet
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
private <T extends PresortedComparable<T>> SortedSet<T> toDescriptorSet(
Set<? extends KeyedDexItem<T>> set) {
ImmutableSortedSet.Builder<T> builder =
new ImmutableSortedSet.Builder<>(PresortedComparable::slowCompareTo);
for (KeyedDexItem<T> item : set) {
builder.add(item.getKey());
}
return builder.build();
}
示例11: rewriteItems
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
private static <T extends PresortedComparable<T>> ImmutableSortedSet<T> rewriteItems(
Set<T> original, BiFunction<T, DexEncodedMethod, T> rewrite) {
ImmutableSortedSet.Builder<T> builder =
new ImmutableSortedSet.Builder<>(PresortedComparable::slowCompare);
for (T item : original) {
builder.add(rewrite.apply(item, null));
}
return builder.build();
}
示例12: 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();
}
示例13: create
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
@Override
protected List<String> create(String[] elements) {
Comparator<String> comparator = createExplicitComparator(elements);
ImmutableSortedSet.Builder<String> builder = ImmutableSortedSet.orderedBy(comparator);
builder.add(BEFORE_FIRST);
builder.add(elements);
builder.add(AFTER_LAST);
return builder.build().subSet(BEFORE_FIRST_2, AFTER_LAST).asList();
}
示例14: joinInvokedMethods
import com.google.common.collect.ImmutableSortedSet; //导入方法依赖的package包/类
private SortedSet<DexMethod> joinInvokedMethods(Map<DexType, Set<DexMethod>> invokes) {
ImmutableSortedSet.Builder<DexMethod> builder =
new ImmutableSortedSet.Builder<>(PresortedComparable::slowCompare);
invokes.values().forEach(builder::addAll);
return builder.build();
}
示例15: 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);
}