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


Java HashMap.containsKey方法代码示例

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


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

示例1: getCachedAuditTrailLogModel

import java.util.HashMap; //导入方法依赖的package包/类
public static EcrfFieldValueAuditTrailLogEagerModel getCachedAuditTrailLogModel(ProbandListEntryOutVO listEntry,
		HashMap<Long, EcrfFieldValueAuditTrailLogEagerModel> auditTrailLogModelCache) {
	EcrfFieldValueAuditTrailLogEagerModel model;
	if (listEntry != null && auditTrailLogModelCache != null) {
		long listEntryId = listEntry.getId();
		if (auditTrailLogModelCache.containsKey(listEntryId)) {
			model = auditTrailLogModelCache.get(listEntryId);
		} else {
			model = new EcrfFieldValueAuditTrailLogEagerModel();
			model.setListEntryId(listEntryId);
			auditTrailLogModelCache.put(listEntryId, model);
		}
	} else {
		model = new EcrfFieldValueAuditTrailLogEagerModel();
	}
	return model;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:18,代码来源:EcrfFieldValueAuditTrailLogEagerModel.java

示例2: extractUniqueLocationIdCounts

import java.util.HashMap; //导入方法依赖的package包/类
/**
 * This methods returns a unique location Id number list using given trace list.
 * @param traces trace list
 * @return unique ids in a list
 */
public HashMap<Long,Integer> extractUniqueLocationIdCounts(
		List<ExtendedLocationTrace> traces) {
	HashMap<Long,Integer> idMap = new HashMap<Long, Integer>();
	
	for(ExtendedLocationTrace aTrace: traces){
		
		// all location ids start from 1. if there is a lower number, it is likely that DBSCAN assigned noise to that visit
		if(aTrace.getLocationId()>0){ 
			int count = 0;
			
			if (idMap.containsKey(aTrace.getLocationId()) == true){
				count = idMap.get(aTrace.getLocationId());
			}
			count++;
			idMap.put(aTrace.getLocationId(), count);
		}
	}
	return idMap ;
}
 
开发者ID:hamdikavak,项目名称:human-mobility-modeling-utilities,代码行数:25,代码来源:LocationTraceHelper.java

示例3: getCachedCollidingVisitScheduleItemModel

import java.util.HashMap; //导入方法依赖的package包/类
public static CollidingVisitScheduleItemEagerModel getCachedCollidingVisitScheduleItemModel(ProbandStatusEntryOutVO statusEntry, boolean allProbandGroups,
		HashMap<Long, CollidingVisitScheduleItemEagerModel> collidingVisitScheduleItemModelCache) {
	CollidingVisitScheduleItemEagerModel model;
	if (statusEntry != null && collidingVisitScheduleItemModelCache != null) {
		long probandStatusEntryId = statusEntry.getId();
		if (collidingVisitScheduleItemModelCache.containsKey(probandStatusEntryId)) {
			model = collidingVisitScheduleItemModelCache.get(probandStatusEntryId);
		} else {
			model = new CollidingVisitScheduleItemEagerModel(probandStatusEntryId, allProbandGroups);
			collidingVisitScheduleItemModelCache.put(probandStatusEntryId, model);
		}
	} else {
		model = new CollidingVisitScheduleItemEagerModel(allProbandGroups);
	}
	return model;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:17,代码来源:CollidingVisitScheduleItemEagerModel.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: SrlgGraphSearch

import java.util.HashMap; //导入方法依赖的package包/类
/**
 * Creates an SRLG graph search object from a map, inferring
 * the number of groups and creating an integral mapping.
 *
 * @param   grouping    map linking edges to object group assignments,
 *                      with same-group status linked to equality
 */
public SrlgGraphSearch(Map<E, Object> grouping) {
    if (grouping == null) {
        useSuurballe = true;
        return;
    }
    numGroups = 0;
    HashMap<Object, Integer> tmpMap = new HashMap<>();
    riskGrouping = new HashMap<>();
    for (E key: grouping.keySet()) {
        Object value = grouping.get(key);
        if (!tmpMap.containsKey(value)) {
            tmpMap.put(value, numGroups);
            numGroups++;
        }
        riskGrouping.put(key, tmpMap.get(value));
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:SrlgGraphSearch.java

示例6: doInBackground

import java.util.HashMap; //导入方法依赖的package包/类
@Override
protected HashMap<String, Integer> doInBackground(Void... params) {
    Cursor cursor = context.getContentResolver().query(
            CouponContract.CouponTable.URI,
            CouponContract.CouponTable.PROJECTION,
            CouponContract.CouponTable.COLUMN_VALID_UNTIL + " = ?",
            new String[]{ String.valueOf(Utilities.getLongDateToday()) },
            CouponContract.CouponTable.COLUMN_VALID_UNTIL
    );
    if (cursor == null) {
        return null;
    }

    HashMap<String, Integer> merchantCouponCountMap = new HashMap<>();
    while (cursor.moveToNext()) {
        Coupon coupon = Coupon.getCoupon(cursor);
        int count = 1;
        if (merchantCouponCountMap.containsKey(coupon.merchant)) {
            count += merchantCouponCountMap.get(coupon.merchant);
        }
        merchantCouponCountMap.put(coupon.merchant, count);
    }
    return merchantCouponCountMap;
}
 
开发者ID:darsh2,项目名称:CouponsTracker,代码行数:25,代码来源:CouponsTrackerNotification.java

示例7: getOpenNoParticipationSummary

import java.util.HashMap; //导入方法依赖的package包/类
public MoneyTransferSummaryVO getOpenNoParticipationSummary(ProbandOutVO proband) {
	if (trialId != null && proband != null) {
		HashMap<Long, MoneyTransferSummaryVO> cache;
		MoneyTransferSummaryVO summary;
		if (noParticipationOpenSummaryCache.containsKey(trialId)) {
			cache = noParticipationOpenSummaryCache.get(trialId);
			if (cache.containsKey(proband.getId())) {
				summary = cache.get(proband.getId());
			} else {
				summary = WebUtil.getProbandOpenReimbursementSummary(trialId, proband.getId(), null);
				cache.put(proband.getId(), summary);
			}
		} else {
			cache = new HashMap<Long, MoneyTransferSummaryVO>();
			noParticipationOpenSummaryCache.put(trialId, cache);
			summary = WebUtil.getProbandOpenReimbursementSummary(trialId, proband.getId(), null);
			cache.put(proband.getId(), summary);
		}
		return summary;
	}
	return null;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:23,代码来源:ReimbursementsBean.java

示例8: setInputModelErrorMsgs

import java.util.HashMap; //导入方法依赖的package包/类
private void setInputModelErrorMsgs(Object data) {
	HashMap<Long, String> errorMessagesMap;
	try {
		errorMessagesMap = (HashMap<Long, String>) data;
	} catch (ClassCastException e) {
		errorMessagesMap = null;
	}
	if (errorMessagesMap != null && errorMessagesMap.size() > 0) {
		Iterator<ProbandListEntryTagInputModel> it = inputModels.iterator();
		while (it.hasNext()) {
			ProbandListEntryTagInputModel inputModel = it.next();
			if (errorMessagesMap.containsKey(inputModel.getProbandListTagId())) {
				inputModel.setErrorMessage(errorMessagesMap.get(inputModel.getProbandListTagId()));
			} else {
				inputModel.setErrorMessage(null);
			}
		}
	} else {
		clearInputModelErrorMsgs();
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:22,代码来源:ProbandListEntryTagValueBean.java

示例9: countGames

import java.util.HashMap; //导入方法依赖的package包/类
private void countGames(HashMap<String, AtomicInteger> hm, int length, String startsWith) {
    for (String game : games) {
        String str = null;
        if (game.length() >= length) {
            str = game.substring(0, length);
        }
        if (str != null && (startsWith == null || str.startsWith(startsWith))) {
            if (hm.containsKey(str)) {
                hm.get(str).incrementAndGet();
            } else {
                hm.put(str, new AtomicInteger(1));
            }
        }
    }
    if (length == 1) {
        checkKeys(hm, length);
    }
}
 
开发者ID:phweda,项目名称:MFM,代码行数:19,代码来源:MAME_Game_Prefixes.java

示例10: dispatchSBDExport

import java.util.HashMap; //导入方法依赖的package包/类
/**
 * Generates the necessary files for the forms upload to the SeaBioData repository
 */
private void dispatchSBDExport() throws IOException {


    SharedPreferences settings = getSharedPreferences(getString(R.string.app_name), MODE_PRIVATE);

    if (!settings.contains(Utils.TAG_SBD_USERNAME)) {
        Toast.makeText(this, getString(R.string.sbd_username_missing_export), Toast.LENGTH_SHORT).show();
        return;
    }

    HashMap<String, ArrayList<FormInstance>> groupedInstances = new HashMap<>();
    for (FormInstance fi : currentItem.getLinkedForms()) {
        if (groupedInstances.containsKey(fi.getParent())) {
            groupedInstances.get(fi.getParent()).add(fi);
            continue;
        }

        ArrayList<FormInstance> newInstances = new ArrayList<>();
        newInstances.add(fi);
        groupedInstances.put(fi.getParent(), newInstances);
    }


    for (String key : groupedInstances.keySet()) {
        FormExportItem exportItem = new FormExportItem(groupedInstances.get(key), settings.getString(Utils.TAG_SBD_USERNAME, ""));
        File file = new File(Environment.getExternalStorageDirectory() + File.separator + key + "_" + new Date().toString() + ".json");

        if(file.createNewFile()) {
            OutputStream fo = new FileOutputStream(file);
            fo.write(new Gson().toJson(exportItem).getBytes());
            fo.close();
        }
    }

    Toast.makeText(getApplicationContext(), getString(R.string.sbd_dorms_exported_successfully), Toast.LENGTH_SHORT).show();
}
 
开发者ID:feup-infolab,项目名称:labtablet,代码行数:40,代码来源:FavoriteDetailsActivity.java

示例11: annotateWithPileup

import java.util.HashMap; //导入方法依赖的package包/类
private Double annotateWithPileup(final AlignmentContext stratifiedContext, final VariantContext vc) {

        final HashMap<Byte, Integer> alleleCounts = new HashMap<>();
        for (final Allele allele : vc.getAlleles())
            alleleCounts.put(allele.getBases()[0], 0);

        final ReadBackedPileup pileup = stratifiedContext.getBasePileup();
        for (final PileupElement p : pileup) {
            if (alleleCounts.containsKey(p.getBase()))
                alleleCounts.put(p.getBase(), alleleCounts.get(p.getBase()) + 1);
        }

        // we need to add counts in the correct order
        final int[] counts = new int[alleleCounts.size()];
        counts[0] = alleleCounts.get(vc.getReference().getBases()[0]);
        for (int i = 0; i < vc.getAlternateAlleles().size(); i++)
            counts[i + 1] = alleleCounts.get(vc.getAlternateAllele(i).getBases()[0]);

        // sanity check
        if (counts[0] + counts[1] == 0)
            return null;

        return ((double) counts[0] / (double) (counts[0] + counts[1]));
    }
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:25,代码来源:AlleleBalanceBySample.java

示例12: twoSum

import java.util.HashMap; //导入方法依赖的package包/类
public int[] twoSum(int[] nums, int target) {
    int len = nums.length;
    HashMap<Integer, Integer> map = new HashMap<>();
    for (int i = 0; i < len; ++i) {
        if (map.containsKey(nums[i])) {
            return new int[]{map.get(nums[i]), i};
        }
        map.put(target - nums[i], i);
    }
    return null;
}
 
开发者ID:laidu,项目名称:java-learn,代码行数:12,代码来源:TwoSum.java

示例13: main

import java.util.HashMap; //导入方法依赖的package包/类
public static void main(String[] args) {

    //create HashMap object
    HashMap hMap = new HashMap();

    //add key value pairs to HashMap
    hMap.put("1", "One");
    hMap.put("2", "Two");
    hMap.put("3", "Three");

    /*
      get Set of keys contained in HashMap using
      Set keySet() method of HashMap class
    */

    Set st = hMap.keySet();

    System.out.println("Set created from HashMap Keys contains :");
    //iterate through the Set of keys
    Iterator itr = st.iterator();
    while (itr.hasNext()) System.out.println(itr.next());

    /*
       Please note that resultant Set object is backed by the HashMap.
       Any key that is removed from Set will also be removed from
       original HashMap object. The same is not the case with the element
       addition.
    */

    //remove 2 from Set
    st.remove("2");

    //check if original HashMap still contains 2
    boolean blnExists = hMap.containsKey("2");
    System.out.println("Does HashMap contain 2 ? " + blnExists);
  }
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:37,代码来源:GetSetViewOfKeysFromHashMapExample.java

示例14: occurrenceAnalyzer

import java.util.HashMap; //导入方法依赖的package包/类
/**
 * Reports Flows where the sink did not occur for all mutated files. It also reports how often a sink occurred and whether it occurred for files where no source was mutated.
 * @param flowocc
 * @param sinkCounter
 * @param occurredForNoSource
 * @param fileCounter
 * @param writer
 * @param flowPosition 
 * @param crashReports 
 */
private static void occurrenceAnalyzer(HashMap<String, HashMap<String, Integer>> flowocc, HashMap<String, Integer> sinkCounter, HashSet<String> occurredForNoSource,float fileCounter, int noMutationCounter, 
		PrintWriter writer, HashMap<String, HashMap<String, String>> flowPosition, HashMap<String, HashMap<String, Boolean>> crashReports, HashMap<String, HashSet<String>> refoundFlows) {
	if (notCondensed) {
		writer.write("\nDroidMutant found the following flows. Such without a number indicate flows, where a value was again found in the sink: \n");
	}
	for (Entry<String, HashSet<String>> ent : refoundFlows.entrySet()) {
		for (String sink : ent.getValue()) {
			writer.write(ent.getKey()+"\t"+sink+"\n");
			refoundCounter++;
		}
	}
	
	for (Entry<String,HashMap<String, Integer>> sourceEntry : flowocc.entrySet()) {
		for (Entry<String,Integer> sinkEntry : sourceEntry.getValue().entrySet()) {
			if (!sinkCounter.get(sinkEntry.getKey()).equals(fileCounter)) {  //if sink did not occur for all mutated files
				float sinkCount = sinkCounter.get(sinkEntry.getKey());
				if (!occurredForNoSource.contains(sinkEntry.getKey())) {
					if ((!refoundFlows.containsKey(sourceEntry.getKey())) || (!refoundFlows.get(sourceEntry.getKey()).contains(sinkEntry.getKey()))) {
						writer.write(sourceEntry.getKey()+"\t"+sinkEntry.getKey()+"\t"+sinkCount+"\t"+fileCounter + "\t" + (occurredForNoSource.contains(sinkEntry.getKey()) ? 0 : 1)+"\t"+noMutationCounter+ "\n");
					}
					HashMap<String, Boolean> currentAPKMap = crashReports.get(FlowExtractor.currentAPK);

					//crashes with NPE if Converter was not run firstly
					boolean crashed = false;

					
					System.out.println(flowPosition.get(sourceEntry.getKey()).get(sinkEntry.getKey()) +" " + sourceEntry.getKey() + " " + sinkEntry.getKey() + " " + crashed );
				}
			}
		}
	}
}
 
开发者ID:bjrnmath,项目名称:mutaflow,代码行数:43,代码来源:FlowExtractor.java

示例15: checkLogin

import java.util.HashMap; //导入方法依赖的package包/类
private boolean checkLogin(HttpRequest request) {
    boolean res = false;
    // в запросе должен быть пароль и пользователь, если нету, то отказ на вход
    String entityContent = NetUtil.getEntityContent(request);
    QLog.l().logger().trace("Принятые параметры \"" + entityContent + "\".");
    // ресурс для выдачи в браузер. это либо список отчетов при корректном логининге или отказ на вход
    // разбирем параметры
    final HashMap<String, String> cookie = NetUtil.getCookie(entityContent, "&");
    if (cookie.containsKey("username") && cookie.containsKey("password")) {
        if (isTrueUser(cookie.get("username"), cookie.get("password"))) {
            res = true;
        }
    }
    return res;
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:16,代码来源:QReportsList.java


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