本文整理匯總了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());
}
示例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));
}
}
示例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()));
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
示例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();
}