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


Java LinkedHashMap.remove方法代碼示例

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


在下文中一共展示了LinkedHashMap.remove方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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 a key value pair from LinkedHashMap use
      Object remove(Object key) method of LinkedHashMap class.
      It returns either the value mapped with the key previously or null if no value
      was mapped.
    */

    Object obj = lHashMap.remove("2");
    System.out.println(obj + " Removed from LinkedHashMap");
  }
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:21,代碼來源:RemoveValueFromLinkedHashMapExample.java

示例2: main

import java.util.LinkedHashMap; //導入方法依賴的package包/類
public static void main(String[] args) {

    //create LinkedHashMap object
    LinkedHashMap lHashMap = new LinkedHashMap();

    /*
      To get the size of LinkedHashMap use
      int size() method of LinkedHashMap class. It returns the number of key value
      pairs stored in LinkedHashMap object.
    */
    System.out.println("Size of LinkedHashMap : " + lHashMap.size());

    //add key value pairs to LinkedHashMap using put method
    lHashMap.put("1", "One");
    lHashMap.put("2", "Two");
    lHashMap.put("3", "Three");
    System.out.println("Size of LinkedHashMap after addition : " + lHashMap.size());

    //remove one element from LinkedHashMap using remove method
    Object obj = lHashMap.remove("2");
    System.out.println("Size of LinkedHashMap after removal : " + lHashMap.size());
  }
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:23,代碼來源:GetSizeOfLinkedHashMapExample.java

示例3: unregisterScope

import java.util.LinkedHashMap; //導入方法依賴的package包/類
/**
 * Unregister the scope with given <code>name</code>
 * @param classLoader ClassLoader
 * @param name Scope name
 * @return <code>true</code> if unregistered
 */
public synchronized boolean unregisterScope(ClassLoader classLoader, String name) {
	ObjectUtils.argumentNotNull(name, "Scope name must be not null");

	final ClassLoader cl = classLoader == null ? getDefaultClassLoader() : classLoader;
	ensureInited(cl);

	final boolean removed;
	LinkedHashMap<String, ContextScope> contextScopes = scopes.get(cl);
	if (contextScopes.containsKey(name)) {
		contextScopes.remove(name);
		removed = true;
	} else {
		removed = false;
	}

	LOGGER.debug(() -> "Unregistered scope with name [" + name + "] for classloader [" + cl
			+ "] - was registered: " + removed);

	return removed;
}
 
開發者ID:holon-platform,項目名稱:holon-core,代碼行數:27,代碼來源:ContextManager.java

示例4: setActivityFeedbackLookupId

import java.util.LinkedHashMap; //導入方法依賴的package包/類
public static void setActivityFeedbackLookupId(Context context, String lookupId, String feedbackType) {
    LinkedHashMap<String, String> lookupIds = getActivityFeedbackLookupId(context);
    lookupIds.put(lookupId, feedbackType);
    if (lookupIds.size() > 30) {
        lookupIds.remove(lookupIds.size() - 1);
    }
    String json = new GsonBuilder().create().toJson(lookupIds);
    SharedPreferences.Editor editor = getEditor(context);
    editor.putString(FEEDBACK_ACTIVITY_LIST, json);
    editor.apply();
}
 
開發者ID:hypertrack,項目名稱:hypertrack-live-android,代碼行數:12,代碼來源:SharedPreferenceManager.java

示例5: sortHashMapByValues

import java.util.LinkedHashMap; //導入方法依賴的package包/類
/**
 * Sorts LinkedHashMap by its values(natural descending order). keeps the
 * duplicates as it is.
 *
 * @param passedMap
 *          An Object of type LinkedHashMap to be sorted by its values.
 * @return An Object containing the sorted LinkedHashMap.
 */
private LinkedHashMap<?,?> sortHashMapByValues(LinkedHashMap<String,String> passedMap) {
  List<String> mapKeys = new ArrayList<String>(passedMap.keySet());
  List<String> mapValues = new ArrayList<String>(passedMap.values());

  Collections.sort(mapValues, new ValueComparator());
  Collections.sort(mapKeys);
  // Reversing the collection to sort the values in descending order
  Collections.reverse(mapValues);
  LinkedHashMap<String,String> sortedMap = new LinkedHashMap<String,String>();

  Iterator<String> valueIt = mapValues.iterator();
  while (valueIt.hasNext()) {
    String val = valueIt.next();
    Iterator<String> keyIt = mapKeys.iterator();
    while (keyIt.hasNext()) {
      String key = keyIt.next();
      String comp1 = passedMap.get(key).toString();
      String comp2 = val.toString();

      if (comp1.equals(comp2)) {
        passedMap.remove(key);
        mapKeys.remove(key);
        sortedMap.put(key, val);
        break;
      }
    }
  }
  return sortedMap;
}
 
開發者ID:GateNLP,項目名稱:gate-core,代碼行數:38,代碼來源:DocTimeReporter.java

示例6: sortHashMapByValues

import java.util.LinkedHashMap; //導入方法依賴的package包/類
/**
 * Sorts LinkedHashMap by its values(natural descending order). keeps the
 * duplicates as it is.
 *
 * @param passedMap
 *          An Object of type LinkedHashMap to be sorted by its values.
 *
 * @return An Object containing the sorted LinkedHashMap.
 */
private LinkedHashMap<String,String> sortHashMapByValues(LinkedHashMap<String,String> passedMap) {
    List<String> mapKeys = new ArrayList<String>(passedMap.keySet());
    List<String> mapValues = new ArrayList<String>(passedMap.values());

    Collections.sort(mapValues, new ValueComparator());
    Collections.sort(mapKeys);
    Collections.reverse(mapValues);
    LinkedHashMap<String,String> sortedMap = new LinkedHashMap<String,String>();

    Iterator<String> valueIt = mapValues.iterator();
    while (valueIt.hasNext()) {
      String val = valueIt.next();
      Iterator<String> keyIt = mapKeys.iterator();
      while (keyIt.hasNext()) {
        String key = keyIt.next();
        String comp1 = passedMap.get(key).toString();
        String comp2 = val.toString();

        if (comp1.equals(comp2)) {
          passedMap.remove(key);
          mapKeys.remove(key);
          sortedMap.put(key, val);
          break;
        }
      }
    }
    return sortedMap;
}
 
開發者ID:GateNLP,項目名稱:gate-core,代碼行數:38,代碼來源:PRTimeReporter.java

示例7: setCustomDisplayProperty

