當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。