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


Java TreeMap.containsKey方法代码示例

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


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

示例1: main

import java.util.TreeMap; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    TreeMap<Byte, Integer> frequencyMap = new TreeMap<Byte, Integer>();
    FileInputStream f = new FileInputStream(args[0]);

    while (f.available() > 0) {
        byte[] buf = new byte[f.available()];
        f.read(buf);

        for (int i = 0; i < buf.length; i++) {
            if (frequencyMap.containsKey(buf[i]))
                frequencyMap.put(buf[i], frequencyMap.get(buf[i]) + 1);
            else
                frequencyMap.put(buf[i], 1);
        }
    }
    f.close();

    for (Map.Entry pair : frequencyMap.entrySet()) {
        System.out.println((char)((byte) pair.getKey()) + " " + pair.getValue());
    }
}
 
开发者ID:avedensky,项目名称:JavaRushTasks,代码行数:22,代码来源:Solution.java

示例2: UploadCdnEntity

import java.util.TreeMap; //导入方法依赖的package包/类
public String UploadCdnEntity(TreeMap<String, Object> params) throws NoSuchAlgorithmException, IOException {
	String actionName = "UploadCdnEntity";

       String entityFile = params.get("entityFile").toString();
       params.remove("entityFile");
       File file = new File(entityFile);        
       if (!file.exists()) {
       	throw new FileNotFoundException();
       }
       
       if (!params.containsKey("entityFileMd5")) {
           params.put("entityFileMd5", MD5.fileNameToMD5(entityFile));
       }
       
       return call(actionName, params, entityFile);
}
 
开发者ID:BennyThink,项目名称:qcloudClient,代码行数:17,代码来源:Cdn.java

示例3: ensureUniqueHost

import java.util.TreeMap; //导入方法依赖的package包/类
public void ensureUniqueHost (	String adminHostName, StringBuffer resultsBuf,
								TreeMap<String, String> hostDuplicateCheck,
								ReleasePackage model ) {

	logger.debug( "checking {} in \n\t {}", adminHostName, hostDuplicateCheck );

	if ( hostDuplicateCheck.containsKey( adminHostName ) ) {

		String message = CSAP.CONFIG_PARSE_ERROR
				+ " Host: "
				+ adminHostName
				+ " was found in multiple release packages: "
				+ hostDuplicateCheck.get( adminHostName )
				+ " and "
				+ model.getReleasePackageFileName()
				+ ". To ensure package isolation, a host can only appear in 1 package\n";
		resultsBuf.append( message );
		logger.warn( message );
	}
	hostDuplicateCheck.put( adminHostName, model.getReleasePackageFileName() );

}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:23,代码来源:DefinitionParser.java

示例4: MultipartUploadVodFile

import java.util.TreeMap; //导入方法依赖的package包/类
public String MultipartUploadVodFile(TreeMap<String, Object> params) throws NoSuchAlgorithmException, IOException {
	serverHost = "vod.qcloud.com";
	
	String actionName = "MultipartUploadVodFile";

       String fileName = params.get("file").toString();
       params.remove("file");
       File f= new File(fileName);  
       
       if (!params.containsKey("fileSize")){
       	params.put("fileSize", f.length());
       }
       if (!params.containsKey("fileSha")){
       	params.put("fileSha", SHA1.fileNameToSHA(fileName));
       }
       
       return call(actionName, params, fileName);
}
 
开发者ID:BennyThink,项目名称:qcloudClient,代码行数:19,代码来源:Vod.java

示例5: currentlog

