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


Java TreeMap.keySet方法代码示例

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


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

示例1: createMyListmenu

import java.util.TreeMap; //导入方法依赖的package包/类
private JMenu createMyListmenu() {

        if (myListMenu == null) {
            myListMenu = new JMenu("My Lists");
        }

        myListMenu.removeAll();

        JMenuItem item;
        TreeMap<String, TreeSet<String>> pls = MFMPlayLists.getInstance().getMyPlayListsTree();
        for (String name : pls.keySet()) {
            item = myListMenu.add(mfmActionShowList);
            item.setActionCommand("Show List");
            item.setText(name);
        }

        myListMenu.repaint();
        myListMenu.validate();
        return myListMenu;
    }
 
开发者ID:phweda,项目名称:MFM,代码行数:21,代码来源:MFM_Menubar.java

示例2: testKeySetOrder

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * keySet is ordered
 */
public void testKeySetOrder() {
    TreeMap map = map5();
    Set s = map.keySet();
    Iterator i = s.iterator();
    Integer last = (Integer)i.next();
    assertEquals(last, one);
    int count = 1;
    while (i.hasNext()) {
        Integer k = (Integer)i.next();
        assertTrue(last.compareTo(k) < 0);
        last = k;
        ++count;
    }
    assertEquals(5, count);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:TreeMapTest.java

示例3: hasEqualComponentTypeSettings

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * Checks for equal component type settings.
 *
 * @param ggsToCompare the GeneralGraphSettings4MAS to compare
 * @return true, if successful
 */
public boolean hasEqualComponentTypeSettings(GeneralGraphSettings4MAS ggsToCompare) {
	
	boolean isEqual = true;
	TreeMap<String, ComponentTypeSettings> ctsTreeMapToCompare = ggsToCompare.getCurrentCTS();
	isEqual = (ctsTreeMapToCompare.size()==this.getCurrentCTS().size());
	if (isEqual==true) {
		// --- Compare each element in the TreeMap ----
		Vector<String> keyVector = new Vector<String>(ctsTreeMapToCompare.keySet());
		for (int i = 0; i < keyVector.size(); i++) {
			String key = keyVector.get(i);
			ComponentTypeSettings cts2Comp = ctsTreeMapToCompare.get(key);
			ComponentTypeSettings ctsLocal = this.getCurrentCTS().get(key);
			if (ctsLocal==null) return false;
			if (isEqualComponentTypeSettings(cts2Comp, ctsLocal)==false) return false;
		}
	}
	return isEqual;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:25,代码来源:GeneralGraphSettings4MAS.java

示例4: selectLikelyEntry

import java.util.TreeMap; //导入方法依赖的package包/类
static <A> Entry<A, Double> selectLikelyEntry(TreeMap<A, Double> entries)
{
	ArrayList<A> keys = new ArrayList<A>(entries.keySet());
	
	Double value;
	A randomKey;
	
	do
	{			
		randomKey = keys.get(random.nextInt(keys.size()));
		value = entries.get(randomKey);
		
		//System.out.println("thinking to talk about " + randomKey + " + " + value + "("+keys.size()+" keys)");
	}
	while(value==null || (Math.random() > value.doubleValue()));
	
	return new SimpleEntry<A, Double>(randomKey, value);
}
 
开发者ID:CognitiveModeling,项目名称:BrainControl,代码行数:19,代码来源:VoiceKnowledgeManager.java

示例5: getMostImportantEffect

import java.util.TreeMap; //导入方法依赖的package包/类
/**
	 * select the most important effect of a collision
	 * @param simulatedEffectList of the collision
	 * @return max important of the effects, with importance := probability * relevance
	 */
	private Effect getMostImportantEffect(TreeMap<Effect,Double> simulatedEffectList){
		// select most important effect
		// note: likelihood != importance!
		double topImportance = 0.0;
		Effect topEffect = null;
		for(Effect e : simulatedEffectList.keySet())
		{
			double importance = simulatedEffectList.get(e) * getEffectRelevance(e);
//			System.out.println("SD: Effect: " + e.getType() +"evaluated; probability: " + simulatedEffectList.get(e) + ", relevance: " + getEffectRelevance(e));
			
			if (importance > topImportance){
				topEffect = e;
				topImportance = importance;
			}
		}

		
		return topEffect;
	}
 
开发者ID:CognitiveModeling,项目名称:BrainControl,代码行数:25,代码来源:ConditionVertex.java

示例6: buildParamStr

import java.util.TreeMap; //导入方法依赖的package包/类
protected static String buildParamStr(TreeMap<String, Object> requestParams, String requestMethod) {

        String retStr = "";
        for(String key: requestParams.keySet()) {
        	//排除上传文件的参数
            if(requestMethod == "POST" && requestParams.get(key).toString().substring(0, 1).equals("@")){
            	continue;
            }
            if (retStr.length()==0) {
                retStr += '?';
            } else {
                retStr += '&';
            }
            retStr += key.replace("_", ".") + '=' + requestParams.get(key).toString();

        }
        return retStr;
    }
 
开发者ID:BennyThink,项目名称:qcloudClient,代码行数:19,代码来源:Sign.java

示例7: service

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * Only interested in the parameters and values for requests.
 * Note: echos parameters in alphabetical order.
 */
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException {
    // Just echo the parameters and values back as plain text
    resp.setContentType("text/plain");
    resp.setCharacterEncoding("UTF-8");

    PrintWriter out = resp.getWriter();

    TreeMap<String,String[]> parameters = new TreeMap<String,String[]>(req.getParameterMap());

    boolean first = true;

    for(String name: parameters.keySet()) {
        String[] values = req.getParameterValues(name);

        java.util.Arrays.sort(values);

        for(int i=0; i<values.length; ++i)
        {
            if(first)
                first = false;
            else
                out.print(",");

            out.print(name + "=" + values[i]);
        }
    }
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:34,代码来源:TestRequest.java

示例8: ScheduleSelectAdapter

import java.util.TreeMap; //导入方法依赖的package包/类
public ScheduleSelectAdapter(TreeMap<Integer, List<ScheduleType>> schedules) {
	minutesList = new ArrayList<>();
	for (Integer integer : schedules.keySet()) {
		minutesList.add(integer);
	}
	this.schedules = schedules;
}
 
开发者ID:chickendude,项目名称:GlossikaSchedule,代码行数:8,代码来源:ScheduleSelectAdapter.java

示例9: testKeySet

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * keySet returns a Set containing all the keys
 */
public void testKeySet() {
    TreeMap map = map5();
    Set s = map.keySet();
    assertEquals(5, s.size());
    assertTrue(s.contains(one));
    assertTrue(s.contains(two));
    assertTrue(s.contains(three));
    assertTrue(s.contains(four));
    assertTrue(s.contains(five));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:TreeMapTest.java

示例10: choose_size

import java.util.TreeMap; //导入方法依赖的package包/类
private int choose_size(TreeMap<Integer, Double> wheel) {
	double choice = rand.nextDouble() * 100;
	for (Integer key : wheel.keySet()) {
		if (choice < wheel.get(key)) {
			return key;
		}
	}
	return 0;
}
 
开发者ID:aventresque,项目名称:EvolvingFMs,代码行数:10,代码来源:GenerateModifications.java

示例11: selectRandomEntry

import java.util.TreeMap; //导入方法依赖的package包/类
static <A, B> Entry<A, B> selectRandomEntry(TreeMap<A, B> entries) 
{
	ArrayList<A> keys = new ArrayList<A>(entries.keySet());
	
	A randomKey = keys.get(random.nextInt(keys.size()));
	B value = entries.get(randomKey);
	
	return new SimpleEntry<A, B>(randomKey, value);
}
 
开发者ID:CognitiveModeling,项目名称:BrainControl,代码行数:10,代码来源:VoiceKnowledgeManager.java

示例12: selectInterestingEntryWithEffect

import java.util.TreeMap; //导入方法依赖的package包/类
static SimpleEntry<ConditionDirectionPair, TreeMap<Effect, Double>> selectInterestingEntryWithEffect(TreeMap<ConditionDirectionPair, TreeMap<Effect, Double>> entries, Effect effect) 
{
	TreeMap<ConditionDirectionPair, TreeMap<Effect, Double>> entriesclone = new TreeMap<ConditionDirectionPair, TreeMap<Effect, java.lang.Double>>();
	
	//filter knowledge
	for(ConditionDirectionPair cdp : entries.keySet())
	{
		for(Entry<Effect, Double> e : entries.get(cdp).entrySet())
		{
			if(e.getKey().equals(effect))
			{
				TreeMap<Effect,Double> tmp = new TreeMap<Effect,Double>();
				tmp.put(e.getKey(),e.getValue());
				entriesclone.put(cdp,tmp);
			}
		}
			
		/*if(entries.get(cdp).keySet().contains(effect))
		{
			entriesclone.put(cdp,entries.get(cdp));
		}*/
	}
	
	if(entriesclone.isEmpty())
		return null;
	
	return selectInterestingEntry(entriesclone);
}
 
开发者ID:CognitiveModeling,项目名称:BrainControl,代码行数:29,代码来源:VoiceKnowledgeManager.java

示例13: main

import java.util.TreeMap; //导入方法依赖的package包/类
public static void main(String[] args) {

		HashMap<Agencia, Cliente[]> hm = new HashMap<Agencia, Cliente[]>();
		// adiciona chave - agência e valor = array Cliente
		hm.put(new Agencia("ag01"), new Cliente[] { new Cliente("Enricando Cardoso"), new Cliente("Inacio Estole"), new Cliente("Luiz Ladrum"), });
		hm.put(new Agencia("ag02"), new Cliente[] { new Cliente("Henri Cando"), new Cliente("Stolin Lu La"), new Cliente("Lara Pio"), });
		hm.put(new Agencia("ag03"), new Cliente[] { new Cliente("Sony Gando"), new Cliente("Leiro Pisto"), new Cliente("Waga Oubum Du"), });

		// criando TreeMap
		TreeMap<Agencia, Cliente[]> tm = new TreeMap<Agencia, Cliente[]>(hm);

		// imprime a coleção
		System.out.println(tm);

		// pega as chaves
		Set chaves = tm.keySet();

		// imprime as chaves
		System.out.println(chaves);

		// pega os valores
		Collection<Cliente[]> valores = tm.values();

		// imprime os valores
		for (Cliente[] cs : valores) {
			for (Cliente c : cs) {
				System.out.println(c);
			}
		}
	}
 
开发者ID:alexferreiradev,项目名称:3way_laboratorios,代码行数:31,代码来源:TesteTreeMap.java

示例14: handleEncapsulatedPacket

import java.util.TreeMap; //导入方法依赖的package包/类
private void handleEncapsulatedPacket(EncapsulatedPacket packet) throws Exception {
    if (packet.messageIndex == null) {
        this.handleEncapsulatedPacketRoute(packet);
    } else {
        if (packet.messageIndex < this.reliableWindowStart || packet.messageIndex > this.reliableWindowEnd) {
            return;
        }

        if ((packet.messageIndex - this.lastReliableIndex) == 1) {
            this.lastReliableIndex++;
            this.reliableWindowStart++;
            this.reliableWindowEnd++;
            this.handleEncapsulatedPacketRoute(packet);

            if (!this.reliableWindow.isEmpty()) {
                TreeMap<Integer, EncapsulatedPacket> sortedMap = new TreeMap<>(this.reliableWindow);

                for (int index : sortedMap.keySet()) {
                    EncapsulatedPacket pk = this.reliableWindow.get(index);

                    if ((index - this.lastReliableIndex) != 1) {
                        break;
                    }

                    this.lastReliableIndex++;
                    this.reliableWindowStart++;
                    this.reliableWindowEnd++;
                    this.handleEncapsulatedPacketRoute(pk);
                    this.reliableWindow.remove(index);
                }
            }
        } else {
            this.reliableWindow.put(packet.messageIndex, packet);
        }
    }

}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:38,代码来源:Session.java

示例15: testKeySetToArray

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * keySet.toArray returns contains all keys
 */
public void testKeySetToArray() {
    TreeMap map = map5();
    Set s = map.keySet();
    Object[] ar = s.toArray();
    assertTrue(s.containsAll(Arrays.asList(ar)));
    assertEquals(5, ar.length);
    ar[0] = m10;
    assertFalse(s.containsAll(Arrays.asList(ar)));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:TreeMapTest.java


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