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


Java TreeMap类代码示例

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


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

示例1: toMultimap

import java.util.TreeMap; //导入依赖的package包/类
public static Map<String, List<String>> toMultimap(Headers headers, String valueForNullKey) {
    Map<String, List<String>> result = new TreeMap(FIELD_NAME_COMPARATOR);
    int size = headers.size();
    for (int i = 0; i < size; i++) {
        String fieldName = headers.name(i);
        String value = headers.value(i);
        List<String> allValues = new ArrayList();
        List<String> otherValues = (List) result.get(fieldName);
        if (otherValues != null) {
            allValues.addAll(otherValues);
        }
        allValues.add(value);
        result.put(fieldName, Collections.unmodifiableList(allValues));
    }
    if (valueForNullKey != null) {
        result.put(null, Collections.unmodifiableList(Collections.singletonList
                (valueForNullKey)));
    }
    return Collections.unmodifiableMap(result);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:OkHeaders.java

示例2: getServices

import java.util.TreeMap; //导入依赖的package包/类
/**
 * Retrieves the services that are available for use with the description for each service. 
 * The Services are determined by looking up all of the implementations of the 
 * Customer Service interface that are using the  DataService qualifier annotation. 
 * The DataService annotation contains the service name and description information. 
 * @return Map containing a list of services available and a description of each one.
 */
public Map<String,String> getServices (){
	TreeMap<String,String> services = new TreeMap<String,String>();
	logger.fine("Getting CustomerService Impls");
   	Set<Bean<?>> beans = beanManager.getBeans(CustomerService.class,new AnnotationLiteral<Any>() {
		private static final long serialVersionUID = 1L;});
   	for (Bean<?> bean : beans) {    		
   		for (Annotation qualifer: bean.getQualifiers()){
   			if(DataService.class.getName().equalsIgnoreCase(qualifer.annotationType().getName())){
   				DataService service = (DataService) qualifer;
   				logger.fine("   name="+service.name()+" description="+service.description());
   				services.put(service.name(), service.description());
   			}
   		}
   	}    	
   	return services;
}
 
开发者ID:ibmruntimes,项目名称:acmeair-modular,代码行数:24,代码来源:ServiceLocator.java

示例3: calculate

import java.util.TreeMap; //导入依赖的package包/类
public static final String calculate(Map<String, ? extends Object> parameters, String appsecret) {
    TreeMap<String, Object> params = new TreeMap(parameters);
    params.remove("sign");
    params.put("appsecret", appsecret);
    StringBuilder stringBuilder = new StringBuilder();
    Iterator var4 = params.entrySet().iterator();

    while(var4.hasNext()) {
        Map.Entry<String, Object> entry = (Map.Entry)var4.next();
        stringBuilder.append(((String)entry.getKey()).trim());
        stringBuilder.append("=");
        stringBuilder.append(entry.getValue().toString().trim());
        stringBuilder.append("&");
    }

    stringBuilder.deleteCharAt(stringBuilder.length() - 1);
    return DigestUtils.sha1Hex(stringBuilder.toString());
}
 
开发者ID:wxz1211,项目名称:dooo,代码行数:19,代码来源:Signs.java

示例4: makeMap

import java.util.TreeMap; //导入依赖的package包/类
private static SortedMap<String, Object> makeMap(
        String[] itemNames, Object[] itemValues)
        throws OpenDataException {

    if (itemNames == null || itemValues == null)
        throw new IllegalArgumentException("Null itemNames or itemValues");
    if (itemNames.length == 0 || itemValues.length == 0)
        throw new IllegalArgumentException("Empty itemNames or itemValues");
    if (itemNames.length != itemValues.length) {
        throw new IllegalArgumentException(
                "Different lengths: itemNames[" + itemNames.length +
                "], itemValues[" + itemValues.length + "]");
    }

    SortedMap<String, Object> map = new TreeMap<String, Object>();
    for (int i = 0; i < itemNames.length; i++) {
        String name = itemNames[i];
        if (name == null || name.equals(""))
            throw new IllegalArgumentException("Null or empty item name");
        if (map.containsKey(name))
            throw new OpenDataException("Duplicate item name " + name);
        map.put(itemNames[i], itemValues[i]);
    }

    return map;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:CompositeDataSupport.java

示例5: getAllDBFiles

import java.util.TreeMap; //导入依赖的package包/类
public static TreeMap<String, MassBank> getAllDBFiles(File[] inputFiles, String ser, boolean forceRecalculation, boolean withPeaks)throws Exception {
	TreeMap<String, MassBank> dbFiles=null;
	if(!forceRecalculation){
		try{
			ObjectInputStream ois = new ObjectInputStream(new FileInputStream(ser));
			dbFiles = (TreeMap<String, MassBank>) ois.readObject();
			ois.close();
		}catch(Exception e){
			System.err.println(e);
		}
	}
	if(dbFiles==null){
		System.out.println("calculating database file...");
		dbFiles=new TreeMap<String,MassBank>();
		for(File f:inputFiles){
			getAllDBFiles(f, dbFiles, withPeaks);
		}
		ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(ser));
		oos.writeObject(dbFiles);
		oos.flush();
		oos.close();
		System.out.println("...finished");
	}

	return dbFiles;
}
 
开发者ID:boecker-lab,项目名称:passatuto,代码行数:27,代码来源:Utils.java

示例6: getSitesForUser

import java.util.TreeMap; //导入依赖的package包/类
public Map<String, TestSite> getSitesForUser(String username)
{
	if(username == null)
	{
		username = AuthenticationUtil.getAdminUserName();
	}
	List<SiteInfo> sites = TenantUtil.runAsUserTenant(new TenantRunAsWork<List<SiteInfo>>()
	{
		@Override
		public List<SiteInfo> doWork() throws Exception
		{
			List<SiteInfo> results = siteService.listSites(null, null);
			return results;
		}
	}, username, getId());
	TreeMap<String, TestSite> ret = new TreeMap<String, TestSite>();
	for(SiteInfo siteInfo : sites)
	{
		TestSite site = new TestSite(TestNetwork.this, siteInfo/*, null*/);
		ret.put(site.getSiteId(), site);
	}
	return ret;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:24,代码来源:RepoService.java

示例7: write

import java.util.TreeMap; //导入依赖的package包/类
void write(File outputFile) throws IOException {
    IoActions.writeTextFile(outputFile, new ErroringAction<BufferedWriter>() {
        @Override
        protected void doExecute(BufferedWriter writer) throws Exception {
            final Map<String, JavadocOptionFileOption<?>> options = new TreeMap<String, JavadocOptionFileOption<?>>(optionFile.getOptions());
            JavadocOptionFileWriterContext writerContext = new JavadocOptionFileWriterContext(writer);

            JavadocOptionFileOption<?> localeOption = options.remove("locale");
            if (localeOption != null) {
                localeOption.write(writerContext);
            }

            for (final String option : options.keySet()) {
                options.get(option).write(writerContext);
            }

            optionFile.getSourceNames().write(writerContext);
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:JavadocOptionFileWriter.java

示例8: putBuffer

import java.util.TreeMap; //导入依赖的package包/类
@Override
public synchronized void putBuffer(ByteBuffer buffer) {
  TreeMap<Key, ByteBuffer> tree = getBufferTree(buffer.isDirect());
  while (true) {
    Key key = new Key(buffer.capacity(), System.nanoTime());
    if (!tree.containsKey(key)) {
      tree.put(key, buffer);
      return;
    }
    // Buffers are indexed by (capacity, time).
    // If our key is not unique on the first try, we try again, since the
    // time will be different.  Since we use nanoseconds, it's pretty
    // unlikely that we'll loop even once, unless the system clock has a
    // poor granularity.
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:17,代码来源:ElasticByteBufferPool.java

示例9: combine

import java.util.TreeMap; //导入依赖的package包/类
/** Combine results */
static <T extends Combinable<T>> Map<Parameter, T> combine(Map<Parameter, List<T>> m) {
  final Map<Parameter, T> combined = new TreeMap<Parameter, T>();
  for(Parameter p : Parameter.values()) {
    //note: results would never be null due to the design of Util.combine
    final List<T> results = Util.combine(m.get(p));
    Util.out.format("%-6s => ", p); 
    if (results.size() != 1)
      Util.out.println(results.toString().replace(", ", ",\n           "));
    else {
      final T r = results.get(0);
      combined.put(p, r); 
      Util.out.println(r);
    }
  }
  return combined;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:Parser.java

示例10: ConditionVertex

import java.util.TreeMap; //导入依赖的package包/类
/**
 * The constructor for chaining nodes inside of ConditionVertex.
 * 
 * @param state the actual CollisionAtPosition
 * @param scene the actual SimulatedLevelScene (has to updated befor)
 * @param knowledge (not actually used in this constructor) knowledge is extracted from the scene (?)
 * @param effects the known effects
 * @param depth the depth of the actual node (incremented in everytime a node is expanded)
 * @param previousInteraction the goal which was reached in the previous node in the simulation
 * @param relevantEffect the relevant Effect
 * @param topProbability the maximum probability
 */
public ConditionVertex(CollisionAtPosition state,
		SimulatedLevelScene scene,
		TreeMap<ConditionDirectionPair, TreeMap<Effect, Double>> knowledge,
		TreeMap<Effect, Double> effects, 
		int depth,
		Goal previousInteraction, Effect relevantEffect, double topProbability) 
{
	this.scene = scene;
	this.depth = depth;
	this.effects = effects;
	this.previousInteraction = previousInteraction;
	this.state = state;
	this.knowledge = scene.getKnowledge();
	this.importantEffect = relevantEffect;
	this.topProbability = topProbability;
}
 
开发者ID:CognitiveModeling,项目名称:BrainControl,代码行数:29,代码来源:ConditionVertex.java

示例11: fastScrollVertical

import java.util.TreeMap; //导入依赖的package包/类
static void fastScrollVertical(int amountAxis, RecyclerView recyclerView) {
    LinearLayoutManager linearLayoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
    if (indexHeight == null) {
        indexHeight = new TreeMap<>();
        //call this method the OnScrollListener's onScrolled will be called,but dx and dy always be zero.
        linearLayoutManager.scrollToPositionWithOffset(0, -amountAxis);
    } else {
        int total = 0, count = 0;
        Iterator<Integer> iterator = indexHeight.keySet().iterator();
        while (null != iterator && iterator.hasNext()) {
            int height = indexHeight.get(iterator.next());
            if (total + height >= amountAxis) {
                break;
            }
            total += height;
            count++;
        }
        linearLayoutManager.scrollToPositionWithOffset(count, -(amountAxis - total));
    }
}
 
开发者ID:zhouchaoyuan,项目名称:excelPanel,代码行数:21,代码来源:ExcelPanel.java

示例12: testHigherKey

import java.util.TreeMap; //导入依赖的package包/类
/**
 * higherKey returns next element
 */
public void testHigherKey() {
    TreeMap q = map5();
    Object e1 = q.higherKey(three);
    assertEquals(four, e1);

    Object e2 = q.higherKey(zero);
    assertEquals(one, e2);

    Object e3 = q.higherKey(five);
    assertNull(e3);

    Object e4 = q.higherKey(six);
    assertNull(e4);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:TreeMapTest.java

示例13: findMinLightsCount

import java.util.TreeMap; //导入依赖的package包/类
static void findMinLightsCount(Node[] nodes, int curr, TreeMap<Integer, Integer> lightsToVariantsCount) {
	if (curr == nodes.length) {
		if (allEdgesHighlighted(nodes[0])) {
			int amountOfSwitchedOnNodes = calculateSwitchedOnNodes(nodes);
			Integer variantsCount = lightsToVariantsCount.getOrDefault(amountOfSwitchedOnNodes, 0);
			lightsToVariantsCount.put(amountOfSwitchedOnNodes, variantsCount + 1);
		}
		return;
	}

	nodes[curr].isSwitchedOn = true;
	findMinLightsCount(nodes, curr + 1, lightsToVariantsCount);

	nodes[curr].isSwitchedOn = false;
	findMinLightsCount(nodes, curr + 1, lightsToVariantsCount);
}
 
开发者ID:lagodiuk,项目名称:spoj,代码行数:17,代码来源:VOCV_Brute_Force.java

示例14: getRequestProperties

import java.util.TreeMap; //导入依赖的package包/类
/**
 * Returns an unmodifiable map of general request properties used by this
 * connection.
 */
@Override
public Map<String, List<String>> getRequestProperties() {
    if (connected) {
        throw new IllegalStateException(
                "Cannot access request headers after connection is set.");
    }
    Map<String, List<String>> map = new TreeMap<String, List<String>>(
            String.CASE_INSENSITIVE_ORDER);
    for (Pair<String, String> entry : mRequestHeaders) {
        if (map.containsKey(entry.first)) {
            // This should not happen due to setRequestPropertyInternal.
            throw new IllegalStateException(
                "Should not have multiple values.");
        } else {
            List<String> values = new ArrayList<String>();
            values.add(entry.second);
            map.put(entry.first, Collections.unmodifiableList(values));
        }
    }
    return Collections.unmodifiableMap(map);
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:26,代码来源:CronetHttpURLConnection.java

示例15: index

import java.util.TreeMap; //导入依赖的package包/类
public void index(Map<String, Object> context) throws Exception {
    Map<String, String> properties = new TreeMap<String, String>();
    StringBuilder msg = new StringBuilder();
    msg.append("Version: ");
    msg.append(Version.getVersion(Envs.class, "2.2.0"));
    properties.put("Registry", msg.toString());
    String address = NetUtils.getLocalHost();
    properties.put("Host", NetUtils.getHostName(address) + "/" + address);
    properties.put("Java", System.getProperty("java.runtime.name") + " " + System.getProperty("java.runtime.version"));
    properties.put("OS", System.getProperty("os.name") + " "
            + System.getProperty("os.version"));
    properties.put("CPU", System.getProperty("os.arch", "") + ", "
            + String.valueOf(Runtime.getRuntime().availableProcessors()) + " cores");
    properties.put("Locale", Locale.getDefault().toString() + "/"
            + System.getProperty("file.encoding"));
    properties.put("Uptime", formatUptime(ManagementFactory.getRuntimeMXBean().getUptime()) 
            + " From " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z").format(new Date(ManagementFactory.getRuntimeMXBean().getStartTime())) 
            + " To " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z").format(new Date()));
    context.put("properties", properties);
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:21,代码来源:Envs.java


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