import java.util.TreeMap; //导入方法依赖的package包/类
@RequestMapping(value = "/apistatisticday", method = RequestMethod.GET)
public String currentlog(Model model,
                         @RequestParam(value = "topdatarange", required = false, defaultValue = "0") String topdaterange,
                         @RequestParam(value = "url", required = false, defaultValue = "") String url
) {

    //date list
    List<String> timelist = DateTimeHelper.getDateTimeListForPage(fieryConfig.getKeepdataday());
    model.addAttribute("datelist", timelist);
    model.addAttribute("datelist_selected", topdaterange);

    model.addAttribute("url", url);

    //now the date render
    long shardtime = DateTimeHelper.getTimesMorning(DateTimeHelper.getBeforeDay(Integer.parseInt(topdaterange)));

    TreeMap<Long, APIStatisticStruct> urlList = apiStatisticTimeSet.getHourDetail(url, shardtime);

    //log.info("size:" + urlList.size());

    model.addAttribute("urllist", urlList);

    //http code
    TreeMap<String, Long> httpCodeMap = new TreeMap<>();
    for (Map.Entry<Long, APIStatisticStruct> timeItem : urlList.entrySet()) {
        for (ConcurrentHashMap.Entry<String, AtomicLong> httpitem : timeItem.getValue().getCode_count().entrySet()) {
            if (!httpCodeMap.containsKey(httpitem.getKey())) {
                httpCodeMap.put(httpitem.getKey(), httpitem.getValue().longValue());
            } else {
                httpCodeMap.put(httpitem.getKey(), httpCodeMap.get(httpitem.getKey()) + httpitem.getValue().longValue());
            }
        }

    }

    model.addAttribute("httpcode", httpCodeMap);

    return "apistatisticday";
}
 
开发者ID:weiboad,项目名称:fiery,代码行数:40,代码来源:APIStatisticDayPage.java

示例6: haveSameTransitions

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * 是否含有相同的转移函数
 * @param node1
 * @param node2
 * @return
 */
public static boolean haveSameTransitions(MDAGNode node1, MDAGNode node2)
{
    TreeMap<Character, MDAGNode> outgoingTransitionTreeMap1 = node1.outgoingTransitionTreeMap;
    TreeMap<Character, MDAGNode> outgoingTransitionTreeMap2 = node2.outgoingTransitionTreeMap;
    
    if(outgoingTransitionTreeMap1.size() == outgoingTransitionTreeMap2.size())
    {
        //For each _transition in outgoingTransitionTreeMap1, get the identically lableed _transition
        //in outgoingTransitionTreeMap2 (if present), and test the equality of the transitions' target nodes
        for(Entry<Character, MDAGNode> transitionKeyValuePair : outgoingTransitionTreeMap1.entrySet())
        {
            Character currentCharKey = transitionKeyValuePair.getKey();
            MDAGNode currentTargetNode = transitionKeyValuePair.getValue();
            
            if(!outgoingTransitionTreeMap2.containsKey(currentCharKey) || !outgoingTransitionTreeMap2.get(currentCharKey).equals(currentTargetNode))
                return false;
        }
        /////
    }
    else
        return false;
    
    return true;
}
 
开发者ID:priester,项目名称:hanlpStudy,代码行数:31,代码来源:MDAGNode.java

示例7: generateUrl

import java.util.TreeMap; //导入方法依赖的package包/类
public String generateUrl(String actionName, TreeMap<String, Object> params) {
	actionName = ucFirst(actionName);
	if(params == null)
		params = new TreeMap<String, Object>();
	params.put("Action", actionName);
	if (!params.containsKey("Region")) {
		params.put("Region", defaultRegion);
	}
	return Request.generateUrl(params, secretId, secretKey, requestMethod,
			serverHost, serverUri);
}
 
开发者ID:BennyThink,项目名称:qcloudClient,代码行数:12,代码来源:Base.java

示例8: getCount

import java.util.TreeMap; //导入方法依赖的package包/类
public static int getCount(String word, TreeMap<String, Integer> frequencyData){
	if (frequencyData.containsKey(word)){
		return frequencyData.get(word);
	}
	else{
		return 0;
	}
}
 
开发者ID:DivyendraPatil,项目名称:MS-Cyber-Security-Solutions,代码行数:9,代码来源:PageRanking.java

示例9: main

