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


Java HashMap.keySet方法代码示例

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


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

示例1: WriteMethylationMutationInBED

import java.util.HashMap; //导入方法依赖的package包/类
public static void WriteMethylationMutationInBED(HashMap<String, LinkedList<MethylationMutationRecord>> methyMutMap, String savePath, boolean isOutputAll)
{
    try
    {
        FileWriter fw = new FileWriter(savePath);
        for(String sampleID : methyMutMap.keySet())
        {
            LinkedList<MethylationMutationRecord> methyMutRecList = methyMutMap.get(sampleID);
            for(MethylationMutationRecord methyMutRec : methyMutRecList)
            {
                if(!isOutputAll)
                {
                    if( (methyMutRec.getMutationEvent() == MutationEvent.FunctionalGain) || (methyMutRec.getMutationEvent() == MutationEvent.FunctionalLoss) )
                        fw.write(methyMutRec.toBEDString() + "\n");
                }
                else
                    fw.write(methyMutRec.toBEDString() + "\n");
            }
        }
        fw.close();
    }
    catch(IOException e)
    {
        e.printStackTrace();
    }
}
 
开发者ID:YubinXieSYSU,项目名称:m6ASNP,代码行数:27,代码来源:MutationWriter.java

示例2: uploadFile

import java.util.HashMap; //导入方法依赖的package包/类
public Object uploadFile(String url, HashMap<String, Object> request, String path) throws Throwable {
	byte[] rawFile = readFile(path);
	ArrayList<KVPair<String>> headers = getHeaders(rawFile);
	MobLog.getInstance().d(">>>  file: " + path + "\nurl = " + url + "\nheader = " + headers.toString());

	NetworkTimeOut timeout = new NetworkTimeOut();
	timeout.readTimout = 30000;
	timeout.connectionTimeout = 5000;
	ArrayList<KVPair<String>> values = new ArrayList<KVPair<String>>();
	for (String key : request.keySet()) {
		values.add(new KVPair<String>(key, String.valueOf(request.get(key))));
	}
	ArrayList<KVPair<String>> files = new ArrayList<KVPair<String>>();
	files.add(new KVPair<String>("file", path));
	StringBuilder sb = new StringBuilder();
	HttpResponseCallback callback = newCallback(sb, null);
	NETWORK.httpPost(url, values, files, headers, callback, timeout);
	String resp = sb.toString().trim();
	MobLog.getInstance().d(">>> response: " + resp);
	return processResponse(HASHON.fromJson(resp));
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:22,代码来源:ProtocolBase.java

示例3: sortHashMapByValues

import java.util.HashMap; //导入方法依赖的package包/类
private static LinkedHashMap<String, String> sortHashMapByValues(HashMap<String, String> passedMap) {
    List<String> mapKeys = new ArrayList<>(passedMap.keySet());
    List<String> mapValues = new ArrayList<>(passedMap.values());
    Collections.sort(mapValues);
    Collections.sort(mapKeys);

    LinkedHashMap<String, String> sortedMap = new LinkedHashMap<>();

    for (String val : mapValues) {
        Iterator<String> keyIt = mapKeys.iterator();

        while (keyIt.hasNext()) {
            String key = keyIt.next();
            String comp1 = passedMap.get(key);

            if (comp1.equals(val)) {
                keyIt.remove();
                sortedMap.put(key, val);
                break;
            }
        }
    }
    return sortedMap;
}
 
开发者ID:GrenderG,项目名称:Protestr,代码行数:25,代码来源:LocaleUtils.java

示例4: occurenceAdderSink

import java.util.HashMap; //导入方法依赖的package包/类
/**
	 * Reports how often a sink occurred and how often it occurred without a source
	 * @param sinks
	 * @param sources
	 */
	private static void occurenceAdderSink(HashMap<String, HashSet<String>> sinks, HashMap<String, HashSet<String>> sources, HashMap<String, Integer> sinksOccurred, HashMap<String, Integer> sinksOccurredNoSource) {
		for (String sink : sinks.keySet()) {
//			System.out.println(sink);
			if (sinksOccurred.containsKey(sink)) {
				sinksOccurred.put(sink, sinksOccurred.get(sink)+1);
			} else {
				sinksOccurred.put(sink, 1);
				sinksOccurredNoSource.put(sink,0);
			}
			
			if (sources.isEmpty()) {
				sinksOccurredNoSource.put(sink, sinksOccurredNoSource.get(sink)+1);
			}
		}
	}
 
开发者ID:bjrnmath,项目名称:mutaflow,代码行数:21,代码来源:FlowExtractor.java

示例5: getAncestors

import java.util.HashMap; //导入方法依赖的package包/类
public HashSet<T> getAncestors(T node, int start, int end)
{
    HashSet<T> answer = new HashSet<T>();
    HashMap<Integer, HashMap<T, Counter>> found = ancestors.get(node);
    if (found != null)
    {
        for (Integer key : found.keySet())
        {
            if ((key.intValue() >= start) && (key.intValue() <= end))
            {
                HashMap<T, Counter> asd = found.get(key);
                answer.addAll(asd.keySet());
            }
        }
    }
    return answer;
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:18,代码来源:BridgeTable.java

示例6: removeServer

import java.util.HashMap; //导入方法依赖的package包/类
public static void removeServer() {
    String pName = "RemoveServer";
    while (true) {
        Printer.printPrompt(pName, "Enter the server name that you wish to remove:");
        String input = in.next();
        if (input.equalsIgnoreCase("back") || input.equalsIgnoreCase("b")) {
            return;
        }
        boolean removed = false;
        HashMap<String, Server> serverList = Storage.getServerList();
        synchronized (serverList) {
            for (String s : serverList.keySet()) {
                if (s.equals(input)) {
                    serverList.remove(s);

                    removed = true;
                    break;
                }
            }
        }
        if (removed) {

            Printer.printDataChange(pName, "Server \"" + input + "\" has been removed successfully.");
            return;
        } else {
            Printer.printFailedReply(pName, "Server \"" + input + "\" was not found.");
        }
    }
}
 
开发者ID:OasisArtisan,项目名称:OasisLight-ServerManager,代码行数:30,代码来源:Main.java

示例7: mapSecretKeys

import java.util.HashMap; //导入方法依赖的package包/类
/**
 * If the secret key shares a CKA_LABEL with another entry,
 * throw an exception
 */
private void mapSecretKeys(HashMap<String, AliasInfo> sKeyMap)
            throws KeyStoreException {
    for (String label : sKeyMap.keySet()) {
        if (aliasMap.containsKey(label)) {
            throw new KeyStoreException("invalid KeyStore state: " +
                    "found secret key sharing CKA_LABEL [" +
                    label +
                    "] with another token object");
        }
    }
    aliasMap.putAll(sKeyMap);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:P11KeyStore.java

示例8: organizeTracesByUserAndSort

import java.util.HashMap; //导入方法依赖的package包/类
/**
 * As its name tells, this method returns the given {@code traces} as a
 * hashmap that holds traces per user where the key values hold user ids
 * 
 * @param traces a list that has location traces from multiple users
 * @return location traces organized by user and sorted by date ascending.
 */
public static HashMap<String, List<LocationTrace>> organizeTracesByUserAndSort(
		List<LocationTrace> traces) {
	HashMap<String, List<LocationTrace>> traceMap = new HashMap<String, List<LocationTrace>>();

	// trace organization by user
	for (LocationTrace aTrace : traces) {
		List<LocationTrace> list;
		if (traceMap.containsKey(aTrace.getUserId()) == true) {
			list = traceMap.get(aTrace.getUserId());
		} else {
			list = new ArrayList<LocationTrace>();
			traceMap.put(aTrace.getUserId(), list);
		}
		list.add(aTrace);
	}

	// sorting traces by time ascending

	// comparator object
	Comparator<LocationTrace> comparator = new Comparator<LocationTrace>() {
		public int compare(LocationTrace t1, LocationTrace t2) {
			return (t1.getUTCTime().getMillis() > t2.getUTCTime()
					.getMillis() ? 1 : -1);
		}
	};

	for (String userId : traceMap.keySet()) {
		List<LocationTrace> traceListForUser = traceMap.get(userId);

		Collections.sort(traceListForUser, comparator);
		traceMap.put(userId, traceListForUser);
	}

	return traceMap;
}
 
开发者ID:hamdikavak,项目名称:human-mobility-modeling-utilities,代码行数:43,代码来源:DataHelper.java

示例9: updatePlayerInfo

import java.util.HashMap; //导入方法依赖的package包/类
public void updatePlayerInfo(HashMap<String, String> values) {

        playerInfo = values;
        for (String key : values.keySet()) {
            if (key.equals("name")) {
                name = values.get(key);
            }
            if (key.equals("pid")) {
                pid = values.get(key);
            }
            if (key.equals("ip")) {
                ip = values.get(key);
            }
            if (key.equals("model")) {
                model = values.get(key);
            }
            if (key.equals("version")) {
                version = values.get(key);
            }
            if (key.equals("lineout")) {
                lineout = values.get(key);
            }
            if (key.equals("network")) {
                network = values.get(key);
            }
            if (key.equals("gid")) {
                gid = values.get(key);
            }
        }

    }
 
开发者ID:Wire82,项目名称:org.openhab.binding.heos,代码行数:32,代码来源:HeosPlayer.java

示例10: populateEcmpRoutingRules

import java.util.HashMap; //导入方法依赖的package包/类
/**
 * Populate ECMP rules for subnets from all switches to destination.
 *
 * @param destSw Device ID of destination switch
 * @param ecmpSPG ECMP shortest path graph
 * @param subnets Subnets to be populated. If empty, populate all configured subnets.
 * @return true if succeed
 */
private boolean populateEcmpRoutingRules(DeviceId destSw,
                                         EcmpShortestPathGraph ecmpSPG,
                                         Set<Ip4Prefix> subnets) {

    HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>> switchVia = ecmpSPG
            .getAllLearnedSwitchesAndVia();
    for (Integer itrIdx : switchVia.keySet()) {
        HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>> swViaMap = switchVia
                .get(itrIdx);
        for (DeviceId targetSw : swViaMap.keySet()) {
            Set<DeviceId> nextHops = new HashSet<>();
            log.debug("** Iter: {} root: {} target: {}", itrIdx, destSw, targetSw);
            for (ArrayList<DeviceId> via : swViaMap.get(targetSw)) {
                if (via.isEmpty()) {
                    nextHops.add(destSw);
                } else {
                    nextHops.add(via.get(0));
                }
            }
            if (!populateEcmpRoutingRulePartial(targetSw, destSw, nextHops, subnets)) {
                return false;
            }
        }
    }

    return true;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:36,代码来源:DefaultRoutingHandler.java

示例11: onActivityResult

import java.util.HashMap; //导入方法依赖的package包/类
public static void onActivityResult(String instanceId,int requestCode, int resultCode, Intent data){

    HashMap<String, WXModule> modules = sInstanceModuleMap.get(instanceId);
    if(modules!=null) {
      for (String key : modules.keySet()) {
        WXModule module = modules.get(key);
        if (module != null) {
          module.onActivityResult(requestCode, resultCode, data);
        } else {
          WXLogUtils.w("onActivityResult can not find the " + key + " module");
        }
      }
    }
  }
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:15,代码来源:WXModuleManager.java

示例12: getDistances

import java.util.HashMap; //导入方法依赖的package包/类
private static HashMap<String, Distance<TimeSeries<Accel>>> getDistances() {
  HashMap<String, Distance<TimeSeries<Accel>>> hashMap =
      new HashMap<String, Distance<TimeSeries<Accel>>>();
  Complexity<Accel> complexityEstimate = new Complexity<Accel>(new EuclideanDistance());
  HashMap<String, AdjustmentWindowCondition> conditions = getConditions();
  for (String conditionName : conditions.keySet()) {
    AdjustmentWindowCondition condition = conditions.get(conditionName);
    hashMap.put(
        "DTW;" + conditionName,
        new DynamicTimeWarping<Accel>(new EuclideanDistance(), condition)
    );
    hashMap.put(
        "ηDTW;" + conditionName,
        new NormalizedDistance<Accel>(
            new DynamicTimeWarping<Accel>(new EuclideanDistance(), condition),
            new ZeroMean<Accel>(new Add(),  new ScalarMult())
        )
    );
    hashMap.put(
        "η'DTW;" + conditionName,
        new NormalizedDistance<Accel>(
            new DynamicTimeWarping<Accel>(new EuclideanDistance(), condition),
            new ZeroMeanOneVariance<Accel>(
                new EuclideanDistance(),
                new Add(),
                new ScalarMult()
            )
        )
    );
  }
  return hashMap;
}
 
开发者ID:GordonLesti,项目名称:SlidingWindowFilter-evaluator,代码行数:33,代码来源:App.java

示例13: addAncestors

import java.util.HashMap; //导入方法依赖的package包/类
/**
 * @param parent T
 * @param child T
 */
private void addAncestors(T parent, T child)
{
    HashMap<Integer, HashMap<T, Counter>> childsAncestors = ancestors.get(child);
    if (childsAncestors == null)
    {
        childsAncestors = new HashMap<Integer, HashMap<T, Counter>>();
        ancestors.put(child, childsAncestors);
    }

    HashMap<Integer, HashMap<T, Counter>> parentAncestorsToAdd = ancestors.get(parent);

    // add all the childs children to the parents descendants

    add(parentAncestorsToAdd, Integer.valueOf(0), childsAncestors, parent);

    // add childs descendants to all parents ancestors at the correct depth

    HashMap<Integer, HashMap<T, Counter>> descenantsToFixUp = descendants.get(child);

    if (descenantsToFixUp != null)
    {
        for (Integer descendantPosition : descenantsToFixUp.keySet())
        {
            HashMap<T, Counter> descenantsToFixUpAtPosition = descenantsToFixUp.get(descendantPosition);
            for (T descenantToFixUpAtPosition : descenantsToFixUpAtPosition.keySet())
            {
                HashMap<Integer, HashMap<T, Counter>> descendatAncestors = ancestors.get(descenantToFixUpAtPosition);
                add(parentAncestorsToAdd, descendantPosition, descendatAncestors, parent);
            }
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:37,代码来源:BridgeTable.java

示例14: organizeExtendedTracesByUserAndSort

import java.util.HashMap; //导入方法依赖的package包/类
public static HashMap<String, List<ExtendedLocationTrace>> organizeExtendedTracesByUserAndSort(
		List<ExtendedLocationTrace> traces) {
	HashMap<String, List<ExtendedLocationTrace>> traceMap = new HashMap<String, List<ExtendedLocationTrace>>();

	// trace organization by user
	for (ExtendedLocationTrace aTrace : traces) {
		List<ExtendedLocationTrace> list;
		if (traceMap.containsKey(aTrace.getUserId()) == true) {
			list = traceMap.get(aTrace.getUserId());
		} else {
			list = new ArrayList<ExtendedLocationTrace>();
			traceMap.put(aTrace.getUserId(), list);
		}
		list.add(aTrace);
	}

	// sorting traces by time ascending

	// comparator object
	Comparator<LocationTrace> comparator = new Comparator<LocationTrace>() {
		public int compare(LocationTrace t1, LocationTrace t2) {
			return (t1.getUTCTime().getMillis() > t2.getUTCTime()
					.getMillis() ? 1 : -1);
		}
	};

	for (String userId : traceMap.keySet()) {
		List<ExtendedLocationTrace> traceListForUser = traceMap.get(userId);

		Collections.sort(traceListForUser, comparator);
		traceMap.put(userId, traceListForUser);
	}

	return traceMap;
}
 
开发者ID:hamdikavak,项目名称:human-mobility-modeling-utilities,代码行数:36,代码来源:DataHelper.java

示例15: handleNewObjectElement

import java.util.HashMap; //导入方法依赖的package包/类
/*******************
 * Handle a new object element in the ReplyData stream.
 * 
 * @param obj The RMIObject to populate with class names.
 * @param dataStack The remaining data in the ReplyData packet.
 ******************/
private void handleNewObjectElement(RMIObject obj, LinkedList<Byte> dataStack) throws BaRMIeInvalidReplyDataPacketException {
	LinkedList<HashMap<Byte, ArrayList<Character>>> classDataDesc;
	HashMap<Byte, ArrayList<Character>> classDataDescElement;
	ArrayList<Character> classDataDescFields;
	
	//Reset the field data
	this._classDataDesc.clear();
	
	//Read the class desc
	this.handleClassDesc(obj, dataStack);
	
	//Set the 'recordClasses' flag to false so that no further classes are added to the object description
	this._recordClasses = false;
	
	//Create a fresh copy of the class data description to use in reading the object data
	classDataDesc = new LinkedList<HashMap<Byte, ArrayList<Character>>>();
	for(HashMap<Byte, ArrayList<Character>> el: this._classDataDesc) {
		classDataDescElement = new HashMap<Byte, ArrayList<Character>>();
		for(Byte key: el.keySet()) {
			classDataDescFields = new ArrayList<Character>();
			for(Character typeCode: el.get(key)) {
				classDataDescFields.add(typeCode);
			}
			classDataDescElement.put(key, classDataDescFields);
		}
		classDataDesc.add(classDataDescElement);
	}
	
	//Read in the class data based on the classDataDesc
	this.handleClassData(obj, dataStack, classDataDesc);
}
 
开发者ID:NickstaDB,项目名称:BaRMIe,代码行数:38,代码来源:RMIReplyDataParser.java


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