本文整理匯總了Java中java.util.TreeMap.putAll方法的典型用法代碼示例。如果您正苦於以下問題:Java TreeMap.putAll方法的具體用法?Java TreeMap.putAll怎麽用?Java TreeMap.putAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.TreeMap
的用法示例。
在下文中一共展示了TreeMap.putAll方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRemovedSymmetryGraph
import java.util.TreeMap; //導入方法依賴的package包/類
public TreeMap<T, LinkedList<Edge>> getRemovedSymmetryGraph() {
if(graphType != GraphType.UNDIRECTED)
return edgesByVertices;
TreeMap<T, LinkedList<Edge>> edgesByVertexes_copy = new TreeMap<>();
edgesByVertexes_copy.putAll(edgesByVertices);
// 대칭 그래프 삭제
for(LinkedList<Edge> edges1 : edgesByVertices.values()) {
for(Edge edge1 : edges1) {
LinkedList<Edge> edges2 = edgesByVertexes_copy.get(edge1.getToVertex());
for(int i=0 ; i<edges2.size() ; i++) {
Edge edge2 = edges2.get(i);
if(edge2.getToVertex().equals(edge1.getFromVertex()))
edges2.remove();
}
}
}
return edgesByVertexes_copy;
}
示例2: printBrokerRuntimeStats
import java.util.TreeMap; //導入方法依賴的package包/類
public void printBrokerRuntimeStats(final DefaultMQAdminExt defaultMQAdminExt, final String brokerAddr,
final boolean printBroker) throws InterruptedException, MQBrokerException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException {
KVTable kvTable = defaultMQAdminExt.fetchBrokerRuntimeStats(brokerAddr);
// 為了排序
TreeMap<String, String> tmp = new TreeMap<String, String>();
tmp.putAll(kvTable.getTable());
Iterator<Entry<String, String>> it = tmp.entrySet().iterator();
while (it.hasNext()) {
Entry<String, String> next = it.next();
if (printBroker) {
System.out.printf("%-24s %-32s: %s%n", brokerAddr, next.getKey(), next.getValue());
} else {
System.out.printf("%-32s: %s%n", next.getKey(), next.getValue());
}
}
}
示例3: printBrokerRuntimeStats
import java.util.TreeMap; //導入方法依賴的package包/類
public void printBrokerRuntimeStats(final DefaultMQAdminExt defaultMQAdminExt, final String brokerAddr,
final boolean printBroker) throws InterruptedException, MQBrokerException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException {
KVTable kvTable = defaultMQAdminExt.fetchBrokerRuntimeStats(brokerAddr);
TreeMap<String, String> tmp = new TreeMap<String, String>();
tmp.putAll(kvTable.getTable());
Iterator<Entry<String, String>> it = tmp.entrySet().iterator();
while (it.hasNext()) {
Entry<String, String> next = it.next();
if (printBroker) {
System.out.printf("%-24s %-32s: %s%n", brokerAddr, next.getKey(), next.getValue());
} else {
System.out.printf("%-32s: %s%n", next.getKey(), next.getValue());
}
}
}
示例4: getPlayerWorldObjectSubset
import java.util.TreeMap; //導入方法依賴的package包/類
/**
* returns subset of BaseEffects (and their probabilities) in knowledge
* referring to the same type of marioWorldObjects
*
* @param playerWorldObject
* @return
*/
public TreeMap<Effect, Double> getPlayerWorldObjectSubset(
PlayerWorldObject playerWorldObject) {
// iterate over all entries in knowledge
TreeMap<Effect, Double> effectMap = new TreeMap<Effect, Double>();
for (Entry<ConditionDirectionPair, TreeMap<Effect, Double>> entry : knowledge
.entrySet()) {
Condition currCond = entry.getKey().condition;
PlayerWorldObject currObj = currCond.getTarget();
// if the entry concerns the right MarioWorldObject, add all known
// effect and probabilities to the map
if (currObj == Generalizer.generalizePlayerWorldObject(playerWorldObject)) {
effectMap.putAll(entry.getValue());
}
}
return effectMap;
}
示例5: buildResource
import java.util.TreeMap; //導入方法依賴的package包/類
/**
* 將path、queryParam、formParam合成一個字符串
*
*/
private static String buildResource(String pathWithParams, Map<String, String> queryParams, Map<String, String> formParams) {
StringBuilder result = new StringBuilder();
result.append(pathWithParams);
//使用TreeMap,默認按照字母排序
TreeMap<String, String> parameter = new TreeMap<String, String>();
if (MapUtils.isNotEmpty(queryParams)) {
parameter.putAll(queryParams);
}
if (MapUtils.isNotEmpty(formParams)) {
parameter.putAll(formParams);
}
if (parameter.size() > 0) {
result.append("?");
// bugfix by [email protected]: "kv separator should be ignored while value is empty, ex. k1=v1&k2&k3=v3&k4"
List<String> comboMap = new ArrayList<String>();
for(Entry<String, String> entry : parameter.entrySet()){
String comboResult = entry.getKey() + (StringUtils.isNotEmpty(entry.getValue())? "="+entry.getValue() : StringUtils.EMPTY);
comboMap.add(comboResult);
}
Joiner joiner = Joiner.on("&");
result.append(joiner.join(comboMap));
}
return result.toString();
}
示例6: testPutAll
import java.util.TreeMap; //導入方法依賴的package包/類
/**
* putAll adds all key-value pairs from the given map
*/
public void testPutAll() {
TreeMap empty = new TreeMap();
TreeMap map = map5();
empty.putAll(map);
assertEquals(5, empty.size());
assertTrue(empty.containsKey(one));
assertTrue(empty.containsKey(two));
assertTrue(empty.containsKey(three));
assertTrue(empty.containsKey(four));
assertTrue(empty.containsKey(five));
}
示例7: toString
import java.util.TreeMap; //導入方法依賴的package包/類
@Override
public String toString() {
//order settings by key before printing them out, for readability
TreeMap<String, ScriptMode> scriptModesTreeMap = new TreeMap<>();
scriptModesTreeMap.putAll(scriptModes);
StringBuilder stringBuilder = new StringBuilder();
for (Map.Entry<String, ScriptMode> stringScriptModeEntry : scriptModesTreeMap.entrySet()) {
stringBuilder.append(stringScriptModeEntry.getKey()).append(": ").append(stringScriptModeEntry.getValue()).append("\n");
}
return stringBuilder.toString();
}
示例8: getUserDefinedMap
import java.util.TreeMap; //導入方法依賴的package包/類
public Map<String, String> getUserDefinedMap() {
TreeMap<String, String> result;
synchronized (lock) {
result = new TreeMap<>(map.comparator());
result.putAll(map);
}
return result;
}
示例9: toMap
import java.util.TreeMap; //導入方法依賴的package包/類
public Map<String, String> toMap() {
TreeMap<String, String> result;
synchronized (lock) {
result = new TreeMap<>(map.comparator());
result.putAll(hostEnv);
result.putAll(map);
}
return result;
}
示例10: toString
import java.util.TreeMap; //導入方法依賴的package包/類
@Override
public String toString() {
//order settings by key before printing them out, for readability
TreeMap<String, Boolean> scriptModesTreeMap = new TreeMap<>();
scriptModesTreeMap.putAll(scriptEnabled);
StringBuilder stringBuilder = new StringBuilder();
for (Map.Entry<String, Boolean> stringScriptModeEntry : scriptModesTreeMap.entrySet()) {
stringBuilder.append(stringScriptModeEntry.getKey()).append(": ").append(stringScriptModeEntry.getValue()).append("\n");
}
return stringBuilder.toString();
}
示例11: execute
import java.util.TreeMap; //導入方法依賴的package包/類
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
try {
defaultMQAdminExt.start();
String brokerAddr = commandLine.getOptionValue('b').trim();
//獲取broker一些全局統計信息 例如commitlog 全局offset等信息
KVTable kvTable = defaultMQAdminExt.fetchBrokerRuntimeStats(brokerAddr);
TreeMap<String, String> tmp = new TreeMap<String, String>();
tmp.putAll(kvTable.getTable());
Iterator<Entry<String, String>> it = tmp.entrySet().iterator();
while (it.hasNext()) {
Entry<String, String> next = it.next();
System.out.printf("%-32s: %s\n", next.getKey(), next.getValue());
}
}
catch (Exception e) {
e.printStackTrace();
}
finally {
defaultMQAdminExt.shutdown();
}
}
示例12: getPackages
import java.util.TreeMap; //導入方法依賴的package包/類
private Map<String, Integer> getPackages(Node n, String curPath, boolean dumpAllPackages) {
TreeMap<String, Integer> res = new TreeMap<String, Integer>();
if (n.hasClasses() || dumpAllPackages)
res.put(curPath + n.name, n.clazzCount);
if (!n.isLeaf()) {
for (Node c: n.childs) {
res.putAll(getPackages(c, curPath + (n.name.equals("Root")? "" : n.name + "."), dumpAllPackages));
}
}
return res;
}
示例13: populateTreeMap
import java.util.TreeMap; //導入方法依賴的package包/類
protected void populateTreeMap(final HierarchicalStreamReader reader, final UnmarshallingContext context,
final TreeMap<?, ?> result, Comparator<?> comparator) {
final boolean inFirstElement = comparator == NULL_MARKER;
if (inFirstElement) {
comparator = null;
}
@SuppressWarnings("unchecked")
final SortedMap<Object, Object> sortedMap = new PresortedMap<Object, Object>(
(Comparator<Object>)(comparator != null && JVM.hasOptimizedTreeMapPutAll() ? comparator : null));
if (inFirstElement) {
// we are already within the first entry
putCurrentEntryIntoMap(reader, context, result, sortedMap);
reader.moveUp();
}
populateMap(reader, context, result, sortedMap);
@SuppressWarnings("unchecked")
final TreeMap<Object, Object> typedResult = (TreeMap<Object, Object>)result;
try {
if (JVM.hasOptimizedTreeMapPutAll()) {
if (comparator != null && comparatorField != null) {
comparatorField.set(result, comparator);
}
typedResult.putAll(sortedMap); // internal optimization will not call comparator
} else if (comparatorField != null) {
comparatorField.set(result, sortedMap.comparator());
typedResult.putAll(sortedMap); // "sort" by index
comparatorField.set(result, comparator);
} else {
typedResult.putAll(sortedMap); // will use comparator for already sorted map
}
} catch (final IllegalAccessException e) {
throw new ConversionException("Cannot set comparator of TreeMap", e);
}
}
示例14: statisticsOriginal
import java.util.TreeMap; //導入方法依賴的package包/類
private static void statisticsOriginal(File inputFile, File outputFile, File outputFileChanges, File graphicsFolder) throws IOException, Exception {
BufferedWriter bw=new BufferedWriter(new FileWriter(outputFile));
bw.write("\t");
bw.write("\t");
bw.write(HitStatistic.getHeaderString());
bw.write("\t\t");
bw.write(HitStatistic.getHeaderString());
bw.write("\tat least one hit");
bw.newLine();
TreeMap<String, MassBank> massbankFilesOriginal=Utils.getAllDBFiles(originalDBFolders, ser, false, false);
TreeMap<String, Map<MassBank, HitDescription>> stats=new TreeMap<String, Map<MassBank, HitDescription>>();
for (int i=0;i<querys.length;i++){
TreeMap<String, Map<MassBank, HitDescription>> statsTmp=new TreeMap<String, Map<MassBank, HitDescription>>();
TreeMap<String, HitStatistic> allHitstatistics=new TreeMap<String, HitStatistic>();
TreeMap<String, HitStatistic> allHitstatisticsDifferentMassesExcluded=new TreeMap<String, HitStatistic>();
String queryLong=querys[i];
String decoy="Original";
System.out.println("statisticsOriginal: "+queryLong+decoy);
bw.write(queryLong+decoy);bw.newLine();
for(String searchMethod:searchMethodsStatisticsOriginal){
File hitstatistics = new File(inputFile.getAbsolutePath()+sep+searchMethod+sep+"HitStatistic_"+queryLong+decoy+".txt");
File hitstatisticsDifferentMassesExcluded = new File(inputFile.getAbsolutePath()+sep+searchMethod+sep+"HitStatistic_DifferentMassesExcluded_"+queryLong+decoy+".txt");
if(hitstatistics.exists()&&hitstatisticsDifferentMassesExcluded.exists()){
HitStatistic hits=new HitStatistic(hitstatistics, massbankFilesOriginal);
bw.write(searchMethod+"\tall\t");
bw.write(hits.toEntryString());
Map<MassBank, HitDescription> stat=hits.getHitDescription();
stats.put(queryLong+decoy+"-"+searchMethod, stat);
allHitstatistics.put(queryLong+decoy+"-"+searchMethod, hits);
hits=new HitStatistic(hitstatisticsDifferentMassesExcluded, massbankFilesOriginal);
bw.write("\tdifferent masses excluded:\t");
bw.write(hits.toEntryString());
bw.write("\t"+hits.getNumberEntriesWithAtLeastOneHit());
stat=hits.getHitDescription();
statsTmp.put(queryLong+decoy+"-"+searchMethod+"-SameMass", stat);
allHitstatisticsDifferentMassesExcluded.put(queryLong+decoy+"-"+searchMethod+"-SameMass", hits);
bw.newLine();
}
bw.flush();
}
HitStatistic.writeROCCurves(new File(graphicsFolder.getAbsolutePath()+sep+"ROCCurve_"+queryLong+decoy+".jpg"), allHitstatistics);
HitStatistic.writeROCCurves(new File(graphicsFolder.getAbsolutePath()+sep+"ROCCurve_DifferentMassesExcluded_"+queryLong+decoy+".jpg"), allHitstatisticsDifferentMassesExcluded);
stats.putAll(statsTmp);
}
bw.close();
compareSearchMethods(outputFileChanges, stats);
}
示例15: statisticsHighFDR
import java.util.TreeMap; //導入方法依賴的package包/類
private static void statisticsHighFDR(File inputFile, File outputFile, File outputFileChanges, File graphicsFolder) throws IOException, Exception {
BufferedWriter bw=new BufferedWriter(new FileWriter(outputFile));
bw.write("\t\t");
bw.write(HitStatistic.getHeaderString());
bw.write("\tat least one hit");
bw.newLine();
TreeMap<String, MassBank> massbankFilesOriginal=Utils.getAllDBFiles(originalDBFolders, ser, false, false);
TreeMap<String, Map<MassBank, HitDescription>> stats=new TreeMap<String, Map<MassBank, HitDescription>>();
for (int i=0;i<querys.length;i++){
TreeMap<String, Map<MassBank, HitDescription>> statsTmp=new TreeMap<String, Map<MassBank, HitDescription>>();
TreeMap<String, HitStatistic> allHitstatisticsDifferentMassesExcluded=new TreeMap<String, HitStatistic>();
String queryLong=querys[i];
String decoy="Original";
System.out.println("statisticsOriginal: "+queryLong+decoy);
bw.write(queryLong+decoy);bw.newLine();
for(String searchMethod:searchMethodsStatisticsOriginal){
File hitstatisticsDifferentMassesExcluded = new File(inputFile.getAbsolutePath()+sep+searchMethod+sep+"HitStatistic_DMEHighFDR_"+queryLong+decoy+".txt");
if(hitstatisticsDifferentMassesExcluded.exists()){
HitStatistic hits=new HitStatistic(hitstatisticsDifferentMassesExcluded, massbankFilesOriginal);
bw.write("searchMethod\tdifferent masses excluded:\t");
bw.write(hits.toEntryString());
bw.write("\t"+hits.getNumberEntriesWithAtLeastOneHit());
Map<MassBank, HitDescription> stat=hits.getHitDescription();
statsTmp.put(queryLong+decoy+"-"+searchMethod+"-SameMass", stat);
allHitstatisticsDifferentMassesExcluded.put(queryLong+decoy+"-"+searchMethod+"-SameMass", hits);
bw.newLine();
}
bw.flush();
}
HitStatistic.writeROCCurves(new File(graphicsFolder.getAbsolutePath()+sep+"ROCCurve_DMEHighFDR_"+queryLong+decoy+".jpg"), allHitstatisticsDifferentMassesExcluded);
stats.putAll(statsTmp);
}
bw.close();
compareSearchMethods(outputFileChanges, stats);
}