當前位置: 首頁>>代碼示例>>Java>>正文


Java LinkedHashMap.clear方法代碼示例

本文整理匯總了Java中java.util.LinkedHashMap.clear方法的典型用法代碼示例。如果您正苦於以下問題:Java LinkedHashMap.clear方法的具體用法?Java LinkedHashMap.clear怎麽用?Java LinkedHashMap.clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.LinkedHashMap的用法示例。


在下文中一共展示了LinkedHashMap.clear方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import java.util.LinkedHashMap; //導入方法依賴的package包/類
public static void main(String[] args) {

    //create LinkedHashMap object
    LinkedHashMap lHashMap = new LinkedHashMap();

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

    /*
      To remove all values or clear LinkedHashMap use
      void clear method() of LinkedHashMap class. Clear method removes all
      key value pairs contained in LinkedHashMap.
    */

    lHashMap.clear();

    System.out.println("Total key value pairs in LinkedHashMap are : " + lHashMap.size());
  }
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:21,代碼來源:EmptyLinkedHashMapExample.java

示例2: getHaplotypeMapFromAlleles

import java.util.LinkedHashMap; //導入方法依賴的package包/類
public static void getHaplotypeMapFromAlleles(final List<Allele> alleleList,
                                              final ReferenceContext ref,
                                              final GenomeLoc loc,
                                              final LinkedHashMap<Allele, Haplotype> haplotypeMap) {
    // protect against having an indel too close to the edge of a contig
    if (loc.getStart() <= HAPLOTYPE_SIZE)
        haplotypeMap.clear();
        // check if there is enough reference window to create haplotypes (can be an issue at end of contigs)
    else if (ref.getWindow().getStop() < loc.getStop() + HAPLOTYPE_SIZE)
        haplotypeMap.clear();
    else if (alleleList.isEmpty())
        haplotypeMap.clear();
    else {
        final int eventLength = getEventLength(alleleList);
        final int hsize = ref.getWindow().size() - Math.abs(eventLength) - 1;
        final int numPrefBases = ref.getLocus().getStart() - ref.getWindow().getStart() + 1;

        if (hsize <= 0)  // protect against event lengths larger than ref window sizes
            haplotypeMap.clear();
        else
            haplotypeMap.putAll(Haplotype.makeHaplotypeListFromAlleles(alleleList, loc.getStart(),
                    ref, hsize, numPrefBases));
    }
}
 
開發者ID:PAA-NCIC,項目名稱:SparkSeq,代碼行數:25,代碼來源:IndelGenotypeLikelihoodsCalculationModel.java

示例3: sortScopes

import java.util.LinkedHashMap; //導入方法依賴的package包/類
/**
 * Sorts the scopes map using {@link ContextScope#getOrder()}
 * @param scopes Scopes map to sort
 */
private static void sortScopes(LinkedHashMap<String, ContextScope> scopes) {
	List<Map.Entry<String, ContextScope>> entries = new ArrayList<>(scopes.entrySet());
	scopes.clear();
	entries.stream()
			.sorted(Comparator.comparing(Map.Entry::getValue, Comparator.comparingInt((v) -> v.getOrder())))
			.forEachOrdered(e -> scopes.put(e.getKey(), e.getValue()));
}
 
開發者ID:holon-platform,項目名稱:holon-core,代碼行數:12,代碼來源:ContextManager.java

示例4: visitTryStatement

import java.util.LinkedHashMap; //導入方法依賴的package包/類
@Override
public String visitTryStatement(JavaParser.TryStatementContext ctx) {
	// 'try' block (catchClause+ finallyBlock? | finallyBlock)
	LinkedHashMap<String, JavaClass> tempLocalVariables = new LinkedHashMap<>();
	tempLocalVariables.putAll(localVariables);
	visit(ctx.block());
	localVariables.clear();
	localVariables.putAll(tempLocalVariables);

	if (ctx.finallyBlock() != null) {
		// 'finally' block
		tempLocalVariables.clear();
		tempLocalVariables.putAll(localVariables);
		visit(ctx.finallyBlock().block());
		localVariables.clear();
		localVariables.putAll(tempLocalVariables);
	}

	// Now visit any available catch clauses
	if (ctx.catchClause() != null && ctx.catchClause().size() > 0) {
		// 'catch' '(' variableModifier* catchType Identifier ')' block

		for (JavaParser.CatchClauseContext cx : ctx.catchClause()) {
			tempLocalVariables.clear();
			tempLocalVariables.putAll(localVariables);
			String name = cx.Identifier().getText();
			//Assume that the catch type is a simple class name, for now
			String type = cx.catchType().getText();
			localVariables.put(name, findClassbyName(type));
			visit(cx.block());
			localVariables.clear();
			localVariables.putAll(tempLocalVariables);
		}
	}

	return null;
}
 
