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


Java TreeRangeMap.create方法代码示例

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


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

示例1: MutableDistribution

import com.google.common.collect.TreeRangeMap; //导入方法依赖的package包/类
/** Constructs an empty Distribution with the specified {@link DistributionFitter}. */
public MutableDistribution(DistributionFitter distributionFitter) {
  this.distributionFitter = checkNotNull(distributionFitter);
  ImmutableSortedSet<Double> boundaries = distributionFitter.boundaries();

  checkArgument(boundaries.size() > 0);
  checkArgument(Ordering.natural().isOrdered(boundaries));

  this.intervalCounts = TreeRangeMap.create();

  double[] boundariesArray = Doubles.toArray(distributionFitter.boundaries());

  // Add underflow and overflow intervals
  this.intervalCounts.put(Range.lessThan(boundariesArray[0]), 0L);
  this.intervalCounts.put(Range.atLeast(boundariesArray[boundariesArray.length - 1]), 0L);

  // Add finite intervals
  for (int i = 1; i < boundariesArray.length; i++) {
    this.intervalCounts.put(Range.closedOpen(boundariesArray[i - 1], boundariesArray[i]), 0L);
  }
}
 
开发者ID:google,项目名称:java-monitoring-client-library,代码行数:22,代码来源:MutableDistribution.java

示例2: parseDiscretize

import com.google.common.collect.TreeRangeMap; //导入方法依赖的package包/类
static
private RangeMap<Double, String> parseDiscretize(Discretize discretize){
	RangeMap<Double, String> result = TreeRangeMap.create();

	List<DiscretizeBin> discretizeBins = discretize.getDiscretizeBins();
	for(DiscretizeBin discretizeBin : discretizeBins){
		Interval interval = discretizeBin.getInterval();
		if(interval == null){
			throw new MissingAttributeException(discretizeBin, PMMLAttributes.DISCRETIZEBIN_INTERVAL);
		}

		Range<Double> range = toRange(interval);

		String binValue = discretizeBin.getBinValue();
		if(binValue == null){
			throw new MissingAttributeException(discretizeBin, PMMLAttributes.DISCRETIZEBIN_BINVALUE);
		}

		result.put(range, binValue);
	}

	return result;
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:24,代码来源:DiscretizationUtil.java

示例3: main

import com.google.common.collect.TreeRangeMap; //导入方法依赖的package包/类
public static void main(String[] args) {

		// define rages for checks
		RangeMap<Integer, Double> checkFee = TreeRangeMap.create();
		checkFee.put(Range.closed(0, 19), .1);
		checkFee.put(Range.closed(20, 39), .8);
		checkFee.put(Range.closed(40, 59), .6);
		checkFee.put(Range.closed(60, Integer.MAX_VALUE), .4);

		// Create a Scanner object for keyboard input.
		Scanner keyboard = new Scanner(System.in);

		// Get the number of checks written.
		System.out.print("Enter the number of checks written " + "this month: ");
		int numChecks = keyboard.nextInt();

		//close scanner
		keyboard.close();

		// calculate total fee
		double total = BASE_FEE + (checkFee.get(numChecks) * numChecks); 
		
		// Display the total bank fees.
		System.out.printf("The total fees are $%.2f\n", total);
	}
 
开发者ID:leveluplunch,项目名称:levelup-java-exercises,代码行数:26,代码来源:BankCharges.java

示例4: RegionCache

import com.google.common.collect.TreeRangeMap; //导入方法依赖的package包/类
public RegionCache(ReadOnlyPDClient pdClient) {
  regionCache = new HashMap<>();
  storeCache = new HashMap<>();

  keyToRegionIdCache = TreeRangeMap.create();
  this.pdClient = pdClient;
}
 
开发者ID:pingcap,项目名称:tikv-client-lib-java,代码行数:8,代码来源:RegionManager.java

示例5: finalizeSheet

import com.google.common.collect.TreeRangeMap; //导入方法依赖的package包/类
/**
 * Finalise la création de la feuille de calcul, notamment en demandant le
 * redimensionnement automatique des colonnes.
 * 
 * @param sheet feuilles de calcul
 * @param columnInfos collection contenant les informations de colonnes
 * @param landscapePrintSetup définit si la feuille est imprimée en paysage ou non
 */
protected void finalizeSheet(Sheet sheet, Collection<ColumnInformation> columnInfos, boolean landscapePrintSetup) {
	RangeMap<Integer, ColumnInformation> map = TreeRangeMap.create();
	int index = 0;
	for (ColumnInformation column : columnInfos) {
		map.put(Range.singleton(index), column);
		++index;
	}
	finalizeSheet(sheet, map, landscapePrintSetup);
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:18,代码来源:AbstractExcelTableExport.java

示例6: setDynamismLevels

import com.google.common.collect.TreeRangeMap; //导入方法依赖的package包/类
/**
 * Sets the dynamism levels.
 * @param levels At least one level must be given. The default level is
 *          <code>.5</code>.
 * @return This, as per the builder pattern.
 */
public Builder setDynamismLevels(Iterable<Double> levels) {
  checkArgument(Iterables.size(levels) > 0);
  final RangeSet<Double> rangeSet = TreeRangeSet.create();
  final Set<Range<Double>> dynamismLevelsB = new LinkedHashSet<>();
  final RangeMap<Double, Double> map = TreeRangeMap.create();
  for (final Double d : levels) {
    checkArgument(d >= 0d && d <= 1d);
    final Range<Double> newRange = createDynRange(d);
    checkArgument(
      rangeSet.subRangeSet(newRange).isEmpty(),
      "Can not add dynamism level %s, it is too close to another level.",
      d);
    rangeSet.add(newRange);
    dynamismLevelsB.add(newRange);
    map.put(newRange, d);
  }

  final SetMultimap<TimeSeriesType, Range<Double>> timeSeriesTypes =
    LinkedHashMultimap
      .<TimeSeriesType, Range<Double>>create();

  for (final Range<Double> r : dynamismLevelsB) {
    checkArgument(DYNAMISM_MAP.get(r.lowerEndpoint()) != null);
    checkArgument(DYNAMISM_MAP.get(r.lowerEndpoint()) == DYNAMISM_MAP.get(r
      .upperEndpoint()));

    timeSeriesTypes.put(DYNAMISM_MAP.get(r.lowerEndpoint()), r);
  }
  dynamismLevels = ImmutableSetMultimap.copyOf(timeSeriesTypes);
  dynamismRangeMap = ImmutableRangeMap.copyOf(map);
  return this;
}
 
开发者ID:rinde,项目名称:pdptw-dataset-generator,代码行数:39,代码来源:DatasetGenerator.java

示例7: DescriptionBasedDiff

import com.google.common.collect.TreeRangeMap; //导入方法依赖的package包/类
private DescriptionBasedDiff(JCCompilationUnit compilationUnit) {
  this.compilationUnit = checkNotNull(compilationUnit);
  this.sourcePath = compilationUnit.getSourceFile().toUri().getPath();
  this.importsToAdd = new HashSet<>();
  this.importsToRemove = new HashSet<>();
  this.endPosMap = JDKCompatible.getEndPosMap(compilationUnit);
  this.replacements = TreeRangeMap.create();
}
 
开发者ID:sivakumar-kailasam,项目名称:refactor-faster,代码行数:9,代码来源:DescriptionBasedDiff.java

示例8: buildReplacements

import com.google.common.collect.TreeRangeMap; //导入方法依赖的package包/类
/** Construct replacements to fix unused imports. */
private static RangeMap<Integer, String> buildReplacements(
    String contents,
    JCCompilationUnit unit,
    Set<String> usedNames,
    Multimap<String, Range<Integer>> usedInJavadoc) {
  RangeMap<Integer, String> replacements = TreeRangeMap.create();
  for (JCImport importTree : unit.getImports()) {
    String simpleName = getSimpleName(importTree);
    if (!isUnused(unit, usedNames, usedInJavadoc, importTree, simpleName)) {
      continue;
    }
    // delete the import
    int endPosition = importTree.getEndPosition(unit.endPositions);
    endPosition = Math.max(CharMatcher.isNot(' ').indexIn(contents, endPosition), endPosition);
    String sep = Newlines.guessLineSeparator(contents);
    if (endPosition + sep.length() < contents.length()
        && contents.subSequence(endPosition, endPosition + sep.length()).equals(sep)) {
      endPosition += sep.length();
    }
    replacements.put(Range.closedOpen(importTree.getStartPosition(), endPosition), "");
    // fully qualify any javadoc references with the same simple name as a deleted
    // non-static import
    if (!importTree.isStatic()) {
      for (Range<Integer> docRange : usedInJavadoc.get(simpleName)) {
        if (docRange == null) {
          continue;
        }
        String replaceWith = importTree.getQualifiedIdentifier().toString();
        replacements.put(docRange, replaceWith);
      }
    }
  }
  return replacements;
}
 
开发者ID:google,项目名称:google-java-format,代码行数:36,代码来源:RemoveUnusedImports.java

示例9: parsePartitions

import com.google.common.collect.TreeRangeMap; //导入方法依赖的package包/类
/**
 * Create {@link HomRefBlock}s which will collectively accept variants of any genotype quality
 *
 * Each individual block covers a band of genotype qualities with the splits between bands occurring at values in {@code gqPartitions}.
 * There will be {@code gqPartitions.size() +1} bands produced covering the entire possible range of genotype qualities from 0 to {@link VCFConstants#MAX_GENOTYPE_QUAL}.
 *
 * @param gqPartitions proposed GQ partitions
 * @return a list of HomRefBlocks accepting bands of genotypes qualities split at the points specified in gqPartitions
 */
@VisibleForTesting
static RangeMap<Integer,Range<Integer>> parsePartitions(final List<Integer> gqPartitions) {
    Utils.nonEmpty(gqPartitions);
    Utils.containsNoNull(gqPartitions, "The list of GQ partitions contains a null integer");
    final RangeMap<Integer, Range<Integer>> result = TreeRangeMap.create();
    int lastThreshold = 0;
    for (final Integer value : gqPartitions) {
        if (value < 0) {
            throw new IllegalArgumentException("The list of GQ partitions contains a non-positive integer.");
        } else if (value > MAX_GENOTYPE_QUAL + 1) {
            throw new IllegalArgumentException(String.format("The value %d in the list of GQ partitions is greater than VCFConstants.MAX_GENOTYPE_QUAL + 1 = %d.", value, MAX_GENOTYPE_QUAL + 1));
        } else if (value < lastThreshold) {
            throw new IllegalArgumentException(String.format("The list of GQ partitions is out of order. Previous value is %d but the next is %d.", lastThreshold, value));
        } else if (value == lastThreshold) {
            throw new IllegalArgumentException(String.format("The value %d appears more than once in the list of GQ partitions.", value));
        }

        result.put(Range.closedOpen(lastThreshold, value), Range.closedOpen(lastThreshold, value));
        lastThreshold = value;
    }

    if (lastThreshold <= MAX_GENOTYPE_QUAL) {
        result.put(Range.closedOpen(lastThreshold, MAX_GENOTYPE_QUAL + 1), Range.closedOpen(lastThreshold,MAX_GENOTYPE_QUAL + 1));
    }

    return result;
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:37,代码来源:GVCFWriter.java

示例10: google_guava_range_map_example

import com.google.common.collect.TreeRangeMap; //导入方法依赖的package包/类
@Test
public void google_guava_range_map_example () {

	RangeMap<Integer, String> gradeScale = TreeRangeMap.create();
	gradeScale.put(Range.closed(0, 60), "F");
	gradeScale.put(Range.closed(61, 70), "D");
	gradeScale.put(Range.closed(71, 80), "C");
	gradeScale.put(Range.closed(81, 90), "B");
	gradeScale.put(Range.closed(91, 100), "A");
	
	String grade = gradeScale.get(77);
	
	assertEquals("C", grade);
}
 
开发者ID:wq19880601,项目名称:java-util-examples,代码行数:15,代码来源:RangeMapExample.java

示例11: setUp

import com.google.common.collect.TreeRangeMap; //导入方法依赖的package包/类
@Before
 public void setUp() {
actual = TreeRangeMap.create();
actual.put(Range.closedOpen(380, 450), "violet");
actual.put(Range.closedOpen(450, 495), "blue");
actual.put(Range.closedOpen(495, 570), "green");
actual.put(Range.closedOpen(570, 590), "yellow");
actual.put(Range.closedOpen(590, 620), "orange");
actual.put(Range.closedOpen(620, 750), "red");
 }
 
开发者ID:joel-costigliola,项目名称:assertj-guava,代码行数:11,代码来源:RangeMapAssertBaseTest.java

示例12: MetricRetention

import com.google.common.collect.TreeRangeMap; //导入方法依赖的package包/类
private MetricRetention(Pattern pattern, String function) {
    this.pattern = pattern;
    this.function = function;
    this.ranges = TreeRangeMap.create();
}
 
开发者ID:yandex,项目名称:graphouse,代码行数:6,代码来源:MetricRetention.java

示例13: reorderModifiers

import com.google.common.collect.TreeRangeMap; //导入方法依赖的package包/类
/**
 * Reorders all modifiers in the given text and within the given character ranges to be in JLS
 * order.
 */
static JavaInput reorderModifiers(JavaInput javaInput, Collection<Range<Integer>> characterRanges)
        throws FormatterException {
    if (javaInput.getTokens().isEmpty()) {
        // There weren't any tokens, possible because of a lexing error.
        // Errors about invalid input will be reported later after parsing.
        return javaInput;
    }
    RangeSet<Integer> tokenRanges = javaInput.characterRangesToTokenRanges(characterRanges);
    Iterator<? extends Token> it = javaInput.getTokens().iterator();
    TreeRangeMap<Integer, String> replacements = TreeRangeMap.create();
    while (it.hasNext()) {
        Token token = it.next();
        if (!tokenRanges.contains(token.getTok().getIndex())) {
            continue;
        }
        Modifier mod = asModifier(token);
        if (mod == null) {
            continue;
        }

        List<Token> modifierTokens = new ArrayList<>();
        List<Modifier> mods = new ArrayList<>();

        int begin = token.getTok().getPosition();
        mods.add(mod);
        modifierTokens.add(token);

        int end = -1;
        while (it.hasNext()) {
            token = it.next();
            mod = asModifier(token);
            if (mod == null) {
                break;
            }
            mods.add(mod);
            modifierTokens.add(token);
            end = token.getTok().getPosition() + token.getTok().length();
        }

        if (!Ordering.natural().isOrdered(mods)) {
            Collections.sort(mods);
            StringBuilder replacement = new StringBuilder();
            for (int i = 0; i < mods.size(); i++) {
                if (i > 0) {
                    addTrivia(replacement, modifierTokens.get(i).getToksBefore());
                }
                replacement.append(mods.get(i).toString());
                if (i < (modifierTokens.size() - 1)) {
                    addTrivia(replacement, modifierTokens.get(i).getToksAfter());
                }
            }
            replacements.put(Range.closedOpen(begin, end), replacement.toString());
        }
    }
    return applyReplacements(javaInput, replacements);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:61,代码来源:ModifierOrderer.java

示例14: createRangeMap

import com.google.common.collect.TreeRangeMap; //导入方法依赖的package包/类
/**
 * 以Guava TreeRangeMap实现的, 一段范围的Key指向同一个Value的Map
 */
@SuppressWarnings("rawtypes")
public static <K extends Comparable, V> TreeRangeMap<K, V> createRangeMap() {
	return TreeRangeMap.create();
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:8,代码来源:MapUtil.java

示例15: load

import com.google.common.collect.TreeRangeMap; //导入方法依赖的package包/类
@Override
public RangeMap<RangeValue, String> load(SegmentId segmentId) throws Exception {
  return TreeRangeMap.create();
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:5,代码来源:BlockIndexImpl.java


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