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


Java Map.remove方法代碼示例

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


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

示例1: AlloyModel

import java.util.Map; //導入方法依賴的package包/類
/** Construct a new AlloyModel object.
 * @param types - the types; we will always add "univ" to it if it's not there already
 * @param sets - the sets
 * @param rels - the relations
 * @param map - we consult this "sig to parent sig" map and extract the mappings relevant to this model.
 * (If we detect a cycle, we will arbitrarily break the cycle)
 */
public AlloyModel(Collection<AlloyType> types
      , Collection<AlloySet> sets
      , Collection<AlloyRelation> rels
      , Map<AlloyType,AlloyType> map) {
   // The following 3 have to be tree sets, since we want to keep them sorted
   Set<AlloyType> allTypes = new TreeSet<AlloyType>();
   Set<AlloySet> allSets = new TreeSet<AlloySet>();
   Set<AlloyRelation> allRelations = new TreeSet<AlloyRelation>();
   allTypes.addAll(types);
   allTypes.add(AlloyType.UNIV);
   for(AlloySet s:sets) if (allTypes.contains(s.getType())) allSets.add(s);
   for(AlloyRelation r:rels) if (allTypes.containsAll(r.getTypes())) allRelations.add(r);
   this.types=Collections.unmodifiableSet(allTypes);
   this.sets=Collections.unmodifiableSet(allSets);
   this.relations=Collections.unmodifiableSet(allRelations);
   Map<AlloyType,AlloyType> newmap=new LinkedHashMap<AlloyType,AlloyType>();
   for(AlloyType type:allTypes) {
      AlloyType sup = isCycle(map,type) ? null : map.get(type);
      if (sup==null || !allTypes.contains(sup)) sup=AlloyType.UNIV;
      newmap.put(type,sup);
   }
   newmap.remove(AlloyType.UNIV); // This ensures univ is not in hierarchy's keySet
   this.hierarchy=Collections.unmodifiableMap(newmap);
   for(AlloyType t: this.types) this.name2types.put(t.getName(), t);
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:33,代碼來源:AlloyModel.java

示例2: parseDoubleParam

import java.util.Map; //導入方法依賴的package包/類
/**
 * Extracts a 0-1 inclusive double from the settings map, otherwise throws an exception
 *
 * @param settings      Map of settings provided to this model
 * @param name          Name of parameter we are attempting to extract
 * @param defaultValue  Default value to be used if value does not exist in map
 * @return Double value extracted from settings map
 */
protected double parseDoubleParam(@Nullable Map<String, Object> settings, String name, double defaultValue) throws ParseException {
    if (settings == null) {
        return defaultValue;
    }

    Object value = settings.get(name);
    if (value == null) {
        return defaultValue;
    } else if (value instanceof Number) {
        double v = ((Number) value).doubleValue();
        if (v >= 0 && v <= 1) {
            settings.remove(name);
            return v;
        }

        throw new ParseException("Parameter [" + name + "] must be between 0-1 inclusive.  Provided"
                + "value was [" + v + "]", 0);
    }

    throw new ParseException("Parameter [" + name + "] must be a double, type `"
            + value.getClass().getSimpleName() + "` provided instead", 0);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:31,代碼來源:MovAvgModel.java

示例3: deleteCustomType

import java.util.Map; //導入方法依賴的package包/類
@Override
public void deleteCustomType(String modelName, String typeName)
{
    // Check the current user is authorised to delete the custom model's type
    validateCurrentUser();

    if(typeName == null)
    {
        throw new InvalidArgumentException(TYPE_NAME_NULL_ERR);
    }

    ModelDetails existingModelDetails = new ModelDetails(getCustomModelImpl(modelName));
    if(existingModelDetails.isActive())
    {
        throw new ConstraintViolatedException("cmm.rest_api.type_cannot_delete");
    }

    Map<String, CustomType> allTypes = transformToMap(existingModelDetails.getTypes(), toNameFunction());
    CustomType typeToBeDeleted = allTypes.get(typeName);

    if(typeToBeDeleted == null)
    {
        throw new EntityNotFoundException(typeName);
    }

    // Validate type's dependency
    validateTypeAspectDelete(allTypes.values(), typeToBeDeleted.getPrefixedName());

    // Remove the validated type
    allTypes.remove(typeName);
    existingModelDetails.setTypes(new ArrayList<>(allTypes.values()));

    updateModel(existingModelDetails, "cmm.rest_api.type_delete_failure");
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:35,代碼來源:CustomModelsImpl.java

示例4: process

import java.util.Map; //導入方法依賴的package包/類
public void process(Map<String, Object> entries)
{
	String value = (String)entries.remove(key);
	try
	{
		value = URLDecoder.decode(value, "UTF-8");
		Matcher matcher = pattern.matcher(value);
		if(matcher.matches())
		{
			String nodeRefStr = matcher.group(1);
			boolean isNodeRef = NodeRef.isNodeRef(nodeRefStr);
			if(isNodeRef)
			{
				NodeRef nodeRef = new NodeRef(nodeRefStr);
				entries.put("objectId", nodeRef.getId());
			}
			else
			{
				logger.warn("Activity page url contains an invalid NodeRef " + value);
			}
		}
		else
		{
			logger.warn("Failed to match activity page url for objectId extraction " + value);
		}
	}
	catch (UnsupportedEncodingException e)
	{
		logger.warn("Unable to decode activity page url " + value);
	}
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:32,代碼來源:BaseActivitySummaryProcessor.java

示例5: removeExclusions

import java.util.Map; //導入方法依賴的package包/類
private static void removeExclusions(Map<String, CompiledClass> classes,
    List<String> exclusions) {
  for (String exclusion : exclusions) {
    exclusion = exclusion.replace('.', '/');
    classes.remove(exclusion);
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:8,代碼來源:AnalyzeSerializablesJUnitTest.java

示例6: unregisterFromTopic

import java.util.Map; //導入方法依賴的package包/類
public void unregisterFromTopic(String topicName, String consumerName) {
    Map<String, List<Message>> consumerMap = topicMessages.get(topicName);

    if (consumerMap == null) {
        return;
    }

    if (consumerMap.containsKey(consumerName)) {
        consumerMap.remove(consumerMap);
    }
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:12,代碼來源:MemoryMessageHandler.java

示例7: getRuntimeOptions

import java.util.Map; //導入方法依賴的package包/類
public Map<String, List<String>> getRuntimeOptions() {
    Map<String, List<String>> runtimeOptions = courgetteRuntimeOptions.mapRuntimeOptions();

    if (courgetteRunLevel.equals(CourgetteRunLevel.SCENARIO) && lineId != null) {
        final String featurePath = runtimeOptions.get(null).get(0);

        final List<String> scenarioPath = new ArrayList<>();
        scenarioPath.add(String.format("%s:%s", featurePath, lineId));
        runtimeOptions.put(null, scenarioPath);

        runtimeOptions.remove("--tags");
    }
    return runtimeOptions;
}
 
開發者ID:prashant-ramcharan,項目名稱:courgette-jvm,代碼行數:15,代碼來源:CourgetteRunnerInfo.java

示例8: disposeItem

import java.util.Map; //導入方法依賴的package包/類
private void disposeItem ( final Extractor extractor, final String localId )
{
    logger.debug ( "Dispose item: {}", localId );

    final Map<String, DataItemInputChained> cache = this.itemCache.get ( extractor );
    final DataItemInputChained item = cache.remove ( localId );
    if ( item == null )
    {
        logger.debug ( "Item not found" );
        return;
    }

    this.storage.removed ( new org.eclipse.scada.da.server.browser.common.query.ItemDescriptor ( item, null ) );
    this.itemFactory.disposeItem ( localId );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:16,代碼來源:ParserComponent.java

示例9: setConnection

import java.util.Map; //導入方法依賴的package包/類
public static void setConnection(String id, SqlSession session) {
    Map<String, SqlSession> map = sessionHolder.get();
    if (null == map) {
        map = new HashMap<>();
    }
    if (null == session) {
        map.remove(id);
    } else {
        map.put(id, session);
    }
    sessionHolder.remove();
    sessionHolder.set(map);
}
 
開發者ID:nuls-io,項目名稱:nuls,代碼行數:14,代碼來源:SessionManager.java

示例10: show

import java.util.Map; //導入方法依賴的package包/類
public void show(Long id, Map<String, Object> context) {
    Override override = overrideService.findById(id);
    
    Map<String, String> parameters = parseQueryString(override.getParams());

    if(parameters.get(DEFAULT_MOCK_JSON_KEY) != null) {
        String mock = URL.decode(parameters.get(DEFAULT_MOCK_JSON_KEY));
        String[] tokens = parseMock(mock);
        context.put(FORM_DEFAULT_MOCK_METHOD_FORCE, tokens[0]);
        context.put(FORM_DEFAULT_MOCK_METHOD_JSON, tokens[1]);
        parameters.remove(DEFAULT_MOCK_JSON_KEY);
    }
    
    Map<String, String> method2Force = new LinkedHashMap<String, String>();
    Map<String, String> method2Json = new LinkedHashMap<String, String>();
    
    for (Iterator<Map.Entry<String, String>> iterator = parameters.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<String, String> e =  iterator.next();
        String key = e.getKey();
        
        if(key.endsWith(MOCK_JSON_KEY_POSTFIX)) {
            String m = key.substring(0, key.length() - MOCK_JSON_KEY_POSTFIX.length());
            parseMock(m, e.getValue(), method2Force, method2Json);
            iterator.remove();
        }
    }
    
    context.put("methodForces", method2Force);
    context.put("methodJsons", method2Json);
    context.put("parameters", parameters);
    context.put("override", override);
}
 
開發者ID:yunhaibin,項目名稱:dubbox-hystrix,代碼行數:33,代碼來源:Overrides.java

示例11: mergeIdentities

import java.util.Map; //導入方法依賴的package包/類
private Map<String, Set<String>> mergeIdentities(
		Collection<PersonIdent> persons) {
	Map<String, Set<String>> namesToEmails = new TreeMap<String, Set<String>>(
			caseInsensitveComparator);
	namesToEmails.putAll(RepositoryUtils.mapNamesToEmails(persons));
	Map<String, Set<String>> emailsToNames = RepositoryUtils
			.mapEmailsToNames(persons);
	for (Entry<String, Set<String>> entry : emailsToNames.entrySet())
		for (String name : entry.getValue())
			namesToEmails.get(name).add(entry.getKey());

	Object[] nameEntries = namesToEmails.entrySet().toArray();
	for (int i = 0; i < nameEntries.length; i++) {
		@SuppressWarnings("unchecked")
		Entry<String, Set<String>> curr = (Entry<String, Set<String>>) nameEntries[i];
		if (curr == null)
			continue;
		for (int j = 0; j < nameEntries.length; j++) {
			if (i == j)
				continue;
			for (String email : curr.getValue().toArray(
					new String[curr.getValue().size()])) {
				@SuppressWarnings("unchecked")
				Entry<String, Set<String>> other = (Entry<String, Set<String>>) nameEntries[j];
				if (other == null)
					continue;
				if (other.getValue().contains(email)) {
					curr.getValue().addAll(other.getValue());
					namesToEmails.remove(other.getKey());
					nameEntries[j] = null;
				}
			}
		}
	}
	return namesToEmails;
}
 
開發者ID:forweaver,項目名稱:forweaver2.0,代碼行數:37,代碼來源:GitInfo.java

示例12: removeParameters

import java.util.Map; //導入方法依賴的package包/類
public URL removeParameters(String... keys) {
    if (keys == null || keys.length == 0) {
        return this;
    }
    Map<String, String> map = new HashMap<String, String>(getParameters());
    for (String key : keys) {
        map.remove(key);
    }
    if (map.size() == getParameters().size()) {
        return this;
    }
    return new URL(protocol, username, password, host, port, path, map);
}
 
開發者ID:tiglabs,項目名稱:jsf-core,代碼行數:14,代碼來源:URL.java

示例13: addParameter

import java.util.Map; //導入方法依賴的package包/類
protected void addParameter(String option, String name, Object value) {
	Map<String, Object> params = iParams.get(option);
	if (params == null) { params = new HashMap<String, Object>(); iParams.put(option, params); }
	if (value == null)
		params.remove(name);
	else
		params.put(name, value);
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:9,代碼來源:TeachingRequestsFilterBackend.java

示例14: unregisterConnection

import java.util.Map; //導入方法依賴的package包/類
@Override
public void unregisterConnection(ContactId c, TransportId t,
		boolean incoming) {
	if (LOG.isLoggable(INFO)) {
		if (incoming) LOG.info("Incoming connection unregistered: " + t);
		else LOG.info("Outgoing connection unregistered: " + t);
	}
	boolean lastConnection = false;
	lock.lock();
	try {
		Map<ContactId, Integer> m = connections.get(t);
		if (m == null) throw new IllegalArgumentException();
		Integer count = m.remove(c);
		if (count == null) throw new IllegalArgumentException();
		if (count == 1) {
			if (m.isEmpty()) connections.remove(t);
		} else {
			m.put(c, count - 1);
		}
		count = contactCounts.get(c);
		if (count == null) throw new IllegalArgumentException();
		if (count == 1) {
			lastConnection = true;
			contactCounts.remove(c);
		} else {
			contactCounts.put(c, count - 1);
		}
	} finally {
		lock.unlock();
	}
	eventBus.broadcast(new ConnectionClosedEvent(c, t, incoming));
	if (lastConnection) {
		LOG.info("Contact disconnected");
		eventBus.broadcast(new ContactDisconnectedEvent(c));
	}
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:37,代碼來源:ConnectionRegistryImpl.java

示例15: checkTriplePatternGroup

import java.util.Map; //導入方法依賴的package包/類
@Test
   public void checkTriplePatternGroup() {
TriplePattern tp11 = new TriplePattern("?a", "knows", "?b");
TriplePattern tp21 = new TriplePattern("?b", "knows", "?c");
TriplePattern tp31 = new TriplePattern("?a", "knows", "?c");
TriplePattern tp41 = new TriplePattern("?t", "knows", "X");
TriplePattern tp51 = new TriplePattern("?b", "?t", "Y");

List<TriplePattern> bgp = new ArrayList<TriplePattern>();
bgp.add(tp11);
bgp.add(tp21);
bgp.add(tp31);
bgp.add(tp41);
bgp.add(tp51);

Map<CompositeKey, List<ResultValue>> nodeResults = new HashMap<CompositeKey, List<ResultValue>>();
List<ResultValue> l1 = new ArrayList<>();
l1.add(new ResultValue("knows", "b"));
List<ResultValue> l2 = new ArrayList<>();
l2.add(new ResultValue("knows", "b2"));
nodeResults.put(new CompositeKey(tp31.getStringRepresentation(),
	Position.SUBJECT), l1);
nodeResults.put(new CompositeKey(tp11.getStringRepresentation(),
	Position.SUBJECT), l2);

// Correct result
assertEquals(true, BGPVerifyUtil.checkTriplePatternGroup(
	new CompositeKey(tp11.getStringRepresentation(),
		Position.SUBJECT), nodeResults, bgp));
assertEquals(true, BGPVerifyUtil.checkTriplePatternGroup(
	new CompositeKey(tp31.getStringRepresentation(),
		Position.SUBJECT), nodeResults, bgp));

// Result missing
assertEquals(false, BGPVerifyUtil.checkTriplePatternGroup(
	new CompositeKey(tp11.getStringRepresentation(),
		Position.OBJECT), nodeResults, bgp));

// Result empty
nodeResults.clear();
l1.clear();
l1.add(new ResultValue("likes", "Y"));
nodeResults.put(new CompositeKey(tp51.getStringRepresentation(),
	Position.PREDICATE), l1);
nodeResults.put(new CompositeKey(tp41.getStringRepresentation(),
	Position.SUBJECT), new ArrayList<ResultValue>());

assertEquals(false, BGPVerifyUtil.checkTriplePatternGroup(
	new CompositeKey(tp51.getStringRepresentation(),
		Position.PREDICATE), nodeResults, bgp));

// Result null
nodeResults.remove(new CompositeKey(tp41.getStringRepresentation(),
	Position.SUBJECT));
assertEquals(false, BGPVerifyUtil.checkTriplePatternGroup(
	new CompositeKey(tp51.getStringRepresentation(),
		Position.PREDICATE), nodeResults, bgp));
   }
 
開發者ID:aschaetzle,項目名稱:S2X,代碼行數:59,代碼來源:BGPVerifyUtilTest.java


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