import java.util.TreeMap; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    TreeMap<String, Double> map = new TreeMap<>();
    BufferedReader fileReader = new BufferedReader(new FileReader(args[0]));

    double max = Double.MIN_VALUE;
    while (fileReader.ready()) {
        String s = fileReader.readLine();
        String[] strs = s.split("[\\s\\t\\n\\x0B\\f\\r]");
        String key = strs[0];
        double value = Double.parseDouble(strs[1]);
        if (map.containsKey(key)) {
            map.put(key, map.get(strs[0]) + value);
        } else
            map.put(key, value);
    }
    fileReader.close();

    //Max
    for (Double a : map.values())
        if (max < a)
            max = a;

    //show
    for (Map.Entry<String, Double> pair : map.entrySet())
        if (pair.getValue().equals(max))
            System.out.println(pair.getKey());
}
 
开发者ID:avedensky,项目名称:JavaRushTasks,代码行数:28,代码来源:Solution.java

示例10: put

import java.util.TreeMap; //导入方法依赖的package包/类
private void put(TreeMap<Date, Long> map, Date date, boolean start) {
	Long count;
	if (map.containsKey(date)) {
		count = map.get(date);
	} else {
		count = 0l;
	}
	map.put(date, count + (start ? 1l : -1l));
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:10,代码来源:OverlapFinder.java

示例11: testContainsKey

import java.util.TreeMap; //导入方法依赖的package包/类
public void testContainsKey()
{
	// create an empty tree map
	TreeMap<TreeMapKey,Object> tree = new TreeMap<TreeMapKey,Object>();
	// look for a key
	assertFalse("Found a key in an empty tree", tree.containsKey(new TreeMapKey(2)));
	
	// create a list of ints 0..TreeMapFactory.SIZE-1 in random order
	ArrayList<Integer> intList = new ArrayList<Integer>(TreeMapFactory.SIZE);
	
	for (int i=0; i<TreeMapFactory.SIZE; i++)
	{
		intList.add(new Integer(i));
	}
	Collections.shuffle(intList, new Random(173417));
	
	// add keys to tree
	while (intList.size()>0)
	{
		tree.put(new TreeMapKey(((Integer)intList.remove(0)).intValue()), null);
	}
	
	// check that the tree contains all keys from 0 to TreeMapFactory.SIZE-1
	for (int i=0; i<TreeMapFactory.SIZE; i++)
	{
		assertTrue("Tree doesn't contain key " + i, tree.containsKey(new TreeMapKey(i)));
	}
	
	// try null key
	try
	{
		tree.containsKey(null);
		fail("Attempt to call TreeMap.containsKey with null should throw NullPointerException");
	}
	catch (NullPointerException e)
	{
		// expected behaviour
	}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:40,代码来源:TreeMapAPITest.java

示例12: expandPossibleGoalsDGM

import java.util.TreeMap; //导入方法依赖的package包/类
/**
	 * expandPossibleGoalsDGM is the goaldegeneralization version of expandPossibleGoals.
	 * Like expandPossibleGoals, it has two arguments:
	 * An ArrayList of (Goal,Double) entries created from the current DegeneralizedGoal
	 * to be generalized and a ConditioDirectionPair extracted from that DegeneralizeGoal.
	 * For each goal It creates a new Node and adds an adjacency with a calculated Probability from
	 * the actual node to the newly generated node.
	 * @param goals an ArrayList of (Goal,Double)-Entries
	 * @param cdp   a CollisionDirectionPair
	 */
	private void expandPossibleGoalsDGM(ArrayList<Entry<Goal,Double>> goals,ConditionDirectionPair cdp){
		for(Entry<Goal,Double> goal: goals){
			GlobalCoarse positionAfterInteraction = goal.getKey().getPosition();
			SimulatedLevelScene newScene =
					new SimulatedLevelScene(this.scene,true);
			CollisionAtPosition cap =
					new CollisionAtPosition(cdp, positionAfterInteraction, goal.getKey().getTargetSprite(), goal.getKey().getActorSprite());
			System.out.println("CURRENT COLLISION AT POSITION");
			System.out.println(cap);
			TreeMap<Effect, Double> simulatedEffectList = newScene.simulateCollision(cap, true);
//			if (simulatedEffectList.size() == 0) System.out.println("SD: Seems like no effects are simulated!");
			newScene.getPlanningPlayer().setPosition(positionAfterInteraction.toGlobalContinuous());
			//newScene.recomputeReachabilityMap();
			System.out.println(newScene);
			System.out.println("PREVIOUS GOAL: " + this.previousInteraction);
			//newScene.Rmap.showMap("DEPTH: " + this.depth);
			double prob = 1.0;
			
			Effect topEffect = getMostImportantEffect(simulatedEffectList);
			double newTopProbability = 1.0;
//			System.out.println("Checking top probability for goal " + ((topEffect != null) ? topEffect.getType() : ActionEffect.UNDEFINED));
			if ((topEffect != null) && (simulatedEffectList.containsKey(topEffect))){
//				System.out.println("SD: Set vertex probability to: " + simulatedEffectList.get(topEffect) + " for top effect " + ((topEffect != null) ? topEffect.getType() : ActionEffect.UNDEFINED));
				newTopProbability = simulatedEffectList.get(topEffect);
			}
			
			ConditionVertex next =
					new ConditionVertex(cap, newScene, knowledge, simulatedEffectList, this.depth + 1, goal.getKey(), topEffect, newTopProbability);
			adjacencies.add(new ProbabilityEdge(next, -Math.log(prob)));
		}
	}
 
开发者ID:CognitiveModeling,项目名称:BrainControl,代码行数:42,代码来源:ConditionVertex.java

示例13: reduce

import java.util.TreeMap; //导入方法依赖的package包/类
public void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {

			//this -> <is=1000, is book=10>
			
			TreeMap<Integer, List<String>> tm = new TreeMap<Integer, List<String>>(Collections.reverseOrder());
			for (Text val : values) {
				String cur_val = val.toString().trim();
				String word = cur_val.split("=")[0].trim();
				int count = Integer.parseInt(cur_val.split("=")[1].trim());
				if(tm.containsKey(count)) {
					tm.get(count).add(word);
				}
				else {
					List<String> list = new ArrayList<>();
					list.add(word);
					tm.put(count, list);
				}
			}

			Iterator<Integer> iter = tm.keySet().iterator();
			
			for(int j=0 ; iter.hasNext() && j < n; j++) {
				int keyCount = iter.next();
				List<String> words = tm.get(keyCount);
				for(String curWord: words) {
					context.write(new DBOutputWritable(key.toString(), curWord, keyCount), NullWritable.get());
					j++;
				}
			}
		}
 
开发者ID:yogykwan,项目名称:mapreduce-samples,代码行数:31,代码来源:LanguageModel.java

示例14: getKeywordMap

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * Returns a map of the keywords and values, or null if there are none.
 */
public Map<String, String> getKeywordMap() {
    if (keywords == null) {
        TreeMap<String, String> m = null;
        if (setToKeywordStart()) {
            // trim spaces and convert to lower case, both keywords and values.
            do {
                String key = getKeyword();
                if (key.length() == 0) {
                    break;
                }
                char c = next();
                if (c != KEYWORD_ASSIGN) {
                    // throw new IllegalArgumentException("key '" + key + "' missing a value.");
                    if (c == DONE) {
                        break;
                    } else {
                        continue;
                    }
                }
                String value = getValue();
                if (value.length() == 0) {
                    // throw new IllegalArgumentException("key '" + key + "' missing a value.");
                    continue;
                }
                if (m == null) {
                    m = new TreeMap<String, String>(getKeyComparator());
                } else if (m.containsKey(key)) {
                    // throw new IllegalArgumentException("key '" + key + "' already has a value.");
                    continue;
                }
                m.put(key, value);
            } while (next() == ITEM_SEPARATOR);
        }
        keywords = m != null ? m : Collections.<String, String>emptyMap();
    }

    return keywords;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:42,代码来源:LocaleIDParser.java

示例15: testContainsKey_NullPointerException

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * containsKey(null) of nonempty map throws NPE
 */
public void testContainsKey_NullPointerException() {
    TreeMap c = map5();
    try {
        c.containsKey(null);
        shouldThrow();
    } catch (NullPointerException success) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:TreeMapTest.java


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