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