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


Java SortedMap.remove方法代碼示例

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


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

示例1: writeMainSection

import java.util.SortedMap; //導入方法依賴的package包/類
public static void writeMainSection(OutputStream out, Attributes attributes)
        throws IOException {

    // Main section must start with the Manifest-Version attribute.
    // See https://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Signed_JAR_File.
    String manifestVersion = attributes.getValue(Attributes.Name.MANIFEST_VERSION);
    if (manifestVersion == null) {
        throw new IllegalArgumentException(
                "Mandatory " + Attributes.Name.MANIFEST_VERSION + " attribute missing");
    }
    writeAttribute(out, Attributes.Name.MANIFEST_VERSION, manifestVersion);

    if (attributes.size() > 1) {
        SortedMap<String, String> namedAttributes = getAttributesSortedByName(attributes);
        namedAttributes.remove(Attributes.Name.MANIFEST_VERSION.toString());
        writeAttributes(out, namedAttributes);
    }
    writeSectionDelimiter(out);
}
 
開發者ID:F8LEFT,項目名稱:FApkSigner,代碼行數:20,代碼來源:ManifestWriter.java

示例2: writeMainSection

import java.util.SortedMap; //導入方法依賴的package包/類
public static void writeMainSection(OutputStream out, Attributes attributes)
        throws IOException {

    // Main section must start with the Signature-Version attribute.
    // See https://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Signed_JAR_File.
    String signatureVersion = attributes.getValue(Attributes.Name.SIGNATURE_VERSION);
    if (signatureVersion == null) {
        throw new IllegalArgumentException(
                "Mandatory " + Attributes.Name.SIGNATURE_VERSION + " attribute missing");
    }
    ManifestWriter.writeAttribute(out, Attributes.Name.SIGNATURE_VERSION, signatureVersion);

    if (attributes.size() > 1) {
        SortedMap<String, String> namedAttributes =
                ManifestWriter.getAttributesSortedByName(attributes);
        namedAttributes.remove(Attributes.Name.SIGNATURE_VERSION.toString());
        ManifestWriter.writeAttributes(out, namedAttributes);
    }
    writeSectionDelimiter(out);
}
 
開發者ID:F8LEFT,項目名稱:FApkSigner,代碼行數:21,代碼來源:SignatureFileWriter.java

示例3: computeExportList

