ConcurrentHashMap remove - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ConcurrentHashMap remove method.

This code example shows how to use the following methods:get, putIfAbsent, remove
     * @param k key 
     * @return value 
     * @throws InterruptedException if interrupted while waiting 
     */ 
    public V get(K k) throws InterruptedException { 
        map.putIfAbsent(k, new SlotFuture<V>()); 
        V v = Util.safeGet( 
            map.get(k), 
            "Waiting to retrieve a value from BlockingHashMap."); 
        map.remove(k); 
        return v; 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:remove
     * @param key the key name for the parameter to remove. 
     */ 
    public void remove(String key){
        urlParams.remove(key);
        fileParams.remove(key);
        urlParamsWithArray.remove(key);
    } 
 
    @Override 
    public String toString() {
        StringBuilder result = new StringBuilder();
        for(ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) {
            if(result.length() > 0)
                result.append("&");
 
            result.append(entry.getKey());
            result.append("=");
            result.append(entry.getValue());
        } 
 
7
CodeRank
This code example shows how to use the following methods:get, isEmpty, keySet, remove
	 *  
	 * @see org.mixare.mgr.downloader.DownloadManager#getNextResult() 
	 */ 
	public synchronized DownloadResult getNextResult() { 
		DownloadResult result = null;
		if (!doneList.isEmpty()) {
			String nextId = doneList.keySet().iterator().next();
			result = doneList.get(nextId);
			doneList.remove(nextId);
		} 
		return result;
	} 
	 
	/* 
	 * (non-Javadoc) 
	 *  
	 * @see org.mixare.mgr.downloader.DownloadManager#getResultSize() 
	 */ 
	public int getResultSize(){ 
		return doneList.size();
7
CodeRank
This code example shows how to use the following methods:get, put, remove
     * @param key 
     *            the key to check 
     * @return <code>true</code> if the node is marked as available. 
     */ 
    public boolean isNodeAvailable( @Nonnull final K key ) {
        final ManagedItem<Boolean> item = _map.get( key );
        if ( item == null ) {
            return updateIsNodeAvailable( key );
        } else if ( isExpired( item ) ) {
            _map.remove( key );
            return updateIsNodeAvailable( key );
        } else { 
            return item._value;
        } 
    } 
 
    private boolean isExpired( final ManagedItem<Boolean> item ) {
        return _ttl > -1 && System.currentTimeMillis() - item._insertionTime > _ttl;
    } 
 

7
CodeRank
This code example shows how to use the following methods:get, putIfAbsent, remove
     * @param k key 
     * @return value 
     * @throws InterruptedException if interrupted while waiting 
     */ 
    public V get(K k) throws InterruptedException { 
        map.putIfAbsent(k, new SlotFuture<V>()); 
        V v = Util.safeGet( 
            map.get(k), 
            "Waiting to retrieve a value from BlockingHashMap."); 
        map.remove(k); 
        return v; 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:remove
     * 
     * @param cookie cookie to be removed 
     */ 
    public void deleteCookie(Cookie cookie) {
        String name = cookie.getName() + cookie.getDomain();
        cookies.remove(name);
        SharedPreferences.Editor prefsWriter = cookiePrefs.edit();
        prefsWriter.remove(COOKIE_NAME_PREFIX + name);
        prefsWriter.commit();
    } 
 
    /** 
     * Serializes Cookie object into String 
     * 
     * @param cookie cookie to be encoded, can be null 
     * @return cookie encoded as String 
     */ 
    protected String encodeCookie(SerializableCookie cookie) {
        if (cookie == null)
            return null; 
6
CodeRank
This code example shows how to use the following methods:get, put, remove
      this.cacheTimeout = cacheTimeout;
   } 
 
   protected void addPrivate(String alias, PrivateKey key)
   { 
      privateCache.put(alias, new CacheEntry<PrivateKey>(key));
   } 
 
   protected void addPublic(String alias, PublicKey key)
   { 
      publicCache.put(alias, new CacheEntry<PublicKey>(key));
   } 
 
   protected PrivateKey getPrivateCache(String alias)
   { 
      CacheEntry<PrivateKey> entry = privateCache.get(alias);
      if (entry == null) return null;
      if (entry.isStale())
      { 
         privateCache.remove(entry, entry);

6
CodeRank
This code example shows how to use the following methods:remove
    } 
 
    @Override 
    public void removeAttribute(String name) {
        if (!valid.get()) throw new IllegalStateException();
        attributes.remove(name);
    } 
 
    @Override 
    public void removeValue(String name) {
        if (!valid.get()) throw new IllegalStateException();
        attributes.remove(name);
    } 
 
    public FakeHttpSession copyAttributes(HttpSession httpSession) {
        Enumeration<String> e = httpSession.getAttributeNames();
        String k;
        while (e.hasMoreElements()) {
            k = e.nextElement();
            if (k == null) continue;
6
CodeRank
This code example shows how to use the following methods:sleep, put, remove
    @Override 
    public void waitBeforeRetry() { 
        _count++;
        try { 
            Thread current = Thread.currentThread();
            _asleep.put(current.getName(), current);
            Thread.sleep(_time);
            _asleep.remove(current.getName());
        } catch(InterruptedException e) {
             
        } 
        return; 
    } 
 
    @Override 
    public void reset() { 
        _count = 0;
    } 
 
    @Override 
7
CodeRank
This code example shows how to use the following methods:get, remove
        executions.put(executionId, future);
    } 
 
    @Override 
    public Map<String, Object> getOutput(String executionId, long timeout) throws ProcessException {
        Future<Map<String, Object>> future = executions.get(executionId);
        if (future == null) { 
            return null; 
        } 
        boolean timedOut = false;
        try { 
            Map<String, Object> result;
            if (timeout <= 0) {
                result = future.get(); 
            } else { 
                result = future.get(timeout, TimeUnit.MILLISECONDS);
            } 
            return result; 
        } catch (TimeoutException e) {
            timedOut = true;

6
CodeRank
remove Method Overview
Removes the key (and its corresponding value) from this map.
See Code Examples for other Java 8 ConcurrentHashMap Methods: