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


Java AbstractMap.SimpleImmutableEntry方法代碼示例

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


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

示例1: iterator

import java.util.AbstractMap; //導入方法依賴的package包/類
private Iterator<Map.Entry<K, V>> iterator(final int pos, final boolean reverse) {
  return new Iterator<Map.Entry<K, V>>() {
    int currentPos = pos;

    @Override
    public boolean hasNext() {
      return reverse ? currentPos >= 0 : currentPos < keys.length;
    }

    @Override
    public Map.Entry<K, V> next() {
      final K key = keys[currentPos];
      final V value = values[currentPos];
      currentPos = reverse ? currentPos - 1 : currentPos + 1;
      return new AbstractMap.SimpleImmutableEntry<>(key, value);
    }

    @Override
    public void remove() {
      throw new UnsupportedOperationException("Can't remove elements from ImmutableSortedMap");
    }
  };
}
 
開發者ID:firebase,項目名稱:firebase-admin-java,代碼行數:24,代碼來源:ArraySortedMap.java

示例2: doRemoveFirstEntry

import java.util.AbstractMap; //導入方法依賴的package包/類
/**
 * Removes first entry; returns its snapshot.
 * @return null if empty, else snapshot of first entry
 */
private Map.Entry<K,V> doRemoveFirstEntry() {
    for (Node<K,V> b, n;;) {
        if ((n = (b = head.node).next) == null)
            return null;
        Node<K,V> f = n.next;
        if (n != b.next)
            continue;
        Object v = n.value;
        if (v == null) {
            n.helpDelete(b, f);
            continue;
        }
        if (!n.casValue(v, null))
            continue;
        if (!n.appendMarker(f) || !b.casNext(n, f))
            findFirst(); // retry
        clearIndexToFirst();
        @SuppressWarnings("unchecked") V vv = (V)v;
        return new AbstractMap.SimpleImmutableEntry<K,V>(n.key, vv);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:26,代碼來源:ConcurrentSkipListMap.java

示例3: actionPerformed

import java.util.AbstractMap; //導入方法依賴的package包/類
@Override
@NbBundle.Messages({
    "MSG_GitAction.savingFiles.progress=Preparing Git action"
})
public void actionPerformed (ActionEvent e) {
    final AbstractMap.SimpleImmutableEntry<File, File[]> roots = GitUtils.getActionRoots(ctx);
    if (roots != null) {
        final File root = roots.getKey();
        final AtomicBoolean canceled = new AtomicBoolean(false);
        Runnable run = new Runnable() {

            @Override
            public void run () {
                LifecycleManager.getDefault().saveAll();
                Utils.logVCSActionEvent("Git"); //NOI18N
                if (!canceled.get()) {
                    EventQueue.invokeLater(new Runnable() {

                        @Override
                        public void run () {
                            SystemAction.get(SwitchBranchAction.class).checkoutRevision(root, branchName, null,
                                    Bundle.SwitchBranchAction_KnownBranchAction_progress(branchName));
                        }
                    });
                }
            }
        };
        ProgressUtils.runOffEventDispatchThread(run, Bundle.MSG_GitAction_savingFiles_progress(), canceled, false);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:31,代碼來源:SwitchBranchAction.java

示例4: zip

import java.util.AbstractMap; //導入方法依賴的package包/類
public static <K, V> EntryStream<K, V> zip(final K[] keys, final V[] values) {
    final BiFunction<K, V, Map.Entry<K, V>> zipFunction = new BiFunction<K, V, Map.Entry<K, V>>() {
        @Override
        public Entry<K, V> apply(K k, V v) {
            return new AbstractMap.SimpleImmutableEntry<>(k, v);
        }
    };

    final Function<Map.Entry<K, V>, Map.Entry<K, V>> mapper = Fn.identity();

    return Stream.zip(keys, values, zipFunction).mapToEntry(mapper);
}
 
開發者ID:landawn,項目名稱:Abacus-Lightweight-Stream-API,代碼行數:13,代碼來源:EntryStream.java

示例5: removeLowest

import java.util.AbstractMap; //導入方法依賴的package包/類
Map.Entry<K,V> removeLowest() {
    Comparator<? super K> cmp = m.comparator;
    for (;;) {
        Node<K,V> n = loNode(cmp);
        if (n == null)
            return null;
        K k = n.key;
        if (!inBounds(k, cmp))
            return null;
        V v = m.doRemove(k, null);
        if (v != null)
            return new AbstractMap.SimpleImmutableEntry<K,V>(k, v);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:ConcurrentSkipListMap.java

示例6: getNear

import java.util.AbstractMap; //導入方法依賴的package包/類
/**
 * Returns SimpleImmutableEntry for results of findNear.
 * @param key the key
 * @param rel the relation -- OR'ed combination of EQ, LT, GT
 * @return Entry fitting relation, or null if no such
 */
final AbstractMap.SimpleImmutableEntry<K,V> getNear(K key, int rel) {
    Comparator<? super K> cmp = comparator;
    for (;;) {
        Node<K,V> n = findNear(key, rel, cmp);
        if (n == null)
            return null;
        AbstractMap.SimpleImmutableEntry<K,V> e = n.createSnapshot();
        if (e != null)
            return e;
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:ConcurrentSkipListMap.java

示例7: parse

import java.util.AbstractMap; //導入方法依賴的package包/類
public static Map.Entry<String, JsonNode> parse(TravnyParser.AnnotationContext ctx) throws IOException {
    String key = ParserUtils.qualifiedIdentifierToString(ctx.annotationName().qualifiedIdentifier());
    TravnyParser.JsonValueContext json = ctx.jsonValue();
    if (json != null) {
        JsonNode node = new ObjectMapper().readTree(json.getText());
        return new AbstractMap.SimpleImmutableEntry<>(key, node);
    } else {
        return new AbstractMap.SimpleImmutableEntry<>(key, NullNode.getInstance());
    }
}
 
開發者ID:atlascon,項目名稱:travny,代碼行數:11,代碼來源:AnnotationParser.java

示例8: createSnapshot

import java.util.AbstractMap; //導入方法依賴的package包/類
/**
 * Creates and returns a new SimpleImmutableEntry holding current
 * mapping if this node holds a valid value, else null.
 * @return new entry or null
 */
AbstractMap.SimpleImmutableEntry<K,V> createSnapshot() {
    Object v = value;
    if (v == null || v == this || v == BASE_HEADER)
        return null;
    @SuppressWarnings("unchecked") V vv = (V)v;
    return new AbstractMap.SimpleImmutableEntry<K,V>(key, vv);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:ConcurrentSkipListMap.java

示例9: instantiate

import java.util.AbstractMap; //導入方法依賴的package包/類
public Map.Entry<UUID, ApplicationId> instantiate(
    JobDefinitionDesiredstate state,
    UUID jobUUID,
    JobCompilationResult job) throws Exception {
  String clusterName = state.getClusterId();
  ClusterInfo cluster = clusters.get(clusterName);
  if (cluster == null) {
    throw new IllegalArgumentException("Invalid cluster name " + clusterName);
  }

  JobDeployer deployer = new JobDeployer(cluster.conf(), cluster.client(), executor, flinkConf);
  ApplicationId appId = deployer.createApplication();
  UUID instanceUUID = UUID.randomUUID();
  InstanceMetadata md = new InstanceMetadata(instanceUUID, jobUUID);

  JobConf jobConf = new JobConf(
      appId,
      jobUUID.toString(),
      job.additionalJars(),
      state.getResource().getQueue(),
      state.getResource().getVCores(),
      state.getResource().getMemory(),
      md);

  LOG.info("Instantiating job {} at {}", jobUUID, clusterName);
  deployer.start(job.jobGraph(), jobConf);
  return new AbstractMap.SimpleImmutableEntry<>(instanceUUID, appId);
}
 
開發者ID:uber,項目名稱:AthenaX,代碼行數:29,代碼來源:InstanceManager.java

示例10: DefaultSimpleCache

import java.util.AbstractMap; //導入方法依賴的package包/類
/**
 * Construct a cache using the specified capacity and name.
 * 
 * @param maxItems The cache capacity. 0 = use {@link #DEFAULT_CAPACITY}
 * @param useMaxItems Whether the maxItems value should be applied as a size-cap for the cache.
 * @param cacheName An arbitrary cache name.
 */
@SuppressWarnings("unchecked")
public DefaultSimpleCache(int maxItems, boolean useMaxItems, int ttlSecs, int maxIdleSecs, String cacheName)
{
    if (maxItems == 0)
    {
        maxItems = DEFAULT_CAPACITY;
    }
    else if (maxItems < 0)
    {
        throw new IllegalArgumentException("maxItems may not be negative, but was " + maxItems);
    }
    this.maxItems = maxItems;
    this.useMaxItems = useMaxItems;
    this.ttlSecs = ttlSecs;
    this.maxIdleSecs = maxIdleSecs;
    setBeanName(cacheName);
    
    // The map will have a bounded size determined by the maxItems member variable.
    @SuppressWarnings("rawtypes")
    CacheBuilder builder = CacheBuilder.newBuilder();
    
    if (useMaxItems)
    {
        builder.maximumSize(maxItems);
    }
    if (ttlSecs > 0)
    {
        builder.expireAfterWrite(ttlSecs, TimeUnit.SECONDS);
    }
    if (maxIdleSecs > 0)
    {
        builder.expireAfterAccess(maxIdleSecs, TimeUnit.SECONDS);
    }
    builder.concurrencyLevel(32);
    
    cache = (Cache<K, AbstractMap.SimpleImmutableEntry<K, V>>) builder.build();
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:45,代碼來源:DefaultSimpleCache.java

示例11: putAndCheckUpdate

import java.util.AbstractMap; //導入方法依賴的package包/類
/**
 * <code>put</code> method that may be used to check for updates in a thread-safe manner.
 * 
 * @return <code>true</code> if the put resulted in a change in value, <code>false</code> otherwise.
 */
public boolean putAndCheckUpdate(K key, V value)
{
    AbstractMap.SimpleImmutableEntry<K, V> kvp = new AbstractMap.SimpleImmutableEntry<K, V>(key, value);
    AbstractMap.SimpleImmutableEntry<K, V> priorKVP = cache.asMap().put(key, kvp);
    return priorKVP != null && (! priorKVP.equals(kvp));
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:12,代碼來源:DefaultSimpleCache.java

示例12: next

import java.util.AbstractMap; //導入方法依賴的package包/類
public Map.Entry<K,V> next() {
    Node<K,V> n = next;
    V v = nextValue;
    advance();
    return new AbstractMap.SimpleImmutableEntry<K,V>(n.key, v);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:7,代碼來源:ConcurrentSkipListMap.java

示例13: exportEntry

import java.util.AbstractMap; //導入方法依賴的package包/類
/**
 * Return SimpleImmutableEntry for entry, or null if null
 */
static <K,V> Map.Entry<K,V> exportEntry(TreeMapBST.Entry<K,V> e) {
    return (e == null) ? null :
        new AbstractMap.SimpleImmutableEntry<>(e);
}
 
開發者ID:dmcmanam,項目名稱:bbst-showdown,代碼行數:8,代碼來源:TreeMapBST.java

示例14: exportEntry

import java.util.AbstractMap; //導入方法依賴的package包/類
/**
 * Return SimpleImmutableEntry for entry, or null if null
 */
static <K,V> Map.Entry<K,V> exportEntry(TreeMapAVLStack.Entry<K,V> e) {
    return (e == null) ? null :
        new AbstractMap.SimpleImmutableEntry<>(e);
}
 
開發者ID:dmcmanam,項目名稱:bbst-showdown,代碼行數:8,代碼來源:TreeMapAVLStack.java

示例15: testConstructor2

import java.util.AbstractMap; //導入方法依賴的package包/類
/**
 * A new SimpleImmutableEntry(k, v) holds k, v.
 */
public void testConstructor2() {
    Map.Entry s = new AbstractMap.SimpleImmutableEntry(k1, v1);
    assertEquals(k1, s.getKey());
    assertEquals(v1, s.getValue());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:EntryTest.java


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