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


Java RangeMap.get方法代码示例

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


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

示例1: main

import com.google.common.collect.RangeMap; //导入方法依赖的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

示例2: chooseShuffledMaterial

import com.google.common.collect.RangeMap; //导入方法依赖的package包/类
MaterialData chooseShuffledMaterial() {
    ImmutableRangeMap.Builder<Double, MaterialData> weightsBuilder = ImmutableRangeMap.builder();
    double sum = 0d;
    for(MaterialData material : shuffleableMaterialDeficit.materials()) {
        double weight = shuffleableMaterialDeficit.get(material);
        if(weight > 0) {
            weightsBuilder.put(Range.closedOpen(sum, sum + weight), material);
            sum += weight;
        }
    }
    RangeMap<Double, MaterialData> weights = weightsBuilder.build();
    return weights.get(match.getRandom().nextDouble() * sum);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:14,代码来源:Renewable.java

示例3: get

import com.google.common.collect.RangeMap; //导入方法依赖的package包/类
public V get(int index) { //indent:2 exp:2
  K key = null; //indent:4 exp:4
  int len = 0; //indent:4 exp:4
  checkElementIndex(index, len); //indent:4 exp:4
  int off; //indent:4 exp:4
  RangeMap<K, V> ranges = null; //indent:4 exp:4
  if (index == 0 || index == len - 1) { //indent:4 exp:4
    Object range; //indent:6 exp:6
    return ranges.get(key); //indent:6 exp:6
  } else { //indent:4 exp:4
    return ranges.get(key); //indent:6 exp:6
  } //indent:4 exp:4
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:14,代码来源:InputIndentationFromGuava2.java

示例4: Opcodes

import com.google.common.collect.RangeMap; //导入方法依赖的package包/类
private Opcodes(int api, int artVersion, boolean experimental) {
    this.api = api;
    this.artVersion = artVersion;

    opcodeValues = new EnumMap<Opcode, Short>(Opcode.class);
    opcodesByName = Maps.newHashMap();

    int version;
    if (isArt()) {
        version = artVersion;
    } else {
        version = api;
    }

    for (Opcode opcode: Opcode.values()) {
        RangeMap<Integer, Short> versionToValueMap;

        if (isArt()) {
            versionToValueMap = opcode.artVersionToValueMap;
        } else {
            versionToValueMap = opcode.apiToValueMap;
        }

        Short opcodeValue = versionToValueMap.get(version);
        if (opcodeValue != null && (!opcode.isExperimental() || experimental)) {
            if (!opcode.format.isPayloadFormat) {
                opcodesByValue[opcodeValue] = opcode;
            }
            opcodeValues.put(opcode, opcodeValue);
            opcodesByName.put(opcode.name.toLowerCase(), opcode);
        }
    }
}
 
开发者ID:johnlee175,项目名称:dex,代码行数:34,代码来源:Opcodes.java

示例5: google_guava_range_map_example

import com.google.common.collect.RangeMap; //导入方法依赖的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

示例6: Opcodes

import com.google.common.collect.RangeMap; //导入方法依赖的package包/类
private Opcodes(int api, int artVersion) {


        if (api >= 21) {
            this.api = api;
            this.artVersion = mapApiToArtVersion(api);
        } else if (artVersion >= 0 && artVersion < 39) {
            this.api = mapArtVersionToApi(artVersion);
            this.artVersion = artVersion;
        } else {
            this.api = api;
            this.artVersion = artVersion;
        }

        opcodeValues = new EnumMap<Opcode, Short>(Opcode.class);
        opcodesByName = Maps.newHashMap();

        int version;
        if (isArt()) {
            version = this.artVersion;
        } else {
            version = this.api;
        }

        for (Opcode opcode: Opcode.values()) {
            RangeMap<Integer, Short> versionToValueMap;

            if (isArt()) {
                versionToValueMap = opcode.artVersionToValueMap;
            } else {
                versionToValueMap = opcode.apiToValueMap;
            }

            Short opcodeValue = versionToValueMap.get(version);
            if (opcodeValue != null) {
                if (!opcode.format.isPayloadFormat) {
                    opcodesByValue[opcodeValue] = opcode;
                }
                opcodeValues.put(opcode, opcodeValue);
                opcodesByName.put(opcode.name.toLowerCase(), opcode);
            }
        }
    }
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:44,代码来源:Opcodes.java

示例7: getSpeedLimit

import com.google.common.collect.RangeMap; //导入方法依赖的package包/类
private Double getSpeedLimit(RangeMap<Long, Double> rangeMap) {
	return rangeMap.get(timeProvider.getSimTimeInDayRange());
}
 
开发者ID:agents4its,项目名称:mobilitytestbed,代码行数:4,代码来源:ExogenousSpeedLimitSegmentInfluence.java


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