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