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


Java SortedMap.get方法代码示例

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


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

示例1: route

import java.util.SortedMap; //导入方法依赖的package包/类
public String route(int jobId, ArrayList<String> addressList) {

        // ------A1------A2-------A3------
        // -----------J1------------------
        TreeMap<Long, String> addressRing = new TreeMap<Long, String>();
        for (String address: addressList) {
            for (int i = 0; i < VIRTUAL_NODE_NUM; i++) {
                long addressHash = hash("SHARD-" + address + "-NODE-" + i);
                addressRing.put(addressHash, address);
            }
        }

        long jobHash = hash(String.valueOf(jobId));
        SortedMap<Long, String> lastRing = addressRing.tailMap(jobHash);
        if (!lastRing.isEmpty()) {
            return lastRing.get(lastRing.firstKey());
        }
        return addressRing.firstEntry().getValue();
    }
 
开发者ID:kevinKaiF,项目名称:xxl-job,代码行数:20,代码来源:ExecutorRouteConsistentHash.java

示例2: main

import java.util.SortedMap; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    SortedMap<String, Charset> map = Charset.availableCharsets();
    for (String name : map.keySet()) {
        Charset charset = map.get(name);
        if (charset.canEncode() && !charset.name().equals("x-COMPOUND_TEXT")) {
            testNormalSurrogate(charset, NORMAL_SURROGATE);
            testMalformedSurrogate(charset, MALFORMED_SURROGATE);
            testMalformedSurrogate(charset, REVERSED_SURROGATE);
            testMalformedSurrogate(charset, SOLITARY_HIGH_SURROGATE);
            testMalformedSurrogate(charset, SOLITARY_LOW_SURROGATE);
            testSurrogateWithReplacement(charset, NORMAL_SURROGATE);
            testSurrogateWithReplacement(charset, MALFORMED_SURROGATE);
            testSurrogateWithReplacement(charset, REVERSED_SURROGATE);
            testSurrogateWithReplacement(charset, SOLITARY_HIGH_SURROGATE);
            testSurrogateWithReplacement(charset, SOLITARY_LOW_SURROGATE);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:MalformedSurrogates.java

示例3: debug

import java.util.SortedMap; //导入方法依赖的package包/类
public String debug(Collection<Statement> catalog_stmts) {
    StringBuilder sb = new StringBuilder();
    for (Statement catalog_stmt : catalog_stmts) {
        if (this.stmtIndex.containsKey(catalog_stmt)) {
            int num_instances = this.stmtIndex.get(catalog_stmt).size();
            sb.append(catalog_stmt.getName() + " [# of Instances=" + num_instances + "]\n");
            for (Integer catalog_stmt_index : this.stmtIndex.get(catalog_stmt).keySet()) {
                if (num_instances > 1) sb.append(String.format("   Instance #%02d:\n", catalog_stmt_index));

                if (this.stmtIndex.get(catalog_stmt).containsKey(catalog_stmt_index)) {
                    SortedMap<StmtParameter, SortedSet<ParameterMapping>> params = this.stmtIndex.get(catalog_stmt).get(catalog_stmt_index);
                    for (StmtParameter catalog_stmt_param : params.keySet()) {
                        for (ParameterMapping c : params.get(catalog_stmt_param)) {
                            sb.append("   " + c + "\n");
                        } // FOR (correlation)
                    } // FOR (catalog_stmt_param)
                } else {
                    sb.append("   <NONE>\n");
                }
            } // FOR (catalog_stmt_index)
            sb.append(StringUtil.SINGLE_LINE);
        }
    } // FOR (catalot_stmt)
    return (sb.toString());
}
 
开发者ID:s-store,项目名称:s-store,代码行数:26,代码来源:ParameterMappingsSet.java

示例4: setLineMap

import java.util.SortedMap; //导入方法依赖的package包/类
private void setLineMap(Code_attribute attr) {
    SortedMap<Integer, SortedSet<Integer>> map = new TreeMap<>();
    SortedSet<Integer> allLines = new TreeSet<>();
    for (Attribute a: attr.attributes) {
        if (a instanceof LineNumberTable_attribute) {
            LineNumberTable_attribute t = (LineNumberTable_attribute) a;
            for (LineNumberTable_attribute.Entry e: t.line_number_table) {
                int start_pc = e.start_pc;
                int line = e.line_number;
                SortedSet<Integer> pcLines = map.get(start_pc);
                if (pcLines == null) {
                    pcLines = new TreeSet<>();
                    map.put(start_pc, pcLines);
                }
                pcLines.add(line);
                allLines.add(line);
            }
        }
    }
    lineMap = map;
    lineList = new ArrayList<>(allLines);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:SourceWriter.java

示例5: setLineMap

import java.util.SortedMap; //导入方法依赖的package包/类
private void setLineMap(Code_attribute attr) {
    SortedMap<Integer, SortedSet<Integer>> map =
            new TreeMap<Integer, SortedSet<Integer>>();
    SortedSet<Integer> allLines = new TreeSet<Integer>();
    for (Attribute a: attr.attributes) {
        if (a instanceof LineNumberTable_attribute) {
            LineNumberTable_attribute t = (LineNumberTable_attribute) a;
            for (LineNumberTable_attribute.Entry e: t.line_number_table) {
                int start_pc = e.start_pc;
                int line = e.line_number;
                SortedSet<Integer> pcLines = map.get(start_pc);
                if (pcLines == null) {
                    pcLines = new TreeSet<Integer>();
                    map.put(start_pc, pcLines);
                }
                pcLines.add(line);
                allLines.add(line);
            }
        }
    }
    lineMap = map;
    lineList = new ArrayList<Integer>(allLines);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:SourceWriter.java

示例6: reduce

import java.util.SortedMap; //导入方法依赖的package包/类
public void reduce(Object key, Iterator values,
                   OutputCollector output, Reporter reporter) throws IOException {
  if (this.reporter == null) {
    this.reporter = reporter;
  }

  SortedMap<Object, ResetableIterator> groups = regroup(key, values, reporter);
  Object[] tags = groups.keySet().toArray();
  ResetableIterator[] groupValues = new ResetableIterator[tags.length];
  for (int i = 0; i < tags.length; i++) {
    groupValues[i] = groups.get(tags[i]);
  }
  joinAndCollect(tags, groupValues, key, output, reporter);
  addLongValue("groupCount", 1);
  for (int i = 0; i < tags.length; i++) {
    groupValues[i].close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:DataJoinReducerBase.java

示例7: getFirstEnabled

import java.util.SortedMap; //导入方法依赖的package包/类
public T getFirstEnabled() {
    SortedMap<String, T> map = enabled.getAsMap();
    if (map.isEmpty()) {
        return null;
    } else {
        return map.get(map.firstKey());
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:DefaultReportContainer.java

示例8: parse

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Method for parsing orders XML.
 * @param is input stream for parsing.
 * @return SortedMap of OrderBook's mapping key name.
 * @throws FileNotFoundException if there is no such file.
 * @throws XMLStreamException The base exception for unexpected processing errors.  This Exception
 * class is used to report well-formedness errors as well as unexpected
 * processing conditions.
 */
public SortedMap<String, OrderBook> parse(InputStream is) throws FileNotFoundException, XMLStreamException {
    SortedMap<String, OrderBook> orders = new TreeMap<>(String::compareTo);
    XMLInputFactory factory = XMLInputFactory.newInstance();
    XMLStreamReader reader = factory.createXMLStreamReader(is);
    OrderBook orderBook;
    String book;
    reader.next();
    while (reader.hasNext()) {
        if (reader.next() == XMLStreamConstants.START_ELEMENT) {
            if (reader.isStartElement()) {
                book = reader.getAttributeValue(null, "book");
                if ("AddOrder".equals(reader.getLocalName())) {
                    if (!orders.containsKey(book)) {
                        orderBook = new OrderBook(book);
                        orders.put(book, orderBook);
                    } else {
                        orderBook = orders.get(book);
                    }
                    orderBook.addOrder(OrderBook.OPERATION.valueOf(reader.getAttributeValue(null, "operation")),
                            Integer.parseInt(reader.getAttributeValue(null, "orderId")),
                            Integer.parseInt(reader.getAttributeValue(null, "volume")),
                            Float.parseFloat(reader.getAttributeValue(null, "price")));
                } else {
                    orders.get(book).delOrder(Integer.parseInt(reader.getAttributeValue(null, "orderId")));
                }
            }
        }
    }
    return orders;
}
 
开发者ID:PavelZubaha,项目名称:pzubaha,代码行数:40,代码来源:StAXParser.java

示例9: getPublicPackagesForPlugin

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Transforms public packages in form of "selected items" map into
 * set of strings describing public packages in maven-nbm-plugin syntax.
 */
public static SortedSet<String> getPublicPackagesForPlugin (SortedMap<String, Boolean> selItems) {
    SortedSet<String> result = new TreeSet<String>();
    Set<String> processed = new HashSet<String>();
    for (Entry<String, Boolean> entry : selItems.entrySet()) {
        if (entry.getValue() && !processed.contains(entry.getKey())) {
            boolean allSubpackages = true;
            Set<String> processedCandidates = new HashSet<String>();
            String prefix = entry.getKey() + ".";
            for (String key : selItems.keySet()) {
                if (key.startsWith(prefix)) {
                    if (selItems.get(key)) {
                        processedCandidates.add(key);
                    } else {
                        allSubpackages = false;
                        break;
                    }
                }
            }
            if (allSubpackages && processedCandidates.size() > COALESCE_LIMIT) {
                result.add(entry.getKey() + ALL_SUBPACKAGES);
                processed.addAll(processedCandidates);
            } else {
                result.add(entry.getKey());
            }
        }
    }

    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:PublicPackagesPanel.java

示例10: selectRepository

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * 
 * @param repositorySpaceMap
 * @param recordSize
 * @return
 * @should select repository with the smallest sufficient space
 * @should return null if recordSize is larger than any available repository space
 */
static DataRepository selectRepository(SortedMap<Long, DataRepository> repositorySpaceMap, long recordSize) {
    if (repositorySpaceMap == null) {
        throw new IllegalArgumentException("repositorySpaceMap may not be null");
    }

    for (Iterator<Long> iterator = repositorySpaceMap.keySet().iterator(); iterator.hasNext();) {
        long storageSize = iterator.next();
        if (recordSize < storageSize) {
            return repositorySpaceMap.get(storageSize);
        }
    }

    return null;
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:23,代码来源:RemainingSpaceStrategy.java

示例11: remove

import java.util.SortedMap; //导入方法依赖的package包/类
public synchronized void remove(Class<?> cls, int begin, int end, T item)
{
	SortedMap<Integer, SortedMap<Integer, Set<T>>> clsMap = map.get(cls);
	if (null==clsMap) {throw new DapException("Tried to remove an item that does not exist.");}
	SortedMap<Integer, Set<T>> beginMap = clsMap.get(begin);
	if (null==beginMap) {throw new DapException("Tried to remove an item that does not exist.");}
	Set<T> items = beginMap.get(end);
	if (null==items) {throw new DapException("Tried to remove an item that does not exist.");}
	for (T anItem : items)
	{
		if (item.getUniqueId()==anItem.getUniqueId())
		{
			items.remove(anItem);
		}
	}
	
	if (items.isEmpty())
	{
		beginMap.remove(end);
	}
	if (beginMap.isEmpty())
	{
		clsMap.remove(begin);
	}
	if (clsMap.isEmpty())
	{
		map.remove(cls);
	}
}
 
开发者ID:document-analysis,项目名称:dap,代码行数:30,代码来源:Index.java

示例12: regroup

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * This is the function that re-groups values for a key into sub-groups based
 * on a secondary key (input tag).
 * 
 * @param arg1
 * @return
 */
private SortedMap<Object, ResetableIterator> regroup(Object key,
                                                     Iterator arg1, Reporter reporter) throws IOException {
  this.numOfValues = 0;
  SortedMap<Object, ResetableIterator> retv = new TreeMap<Object, ResetableIterator>();
  TaggedMapOutput aRecord = null;
  while (arg1.hasNext()) {
    this.numOfValues += 1;
    if (this.numOfValues % 100 == 0) {
      reporter.setStatus("key: " + key.toString() + " numOfValues: "
                         + this.numOfValues);
    }
    if (this.numOfValues > this.maxNumOfValuesPerGroup) {
      continue;
    }
    aRecord = ((TaggedMapOutput) arg1.next()).clone(job);
    Text tag = aRecord.getTag();
    ResetableIterator data = retv.get(tag);
    if (data == null) {
      data = createResetableIterator();
      retv.put(tag, data);
    }
    data.add(aRecord);
  }
  if (this.numOfValues > this.largestNumOfValues) {
    this.largestNumOfValues = numOfValues;
    LOG.info("key: " + key.toString() + " this.largestNumOfValues: "
             + this.largestNumOfValues);
  }
  return retv;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:38,代码来源:DataJoinReducerBase.java

示例13: getShardInfo

import java.util.SortedMap; //导入方法依赖的package包/类
public S getShardInfo(byte[] key) {
  SortedMap<Long, S> tail = nodes.tailMap(algo.hash(key));
  if (tail.isEmpty()) {
    return nodes.get(nodes.firstKey());
  }
  return tail.get(tail.firstKey());
}
 
开发者ID:x7-framework,项目名称:x7,代码行数:8,代码来源:Sharded.java

示例14: getToolOutput

import java.util.SortedMap; //导入方法依赖的package包/类
public ToolOutput getToolOutput(String name, ISubmitFilesService submitFilesService, Long toolSessionId,
    Long learnerId) {
if (name != null) {
    String[] nameParts = splitConditionName(name);
    if (SbmtConstants.SUBMITTED_ITEMS_DEFINITION_NAME.equals(nameParts[0])) {

	SortedMap<SubmitUserDTO, List<FileDetailsDTO>> filesUploadedBySession = submitFilesService
		.getFilesUploadedBySession(toolSessionId, null);
	if (!filesUploadedBySession.isEmpty()) {
	    String serverUrl = Configuration.get(ConfigurationKeys.SERVER_URL);
	    SimpleURL[][] usersAndUrls = new SimpleURL[filesUploadedBySession.keySet().size()][];
	    int userIndex = 0;
	    for (SubmitUserDTO userDTO : filesUploadedBySession.keySet()) {
		List<FileDetailsDTO> files = filesUploadedBySession.get(userDTO);
		if (!files.isEmpty()) {
		    SimpleURL[] urlArray = new SimpleURL[files.size()];
		    int urlIndex = 0;
		    for (FileDetailsDTO filesDetailsDTO : files) {
			String fileUrl = "javascript:var dummy = window.open('" + serverUrl + "download/?uuid="
				+ filesDetailsDTO.getUuID() + "&preferDownload=false&"
				+ AttributeNames.PARAM_TOOL_CONTENT_HANDLER_NAME + "="
				+ SbmtConstants.TOOL_CONTENT_HANDLER_NAME + "','"
				+ filesDetailsDTO.getFileDescription() + "','resizable,scrollbars')";

			SimpleURL url = new SimpleURL(filesDetailsDTO.getFileDescription(), fileUrl);
			urlArray[urlIndex] = url;
			urlIndex++;
		    }
		    usersAndUrls[userIndex] = urlArray;
		}
		userIndex++;
	    }
	    return new ToolOutput(SbmtConstants.SUBMITTED_ITEMS_DEFINITION_NAME,
		    getI18NText(SbmtConstants.SUBMITTED_ITEMS_DEFINITION_NAME, true), usersAndUrls, false);
	}
    }
}
return null;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:40,代码来源:SubmitFilesOutputFactory.java

示例15: getShardInfo

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * 功能描述: 获取分片信息
 * @param key 键
 * @return 分片信息
 */
public S getShardInfo(byte[] key) {
    SortedMap<Long, S> tail = nodes.tailMap(algo.hash(key));
    if (tail.size() == 0) {
        return nodes.get(nodes.firstKey());
    }
    return tail.get(tail.firstKey());
}
 
开发者ID:m18507308080,项目名称:onolisa,代码行数:13,代码来源:DefaultSharded.java


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