当前位置: 首页>>代码示例>>Java>>正文


Java HashMap.remove方法代码示例

本文整理汇总了Java中java.util.HashMap.remove方法的典型用法代码示例。如果您正苦于以下问题:Java HashMap.remove方法的具体用法?Java HashMap.remove怎么用?Java HashMap.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.HashMap的用法示例。


在下文中一共展示了HashMap.remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: nodeProperty

import java.util.HashMap; //导入方法依赖的package包/类
@Usage("node-property <id> <key>")
@Named("node-property")
@Command
public void nodeProperty(InvocationContext<ObjectName> context,
                         @Usage("the node id") @Required @Argument final String id,
                         @Usage("the property key") @Required @Argument final String key) throws Exception {
    HashMap<String, Object> node = Server.db.getNode(id);
    if (node == null) {
        throw new Err(Status.NOT_FOUND);
    } else {
        node.remove(key);
        Server.db.updateNode(id, node);
        node = Server.db.getNode(id);
        context.append(mapper.writeValueAsString(node));
    }
}
 
开发者ID:maxdemarzi,项目名称:GuancialeDB,代码行数:17,代码来源:delete.java

示例2: relationshipProperty

import java.util.HashMap; //导入方法依赖的package包/类
@Usage("relationship-property <type> <from> <to> <key>")
@Named("relationship-property")
@Command
public void relationshipProperty(InvocationContext<ObjectName> context,
                                 @Usage("the relationship type") @Required @Argument final String type,
                                 @Usage("the starting node") @Required @Argument final String from,
                                 @Usage("the ending node") @Required @Argument final String to,
                                 @Usage("the property key") @Required @Argument final String key) throws Exception {
    HashMap<String, Object>  rel = Server.db.getRelationship(type, from, to);
    if (rel == null) {
        throw new Err(Status.NOT_FOUND);
    } else {
        rel.remove(key);
        Server.db.updateRelationship(type, from, to, rel);
        rel = Server.db.getRelationship(type, from, to);
        context.append(mapper.writeValueAsString(rel));
    }
}
 
开发者ID:maxdemarzi,项目名称:GuancialeDB,代码行数:19,代码来源:delete.java

示例3: fetchPositionListIndexesStatic

import java.util.HashMap; //导入方法依赖的package包/类
protected static List<PositionListIndex> fetchPositionListIndexesStatic(List<HashMap<String, IntArrayList>> clusterMaps, boolean isNullEqualNull) {
	List<PositionListIndex> clustersPerAttribute = new ArrayList<>();
	for (int columnId = 0; columnId < clusterMaps.size(); columnId++) {
		List<IntArrayList> clusters = new ArrayList<>();
		HashMap<String, IntArrayList> clusterMap = clusterMaps.get(columnId);
		
		if (!isNullEqualNull)
			clusterMap.remove(null);
		
		for (IntArrayList cluster : clusterMap.values())
			if (cluster.size() > 1)
				clusters.add(cluster);
		
		clustersPerAttribute.add(new PositionListIndex(columnId, clusters));
	}
	return clustersPerAttribute;
}
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:18,代码来源:PLIBuilder.java

示例4: removeLastItem

import java.util.HashMap; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public void removeLastItem() {
	try {
		// remove the item from the cache
		HashMap cache = getCache();
		if (cache != null) {
			Object item = getItem(m_pool.getSize() - 1);
			cache.remove(item);
		}
		
		// remove the actual item
		// based off of LongVector.addElement()
		Object items = m_items.get(m_pool);
		Object[][] objects = (Object[][])m_objects.get(items);
		int numElements = (Integer)m_elements.get(items) - 1;
		int nth = numElements >> 7;
		int offset = numElements & (128 - 1);
		objects[nth][offset] = null;
		
		// decrement the number of items
		m_elements.set(items, numElements);
		m_numItems.set(m_pool, (Integer)m_numItems.get(m_pool) - 1);
	} catch (Exception ex) {
		throw new Error(ex);
	}
}
 
开发者ID:cccssw,项目名称:enigma-vk,代码行数:27,代码来源:ConstPoolEditor.java

示例5: deleteKVConfig

