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