当前位置: 首页>>代码示例>>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;未经允许,请勿转载。