import java.util.SortedMap; //導入方法依賴的package包/類
public static SortedMap<String, Boolean> computeExportList (Map<Integer, String> exportInstructions, Project project) {
    SortedMap<String, Boolean> pkgMap = new TreeMap<String, Boolean>();
    SortedSet<String> pkgNames = FileUtilities.getPackageNames(project);
    for (String name : pkgNames) {
        pkgMap.put(name, Boolean.FALSE);
    }
    String exportIns = exportInstructions.get(EXPORT_PACKAGE);
    if (exportIns != null) {
        StringTokenizer strTok = new StringTokenizer(exportIns, DELIMITER);

        while(strTok.hasMoreTokens()) {
            String cur = strTok.nextToken();
            pkgMap.remove(cur);
            pkgMap.put(cur, Boolean.TRUE);
        }
    }

    return pkgMap;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:InstructionsConverter.java

示例4: playJoke

import java.util.SortedMap; //導入方法依賴的package包/類
private boolean playJoke(TextToSpeech tts) {
    long now = System.currentTimeMillis();
    // choose a random joke whose last occurrence was far enough in the past
    SortedMap<Long, Utterance> availableJokes = mJokes.headMap(now - JOKE_COOLDOWN_MILLIS);
    Utterance joke = null;
    if (!availableJokes.isEmpty()) {
        int r = RANDOM.nextInt(availableJokes.size());
        int i = 0;
        for (Long key : availableJokes.keySet()) {
            if (i++ == r) {
                joke = availableJokes.remove(key); // also removes from mJokes
                break;
            }
        }
    }
    if (joke != null) {
        joke.speak(tts);
        // add it back with the current time
        mJokes.put(now, joke);
        return true;
    }
    return false;
}
 
開發者ID:FoxLabMakerSpace,項目名稱:SIGHT-For-the-Blind,代碼行數:24,代碼來源:TtsSpeaker.java

示例5: stressMapChecked

import java.util.SortedMap; //導入方法依賴的package包/類
public void stressMapChecked(SortedMap<Integer,Integer> map)
{
	// get the keys, remove every odd element, and re-add it
	Set<Integer> keyset = map.keySet();
	Object[] keys = keyset.toArray();
	// remove every odd element
	for (int i=1; i<keys.length; i=i+2)
	{
		map.remove(keys[i]);
	}
	assertEquals((keys.length+1)/2, map.size());
	
	// re-add every odd element
	for (int i=0; i<keys.length; i++)
	{
		map.put((Integer)keys[i], null);
	}
	// just check that we have the same number of keys
	assertEquals(map.size(), keys.length);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-systemtest,代碼行數:21,代碼來源:TreeMapTest.java

示例6: stressMapUnChecked

import java.util.SortedMap; //導入方法依賴的package包/類
public void stressMapUnChecked(SortedMap<Integer,Integer> map)
{
	// get the keys, remove every odd element and re-add it
	Object[] keys;
	synchronized(map)
	{
		keys = map.keySet().toArray();
	}
	// remove every odd element
	for (int i=1; i<keys.length; i=i+2)
	{
		map.remove(keys[i]);
	}
	
	// re-add every odd element
	for (int i=0; i<keys.length; i++)
	{
		map.put((Integer)keys[i], null);
	}
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-systemtest,代碼行數:21,代碼來源:TreeMapTest.java

示例7: testTailMapRemoveThrough

import java.util.SortedMap; //導入方法依賴的package包/類
public void testTailMapRemoveThrough() {
  final SortedMap<K, V> map;
  try {
    map = makePopulatedMap();
  } catch (UnsupportedOperationException e) {
    return;
  }
  int oldSize = map.size();
  if (map.size() < 2 || !supportsRemove) {
    return;
  }
  Iterator<Entry<K, V>> iterator = map.entrySet().iterator();
  Entry<K, V> firstEntry = iterator.next();
  Entry<K, V> secondEntry = iterator.next();
  K key = secondEntry.getKey();
  SortedMap<K, V> subMap = map.tailMap(key);
  subMap.remove(key);
  assertNull(subMap.remove(firstEntry.getKey()));
  assertEquals(map.size(), oldSize - 1);
  assertFalse(map.containsKey(key));
  assertEquals(subMap.size(), oldSize - 2);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:23,代碼來源:SortedMapInterfaceTest.java

示例8: remove

import java.util.SortedMap; //導入方法依賴的package包/類
public synchronized void remove(Class<?> cls, int begin, int end, T item)
{
	SortedMap<Integer, SortedMap<Integer, Set<T>>> clsMap = map.get(cls);
	if (null==clsMap) {throw new DapException("Tried to remove an item that does not exist.");}
	SortedMap<Integer, Set<T>> beginMap = clsMap.get(begin);
	if (null==beginMap) {throw new DapException("Tried to remove an item that does not exist.");}
	Set<T> items = beginMap.get(end);
	if (null==items) {throw new DapException("Tried to remove an item that does not exist.");}
	for (T anItem : items)
	{
		if (item.getUniqueId()==anItem.getUniqueId())
		{
			items.remove(anItem);
		}
	}
	
	if (items.isEmpty())
	{
		beginMap.remove(end);
	}
	if (beginMap.isEmpty())
	{
		clsMap.remove(begin);
	}
	if (clsMap.isEmpty())
	{
		map.remove(cls);
	}
}
 
開發者ID:document-analysis,項目名稱:dap,代碼行數:30,代碼來源:Index.java

示例9: getFormatsForFlavors

import java.util.SortedMap; //導入方法依賴的package包/類
@Override
public SortedMap <Long, DataFlavor> getFormatsForFlavors(
        DataFlavor[] flavors, FlavorTable map)
{
    SortedMap <Long, DataFlavor> retval =
            super.getFormatsForFlavors(flavors, map);

    // The Win32 native code does not support exporting LOCALE data, nor
    // should it.
    retval.remove(L_CF_LOCALE);

    return retval;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:14,代碼來源:WDataTransferer.java

示例10: getFormatsForFlavors

import java.util.SortedMap; //導入方法依賴的package包/類
public SortedMap getFormatsForFlavors(DataFlavor[] flavors, FlavorTable map) {
    SortedMap retval = super.getFormatsForFlavors(flavors, map);

    // The Win32 native code does not support exporting LOCALE data, nor
    // should it.
    retval.remove(L_CF_LOCALE);

    return retval;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:10,代碼來源:IkvmDataTransferer.java

示例11: writeObject

import java.util.SortedMap; //導入方法依賴的package包/類
/**
 * Serializes a {@link DescriptorSupport} to an {@link ObjectOutputStream}.
 */
/* If you set jmx.serial.form to "1.2.0" or "1.2.1", then we are
   bug-compatible with those versions.  Specifically, field names
   are forced to lower-case before being written.  This
   contradicts the spec, which, though it does not mention
   serialization explicitly, does say that the case of field names
   is preserved.  But in 1.2.0 and 1.2.1, this requirement was not
   met.  Instead, field names in the descriptor map were forced to
   lower case.  Those versions expect this to have happened to a
   descriptor they deserialize and e.g. getFieldValue will not
   find a field whose name is spelt with a different case.
*/
private void writeObject(ObjectOutputStream out) throws IOException {
    ObjectOutputStream.PutField fields = out.putFields();
    boolean compat = "1.0".equals(serialForm);
    if (compat)
        fields.put("currClass", currClass);

    /* Purge the field "targetObject" from the DescriptorSupport before
     * serializing since the referenced object is typically not
     * serializable.  We do this here rather than purging the "descriptor"
     * variable below because that HashMap doesn't do case-insensitivity.
     * See CR 6332962.
     */
    SortedMap<String, Object> startMap = descriptorMap;
    if (startMap.containsKey("targetObject")) {
        startMap = new TreeMap<String, Object>(descriptorMap);
        startMap.remove("targetObject");
    }

    final HashMap<String, Object> descriptor;
    if (compat || "1.2.0".equals(serialForm) ||
            "1.2.1".equals(serialForm)) {
        descriptor = new HashMap<String, Object>();
        for (Map.Entry<String, Object> entry : startMap.entrySet())
            descriptor.put(entry.getKey().toLowerCase(), entry.getValue());
    } else
        descriptor = new HashMap<String, Object>(startMap);

    fields.put("descriptor", descriptor);
    out.writeFields();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:45,代碼來源:DescriptorSupport.java


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