import java.util.HashMap; //导入方法依赖的package包/类
public void deleteKVConfig(final String namespace, final String key) {
    try {
        this.lock.writeLock().lockInterruptibly();
        try {
            HashMap<String, String> kvTable = this.configTable.get(namespace);
            if (null != kvTable) {
                String value = kvTable.remove(key);
                log.info("deleteKVConfig delete a config item, Namespace: {} Key: {} Value: {}", //
                    namespace, key, value);
            }
        }
        finally {
            this.lock.writeLock().unlock();
        }
    }
    catch (InterruptedException e) {
        log.error("deleteKVConfig InterruptedException", e);
    }

    this.persist();
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:22,代码来源:KVConfigManager.java

示例6: testGetItemsMissingValue

import java.util.HashMap; //导入方法依赖的package包/类
@Test
public void testGetItemsMissingValue() throws Exception {
    // Get test bean
    ConfigurationBean bean = getTestBean();

    // Remove one default value from controller settings
    HashMap<String, Setting> def_settings = platformService
            .getControllerSettings("ess.common",
                    new PasswordAuthentication("user", "password"));
    def_settings.remove(ControllerConfigurationKey.BSS_ORGANIZATION_ID
            .name());
    def_settings.remove("TEST1");
    platformService.storeControllerSettings("ess.common", def_settings,
            new PasswordAuthentication("user", "password"));

    // Get default items (missing value must be defined with an empty
    // string!)
    List<ConfigurationItem> items = bean.getAccessItems();
    assertNotNull(items);
    assertEquals(4, items.size());

    // Check the missing value
    ConfigurationItem item = findItem(items, "BSS_ORGANIZATION_ID");
    assertEquals("", item.getValue());
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:26,代码来源:ConfigurationBeanTest.java

示例7: main

import java.util.HashMap; //导入方法依赖的package包/类
public static void main(String[] args) {
    HashMap<Integer, Integer> map = new HashMap<>();
    ArrayDeque<Integer> deque     = new ArrayDeque<>();
    
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    int max = 0;
    
    for (int i = 0; i < n; i++) {
        /* Remove old value (if necessary) */
        if (i >= m) {
            int old = deque.removeFirst();
            if (map.get(old) == 1) {
                map.remove(old);
            } else {
                map.merge(old, -1, Integer::sum);
            }
        }
        
        /* Add new value */
        int num = scan.nextInt();
        deque.addLast(num);
        map.merge(num, 1, Integer::sum);
        
        max = Math.max(max, map.size());
    }
    
    scan.close();
    System.out.println(max);
}
 
开发者ID:MohamedSondo,项目名称:ACE_HackerRank,代码行数:32,代码来源:Solution.java

示例8: getTopTags

import java.util.HashMap; //导入方法依赖的package包/类
public CSList<TextTag> getTopTags(int nTags, HashMap<String,TextTag> tags) throws Exception {
    int resLen = nTags < tags.size() ? nTags : tags.size();
    CSList<TextTag> res = new CSList<TextTag>();
    String tag = null;
    float maxWeight;
    for (int i = 0;i < resLen;i++)
    {
        maxWeight = Float.MIN_VALUE;
        for (TextTag t : tags.values())
        {
            if (t.getWeight() > maxWeight)
            {
                tag = t.getWord();
                maxWeight = t.getWeight();
            }
             
        }
        res.add(new TextTag(tag, maxWeight, true));
        tags.remove(tag);
        if (res.size() > nTags)
            break;
         
    }
    return res;
}
 
开发者ID:datancoffee,项目名称:sirocco,代码行数:26,代码来源:NonEnglishIndexer.java

示例9: resetToken

import java.util.HashMap; //导入方法依赖的package包/类
/**
    * Reset the saved transaction token from request in the user's session.
    * 
    * @param request
    *            The servlet request
    */
   public synchronized void resetToken(HttpServletRequest request) {
HttpSession session = request.getSession(false);
if (session == null) {
    return;
}

HashMap tokens = getTokens(session);
if (tokens == null) {
    return;
}

String token = getTokenFromRequest(request);
if (token == null) {
    return;
}

tokens.remove(token);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:TokenProcessor.java

示例10: markComponent

import java.util.HashMap; //导入方法依赖的package包/类
public void markComponent(Component comp, int dx, int dy) {
	HashMap<Location, String> avoid = this.avoid;
	boolean translated = dx != 0 || dy != 0;
	Bounds bds = comp.getBounds();
	int x0 = bds.getX() + dx;
	int y0 = bds.getY() + dy;
	int x1 = x0 + bds.getWidth();
	int y1 = y0 + bds.getHeight();
	x0 += 9 - (x0 + 9) % 10;
	y0 += 9 - (y0 + 9) % 10;
	for (int x = x0; x <= x1; x += 10) {
		for (int y = y0; y <= y1; y += 10) {
			Location loc = Location.create(x, y);
			// loc is most likely in the component, so go ahead and
			// put it into the map as if it is - and in the rare event
			// that loc isn't in the component, we can remove it.
			String prev = avoid.put(loc, Connector.ALLOW_NEITHER);
			if (prev != Connector.ALLOW_NEITHER) {
				Location baseLoc = translated ? loc.translate(-dx, -dy) : loc;
				if (!comp.contains(baseLoc)) {
					if (prev == null) {
						avoid.remove(loc);
					} else {
						avoid.put(loc, prev);
					}
				}
			}
		}
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:31,代码来源:AvoidanceMap.java

示例11: unregisterProducer

import java.util.HashMap; //导入方法依赖的package包/类
public void unregisterProducer(final String group, final ClientChannelInfo clientChannelInfo) {
    try {
        if (this.groupChannelLock.tryLock(LockTimeoutMillis, TimeUnit.MILLISECONDS)) {
            try {
                HashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group);
                if (null != channelTable && !channelTable.isEmpty()) {
                    ClientChannelInfo old = channelTable.remove(clientChannelInfo.getChannel());
                    if (old != null) {
                        log.info("unregister a producer[{}] from groupChannelTable {}", group,
                            clientChannelInfo.toString());
                    }

                    if (channelTable.isEmpty()) {
                        this.groupChannelTable.remove(group);
                        log.info("unregister a producer group[{}] from groupChannelTable", group);
                    }
                }
            }
            finally {
                this.groupChannelLock.unlock();
            }
        }
        else {
            log.warn("ProducerManager unregisterProducer lock timeout");
        }
    }
    catch (InterruptedException e) {
        log.error("", e);
    }
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:31,代码来源:ProducerManager.java

示例12: mapToHashtable

import java.util.HashMap; //导入方法依赖的package包/类
/**
 * Converts a map into a valid hash table, i.e.
 * it removes all the 'null' values from the map.
 */
public static <K, V> Hashtable<K, V> mapToHashtable(Map<K, V> map) {
    HashMap<K, V> m = new HashMap<K, V>(map);
    if (m.containsKey(null)) m.remove(null);
    for (Iterator<?> i = m.values().iterator(); i.hasNext(); )
        if (i.next() == null) i.remove();
    return new Hashtable<K, V>(m);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:EnvHelp.java

示例13: show

import java.util.HashMap; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void show(Context context) {
	HashMap<String, Object> shareParamsMap = new HashMap<String, Object>();
	shareParamsMap.putAll(params);

	MobSDK.init(context.getApplicationContext());
	ShareSDK.initSDK(context);

	// 打开分享菜单的统计
	ShareSDK.logDemoEvent(1, null);

	int iTheme = 0;
	try {
		iTheme = ResHelper.parseInt(String.valueOf(shareParamsMap.remove("theme")));
	} catch (Throwable t) {}
	OnekeyShareTheme theme = OnekeyShareTheme.fromValue(iTheme);
	OnekeyShareThemeImpl themeImpl = theme.getImpl();

	themeImpl.setShareParamsMap(shareParamsMap);
	themeImpl.setDialogMode(shareParamsMap.containsKey("dialogMode") ? ((Boolean) shareParamsMap.remove("dialogMode")) : false);
	themeImpl.setSilent(shareParamsMap.containsKey("silent") ? ((Boolean) shareParamsMap.remove("silent")) : false);
	themeImpl.setCustomerLogos((ArrayList<CustomerLogo>) shareParamsMap.remove("customers"));
	themeImpl.setHiddenPlatforms((HashMap<String, String>) shareParamsMap.remove("hiddenPlatforms"));
	themeImpl.setPlatformActionListener((PlatformActionListener) shareParamsMap.remove("callback"));
	themeImpl.setShareContentCustomizeCallback((ShareContentCustomizeCallback) shareParamsMap.remove("customizeCallback"));
	if (shareParamsMap.containsKey("disableSSO") ? ((Boolean) shareParamsMap.remove("disableSSO")) : false) {
		themeImpl.disableSSO();
	}

	themeImpl.show(context.getApplicationContext());
}
 
开发者ID:auv1107,项目名称:TextEmoji,代码行数:32,代码来源:OnekeyShare.java

示例14: removeTemplate

import java.util.HashMap; //导入方法依赖的package包/类
final <T> ImmutableInternalData removeTemplate(ProxyLookup proxy, Template<T> template) {
    if (getResults().containsKey(template)) {
        HashMap<Template,Reference<R>> c = new HashMap<Template, Reference<ProxyLookup.R>>(getResults());
        Reference<R> ref = c.remove(template);
        if (ref != null && ref.get() != null) {
            // seems like there is a reference to a result for this template
            // thta is still alive
            return this;
        }
        return create(getRawLookups(), c);
    } else {
        return this;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:ProxyLookup.java

示例15: remove

import java.util.HashMap; //导入方法依赖的package包/类
public static void remove(Symbol symbol) {
    HashMap<Type, ArrayList<Symbol>> vars = SYMBOL_STACK.peek();
    if (vars.containsKey(symbol.type)) {
        ArrayList<Symbol> symbolsOfType = vars.get(symbol.type);
        symbolsOfType.remove(symbol);
        if (symbolsOfType.isEmpty()) {
            vars.remove(symbol.type);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:SymbolTable.java


注:本文中的java.util.HashMap.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。