import java.util.LinkedHashMap; //導入方法依賴的package包/類
@Override
public void setCustomDisplayProperty(String key, Object value)
{
	LinkedHashMap<String, Object> map = getCustomDisplayMap();
	if( value != null )
	{
		map.put(key, value);
	}
	else
	{
		map.remove(key);
	}
	wrapped.setData(AttachmentUtils.CUSTOM_DISPLAY_KEY, map);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:15,代碼來源:AttachmentsScriptWrapper.java

示例8: addNumericUpdate

import java.util.LinkedHashMap; //導入方法依賴的package包/類
public void addNumericUpdate(NumericDocValuesUpdate update, int docIDUpto) {
  LinkedHashMap<Term,NumericDocValuesUpdate> fieldUpdates = numericUpdates.get(update.field);
  if (fieldUpdates == null) {
    fieldUpdates = new LinkedHashMap<>();
    numericUpdates.put(update.field, fieldUpdates);
    bytesUsed.addAndGet(BYTES_PER_NUMERIC_FIELD_ENTRY);
  }
  final NumericDocValuesUpdate current = fieldUpdates.get(update.term);
  if (current != null && docIDUpto < current.docIDUpto) {
    // Only record the new number if it's greater than or equal to the current
    // one. This is important because if multiple threads are replacing the
    // same doc at nearly the same time, it's possible that one thread that
    // got a higher docID is scheduled before the other threads.
    return;
  }

  update.docIDUpto = docIDUpto;
  // since it's a LinkedHashMap, we must first remove the Term entry so that
  // it's added last (we're interested in insertion-order).
  if (current != null) {
    fieldUpdates.remove(update.term);
  }
  fieldUpdates.put(update.term, update);
  numNumericUpdates.incrementAndGet();
  if (current == null) {
    bytesUsed.addAndGet(BYTES_PER_NUMERIC_UPDATE_ENTRY + update.sizeInBytes());
  }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:29,代碼來源:BufferedUpdates.java

示例9: addBinaryUpdate

import java.util.LinkedHashMap; //導入方法依賴的package包/類
public void addBinaryUpdate(BinaryDocValuesUpdate update, int docIDUpto) {
  LinkedHashMap<Term,BinaryDocValuesUpdate> fieldUpdates = binaryUpdates.get(update.field);
  if (fieldUpdates == null) {
    fieldUpdates = new LinkedHashMap<>();
    binaryUpdates.put(update.field, fieldUpdates);
    bytesUsed.addAndGet(BYTES_PER_BINARY_FIELD_ENTRY);
  }
  final BinaryDocValuesUpdate current = fieldUpdates.get(update.term);
  if (current != null && docIDUpto < current.docIDUpto) {
    // Only record the new number if it's greater than or equal to the current
    // one. This is important because if multiple threads are replacing the
    // same doc at nearly the same time, it's possible that one thread that
    // got a higher docID is scheduled before the other threads.
    return;
  }
  
  update.docIDUpto = docIDUpto;
  // since it's a LinkedHashMap, we must first remove the Term entry so that
  // it's added last (we're interested in insertion-order).
  if (current != null) {
    fieldUpdates.remove(update.term);
  }
  fieldUpdates.put(update.term, update);
  numBinaryUpdates.incrementAndGet();
  if (current == null) {
    bytesUsed.addAndGet(BYTES_PER_BINARY_UPDATE_ENTRY + update.sizeInBytes());
  }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:29,代碼來源:BufferedUpdates.java

示例10: removeBatchLoadableCollection

import java.util.LinkedHashMap; //導入方法依賴的package包/類
/**
 * After a collection was initialized or evicted, we don't
 * need to batch fetch it anymore, remove it from the queue
 * if necessary
 */
public void removeBatchLoadableCollection(CollectionEntry ce) {
	LinkedHashMap<CollectionEntry, PersistentCollection> map =  batchLoadableCollections.get( ce.getLoadedPersister().getRole() );
	if ( map != null ) {
		map.remove( ce );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:12,代碼來源:BatchFetchQueue.java

示例11: runDestructionCallbacks

import java.util.LinkedHashMap; //導入方法依賴的package包/類
protected void runDestructionCallbacks() {
	LinkedHashMap<String, Runnable> index = DESTRUCTION_CALLBACKS.get();
	DESTRUCTION_CALLBACKS.remove();
	List<String> names = Lists.reverse(Lists.newArrayList(index.keySet()));
	for (String name : names) {
		Runnable callback = index.remove(name);
		run(name, callback);
	}
}
 
開發者ID:qas-guru,項目名稱:martini-core,代碼行數:10,代碼來源:ScenarioScope.java

示例12: BSONObject

import java.util.LinkedHashMap; //導入方法依賴的package包/類
public BSONObject(String BSONString) throws BSONException {
    this.bson = new LinkedHashMap<String, Object>();
    BSONString bs = new BSONString();
    LinkedHashMap<String, Object> map = bs.getBSON(BSONString);
    String msg = (String) map.get(BSON.TAG_MSG);
    if (msg.equals(BSON.MSG_BSON)) {
        String tag = (String) map.get(BSON.TAG_KEY);
        String value = (String) map.get(BSON.TAG_VALUE);
        LinkedHashMap<String, Object> hm = bs.getValue(value);
        bson.put(tag, hm.get(BSON.TAG_VALUE));
    } else if (msg.equals(BSON.MSG_BSON_ARRAY)) {
        map.remove(BSON.TAG_MSG);
        Iterator<Entry<String, Object>> iter = map.entrySet().iterator();
        while (iter.hasNext()) {
            Entry<String, Object> entry = (Entry<String, Object>) iter.next();
            bson.put(entry.getKey(), entry.getValue());
        }
    } else if (msg.equals(BSON.MSG_BSON_EMPTY)) {
        BSON.Warn(BSON.MSG_BSON_EMPTY);
    } else if (msg.equals(BSON.MSG_ERROR_NOTBSON)) {
        throw new BSONException(msg);
    } else if (msg.equals(BSON.MSG_ERROR_EMPTY)) {
        throw new BSONException(msg);
    } else {
        throw new BSONException(BSON.MSG_ERROR_UNKNOW);
    }
}
 
開發者ID:IaHehe,項目名稱:classchecks,代碼行數:28,代碼來源:BSONObject.java

示例13: getNamedParameters

import java.util.LinkedHashMap; //導入方法依賴的package包/類
public LinkedHashSet<NamedParameter> getNamedParameters(String resource, boolean excludeOverriden) throws Exception {
	LinkedHashMap<String, NamedParameter> namedParameters = new LinkedHashMap<String, NamedParameter>();
	Method method = getAnnotatedMethod(resource);
	if (method != null) {
		MethodParameterNames annotation = method.getAnnotation(MethodParameterNames.class);
		String[] parameterNames = null;
		if (annotation != null) {
			parameterNames = annotation.value();
		}
		Class[] parameterTypes = method.getParameterTypes();
		if (parameterNames != null && parameterTypes != null) {
			for (int i = 0; i < parameterNames.length; i++) {
				namedParameters.put(parameterNames[i], new NamedParameter(parameterNames[i], parameterTypes[i]));
			}
		}
	}
	Iterator<Entry<String, Object>> it = defaults.entrySet().iterator();
	while (it.hasNext()) {
		Entry<String, Object> defaultParameter = it.next();
		if (!namedParameters.containsKey(defaultParameter.getKey())) {
			namedParameters.put(defaultParameter.getKey(), new NamedParameter(defaultParameter.getKey(), defaultParameter.getValue().getClass()));
		}
	}
	it = overrides.entrySet().iterator();
	while (it.hasNext()) {
		Entry<String, Object> overrideParameter = it.next();
		namedParameters.put(overrideParameter.getKey(), new NamedParameter(overrideParameter.getKey(), overrideParameter.getValue().getClass()));
	}
	if (excludeOverriden) {
		it = overrides.entrySet().iterator();
		while (it.hasNext()) {
			namedParameters.remove(it.next().getKey());
		}
	}
	return new LinkedHashSet<NamedParameter>(namedParameters.values());
}
 
開發者ID:phoenixctms,項目名稱:ctsms,代碼行數:37,代碼來源:ArgsUriPart.java

示例14: fix

import java.util.LinkedHashMap; //導入方法依賴的package包/類
private void fix() {
    /*
     * Useful references:
     * http://tools.ietf.org/html/rfc4121#page-5
     * http://tools.ietf.org/html/rfc2743#page-81
     * https://msdn.microsoft.com/en-us/library/ms995330.aspx
     */

    // Scan until we find the mech types list. If we find anything
    // unexpected, abort the fix process.
    if (!tag(0x60)) return;
    if (!length()) return;
    if (!oid("1.3.6.1.5.5.2")) return;
    if (!tag(0xa0)) return;
    if (!length()) return;
    if (!tag(0x30)) return;
    if (!length()) return;
    if (!tag(0xa0)) return;
    lengthAsInt();
    if (!tag(0x30)) return;
    // Now at the start of the mechType list.
    // Read the mechTypes into an ordered set
    int mechTypesLen = lengthAsInt();
    int mechTypesStart = pos;
    LinkedHashMap<String, int[]> mechTypeEntries = new LinkedHashMap<String, int[]>();
    while (pos < mechTypesStart + mechTypesLen) {
        int[] value = new int[2];
        value[0] = pos;
        String key = oidAsString();
        value[1] = pos - value[0];
        mechTypeEntries.put(key, value);
    }
    // Now construct the re-ordered mechType list
    byte[] replacement = new byte[mechTypesLen];
    int replacementPos = 0;

    int[] first = mechTypeEntries.remove("1.2.840.113554.1.2.2");
    if (first != null) {
        System.arraycopy(token, first[0], replacement, replacementPos, first[1]);
        replacementPos += first[1];
    }
    for (int[] markers : mechTypeEntries.values()) {
        System.arraycopy(token, markers[0], replacement, replacementPos, markers[1]);
        replacementPos += markers[1];
    }

    // Finally, replace the original mechType list with the re-ordered
    // one.
    System.arraycopy(replacement, 0, token, mechTypesStart, mechTypesLen);
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:51,代碼來源:SpnegoAuthenticator.java

示例15: buildSearchContext

import java.util.LinkedHashMap; //導入方法依賴的package包/類
protected SearchContext buildSearchContext(long userId, long groupId, long ownerUserId, String workPackage,
        String description, int status, Date fromDate, Date untilDate, LinkedHashMap<String, Object> params,
        boolean andSearch, boolean advancedSearch, int start, int end, Sort sort) throws PortalException {

    SearchContext searchContext = new SearchContext();

    searchContext.setAttribute("advancedSearch", advancedSearch);

    searchContext.setAttribute(Field.STATUS, status);

    if (Validator.isNotNull(description)) {
        searchContext.setAttribute("description", description);
    }

    searchContext.setAttribute("fromDate", fromDate);
    searchContext.setAttribute("untilDate", untilDate);

    if (Validator.isNotNull(workPackage)) {
        searchContext.setAttribute("workPackage", workPackage);
    }

    searchContext.setAttribute("paginationType", "more");

    Group group = GroupLocalServiceUtil.getGroup(groupId);

    searchContext.setCompanyId(group.getCompanyId());

    if (ownerUserId > 0) {
        searchContext.setOwnerUserId(ownerUserId);
    }

    searchContext.setEnd(end);
    if (groupId > 0) {
        searchContext.setGroupIds(new long[] { groupId });
    }
    searchContext.setSorts(sort);
    searchContext.setStart(start);
    searchContext.setUserId(userId);

    searchContext.setAndSearch(andSearch);

    if (params != null) {

        String keywords = (String) params.remove("keywords");

        if (Validator.isNotNull(keywords)) {
            searchContext.setKeywords(keywords);
        }
    }

    QueryConfig queryConfig = new QueryConfig();

    queryConfig.setHighlightEnabled(false);
    queryConfig.setScoreEnabled(false);

    searchContext.setQueryConfig(queryConfig);

    if (sort != null) {
        searchContext.setSorts(sort);
    }

    searchContext.setStart(start);

    return searchContext;
}
 
開發者ID:inofix,項目名稱:ch-inofix-timetracker,代碼行數:66,代碼來源:TaskRecordLocalServiceImpl.java


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