本文整理汇总了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");
}
};
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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;
}
}
示例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());
}
}
示例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);
}
示例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);
}
示例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();
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}