開發者ID:ghaffarian,項目名稱:progex,代碼行數:38,代碼來源:JavaICFGBuilder.java

示例5: readGroupedEntryMap

import java.util.LinkedHashMap; //導入方法依賴的package包/類
protected static <T extends GroupedBiomeEntry> void readGroupedEntryMap(JsonObject readFrom, LinkedHashMap<String, T> list, String tagname, Class<T> clazz) {
    list.clear();
    if (readFrom.has(tagname)) {
        JsonObject b = JsonUtil.getAsObject(readFrom, tagname);
        readGroupedEntryMap(b, list, clazz);
    }
}
 
開發者ID:stuebz88,項目名稱:modName,代碼行數:8,代碼來源:BiomeSettings.java

示例6: readJsonableMap

import java.util.LinkedHashMap; //導入方法依賴的package包/類
static <T extends IJsonMappable> void readJsonableMap(JsonObject o, LinkedHashMap<String, T> list, String tagname, Class<T> clazz) {
    list.clear();
    if (o.has(tagname)) {
        JsonArray g = JsonUtil.getAsArray(o, tagname); //o.getAsJsonArray(tagname);
        for (JsonElement element : g) {
            T def = IJsonable.create(clazz);
            JsonObject eo;
            /*try {
                eo = element.getAsJsonObject();
            } catch (Exception e) {
                return;
            }*/
            eo = JsonUtil.asObject(element);
            def.fromJson(eo);
            list.put(def.getMapKey(), def);
        }
    }

}
 
開發者ID:stuebz88,項目名稱:modName,代碼行數:20,代碼來源:Settings.java

示例7: execBulkRequestForNavigationProperty

import java.util.LinkedHashMap; //導入方法依賴的package包/類
/**
 * NP経由ユーザデータをバルク登録する.
 * @param npBulkContexts NavigationPropertyコンテキストのリスト
 */
private void execBulkRequestForNavigationProperty(List<NavigationPropertyBulkContext> npBulkContexts) {
    // バルク登録用にコンテキストからBulkRequestを作成
    // NP側のEntityTypeの存在チェック、バルクデータ內でのID競合チェックもここで行う
    LinkedHashMap<String, BulkRequest> npBulkRequests = new LinkedHashMap<String, BulkRequest>();
    for (NavigationPropertyBulkContext npBulkContext : npBulkContexts) {
        BatchBodyPart bodyPart = npBulkContext.getBodyPart();
        BulkRequest bulkRequest = new BulkRequest(bodyPart);
        String key = PersoniumUUID.randomUUID();

        if (npBulkContext.isError()) {
            bulkRequest.setError(npBulkContext.getException());
            npBulkRequests.put(key, bulkRequest);
            continue;
        }

        String targetEntitySetName = bodyPart.getTargetEntitySetName();
        bulkRequest = createBulkRequest(bodyPart, targetEntitySetName);
        // データ內でのID競合チェック
        // TODO 複合主キー対応、ユニークキーのチェック、NTKP対応
        if (bulkRequest.getError() == null) {
            EntitySetDocHandler docHandler = bulkRequest.getDocHandler();
            key = docHandler.getEntityTypeId() + ":" + (String) docHandler.getStaticFields().get("__id");
            if (npBulkRequests.containsKey(key)) {
                key = PersoniumUUID.randomUUID();
                bulkRequest.setError(PersoniumCoreException.OData.ENTITY_ALREADY_EXISTS);
            }
        }

        npBulkRequests.put(key, bulkRequest);
    }

    try {
        this.odataResource.getODataProducer().bulkCreateEntityViaNavigationProperty(npBulkContexts, npBulkRequests);
    } catch (PersoniumCoreException e) {
        // 503が発生した後の処理を継続させるため、shutterにステータスを設定。
        shutter.updateStatus(e);
        if (!PersoniumCoreException.Misc.TOO_MANY_CONCURRENT_REQUESTS.equals(e)) {
            throw e;
        } else {
            createTooManyConcurrentResponse(npBulkContexts);
        }
    }
    npBulkRequests.clear();
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:49,代碼來源:ODataBatchResource.java


注:本文中的java.util.LinkedHashMap.clear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。