本文整理了Java中java.util.LinkedHashMap.entrySet()
方法的一些代码示例,展示了LinkedHashMap.entrySet()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedHashMap.entrySet()
方法的具体详情如下:
包路径:java.util.LinkedHashMap
类名称:LinkedHashMap
方法名:entrySet
暂无
代码示例来源:origin: apache/flink
@Nonnull
protected Stream<Map.Entry<Long, TXN>> pendingTransactions() {
return pendingCommitTransactions.entrySet().stream()
.map(e -> new AbstractMap.SimpleEntry<>(e.getKey(), e.getValue().handle));
}
代码示例来源:origin: google/guava
@Override
public Iterable<Entry<K, Collection<V>>> order(List<Entry<K, Collection<V>>> insertionOrder) {
Map<K, Collection<V>> map = new HashMap<>();
List<Entry<K, V>> builder = new ArrayList<>();
for (Entry<K, Collection<V>> entry : insertionOrder) {
for (V v : entry.getValue()) {
builder.add(mapEntry(entry.getKey(), v));
}
map.put(entry.getKey(), entry.getValue());
}
Iterable<Entry<K, V>> ordered = multimapGenerator.order(builder);
LinkedHashMap<K, Collection<V>> orderedMap = new LinkedHashMap<>();
for (Entry<K, V> entry : ordered) {
orderedMap.put(entry.getKey(), map.get(entry.getKey()));
}
return orderedMap.entrySet();
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
private void trimToSize() throws IOException {
while (size > maxSize) {
Map.Entry<String, Entry> toEvict = lruEntries.entrySet().iterator().next();
remove(toEvict.getKey());
}
}
代码示例来源:origin: alibaba/druid
public void setMaxSqlSize(int value) {
if (value == this.maxSqlSize) {
return;
}
lock.writeLock().lock();
try {
if (value < this.maxSqlSize) {
int removeCount = this.maxSqlSize - value;
Iterator<Map.Entry<String, JdbcSqlStat>> iter = sqlStatMap.entrySet().iterator();
while (iter.hasNext()) {
iter.next();
if (removeCount > 0) {
iter.remove();
removeCount--;
} else {
break;
}
}
}
this.maxSqlSize = value;
} finally {
lock.writeLock().unlock();
}
}
代码示例来源:origin: pentaho/pentaho-kettle
for ( Entry<RepositoryObjectType, List<RepositoryFile>> entry : filesByType.entrySet() ) {
SharedObjectAssembler<?> assembler = sharedObjectAssemblerMap.get( entry.getKey() );
if ( assembler == null ) {
throw new UnsupportedOperationException(
String.format( "Cannot assemble shared object of type [%s]", entry.getKey() ) ); //$NON-NLS-1$
Iterator<RepositoryFile> filesIter = entry.getValue().iterator();
List<SharedObjectInterface> sharedObjects = new ArrayList<SharedObjectInterface>( entry.getValue().size() );
while ( filesIter.hasNext() ) {
RepositoryFile file = filesIter.next();
NodeRepositoryFileData repoData = dataIter.next();
VersionSummary version = versionsIter.next();
sharedObjectsByType.put( entry.getKey(), sharedObjects );
代码示例来源:origin: neo4j/neo4j
Collection<LinkedHashMap<String, String>> hits =
(Collection<LinkedHashMap<String, String>>) JsonHelper.readJson( entity );
LinkedHashMap<String, String> nodeMapUnordered = hits.iterator().next();
LinkedHashMap<String, String> nodeMapOrdered = hits.iterator().next();
for ( Map.Entry<String, String> unorderedEntry : nodeMapUnordered.entrySet() )
assertEquals( "wrong entry for key: " + unorderedEntry.getKey(),
unorderedEntry.getValue(),
nodeMapOrdered.get( unorderedEntry.getKey() ) );
代码示例来源:origin: apache/kafka
Struct struct = new Struct(ApiKeys.FETCH.requestSchema(version()));
List<TopicAndPartitionData<PartitionData>> topicsData =
TopicAndPartitionData.batchByTopic(fetchData.entrySet().iterator());
topicData.set(TOPIC_NAME, topicEntry.topic);
List<Struct> partitionArray = new ArrayList<>();
for (Map.Entry<Integer, PartitionData> partitionEntry : topicEntry.partitions.entrySet()) {
PartitionData fetchPartitionData = partitionEntry.getValue();
Struct partitionData = topicData.instance(PARTITIONS);
partitionData.set(PARTITION_ID, partitionEntry.getKey());
partitionData.set(FETCH_OFFSET, fetchPartitionData.fetchOffset);
partitionData.set(PARTITION_MAX_BYTES, fetchPartitionData.maxBytes);
for (Map.Entry<String, List<Integer>> entry : topicsToPartitions.entrySet()) {
Struct toForgetStruct = struct.instance(FORGOTTEN_TOPICS);
toForgetStruct.set(TOPIC_NAME, entry.getKey());
toForgetStruct.set(FORGOTTEN_PARTITIONS, entry.getValue().toArray());
toForgetStructs.add(toForgetStruct);
代码示例来源:origin: stanfordnlp/CoreNLP
for (Entry<String, String> o : result.entrySet()) {
String val = resolveVars(o.getValue(), result);
result.put(o.getKey(), val);
代码示例来源:origin: apache/incubator-druid
private void resolveWaitingFutures()
{
final LinkedHashMap<CustomSettableFuture, Counter> waitingFuturesCopy = new LinkedHashMap<>();
synchronized (waitingFutures) {
waitingFuturesCopy.putAll(waitingFutures);
waitingFutures.clear();
}
for (Map.Entry<CustomSettableFuture, Counter> e : waitingFuturesCopy.entrySet()) {
try {
e.getKey().set(getRequestsSinceWithoutWait(e.getValue()));
}
catch (Exception ex) {
e.getKey().setException(ex);
}
}
}
代码示例来源:origin: micronaut-projects/micronaut-core
@Override
public Map.Entry<String, Object> lastOption() {
final Iterator<Map.Entry<String, Object>> i = undeclaredOptions.entrySet().iterator();
while (i.hasNext()) {
Map.Entry<String, Object> next = i.next();
if (!i.hasNext()) {
return next;
}
}
return null;
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
private void trimToFileCount() throws IOException {
while (fileCount > maxFileCount) {
Map.Entry<String, Entry> toEvict = lruEntries.entrySet().iterator().next();
remove(toEvict.getKey());
}
}
代码示例来源:origin: prestodb/presto
for (Entry<IdKey,ReadableObjectId> entry : _objectIds.entrySet()) {
ReadableObjectId roid = entry.getValue();
if (!roid.hasReferringProperties()) {
continue;
for (Iterator<Referring> iterator = roid.referringProperties(); iterator.hasNext(); ) {
Referring referring = iterator.next();
exception.addUnresolvedId(key, referring.getBeanType(), referring.getLocation());
代码示例来源:origin: apache/kafka
private void update(Map<TopicPartition, S> partitionToState) {
LinkedHashMap<String, List<TopicPartition>> topicToPartitions = new LinkedHashMap<>();
for (TopicPartition tp : partitionToState.keySet()) {
List<TopicPartition> partitions = topicToPartitions.computeIfAbsent(tp.topic(), k -> new ArrayList<>());
partitions.add(tp);
}
for (Map.Entry<String, List<TopicPartition>> entry : topicToPartitions.entrySet()) {
for (TopicPartition tp : entry.getValue()) {
S state = partitionToState.get(tp);
map.put(tp, state);
}
}
}
代码示例来源:origin: apache/hive
targetAliasToPartnInfo.remove(targetAlias);
List<Path> pathsToRemove = new ArrayList<>();
for (Entry<Path, ArrayList<String>> entry: targetPathToAliases.entrySet()) {
ArrayList<String> aliases = entry.getValue();
aliases.remove(targetAlias);
if (aliases.isEmpty()) {
pathsToRemove.add(entry.getKey());
List<Path> pathsToAdd = new ArrayList<>();
for (Entry<Path, ArrayList<String>> entry: sourcePathToAliases.entrySet()) {
ArrayList<String> aliases = entry.getValue();
if (aliases.contains(sourceAlias)) {
pathsToAdd.add(entry.getKey());
targetPathToAliases.put(pathToAdd, new ArrayList<String>());
代码示例来源:origin: apache/kafka
/**
* Returns the partition states in order.
*/
public List<PartitionState<S>> partitionStates() {
List<PartitionState<S>> result = new ArrayList<>();
for (Map.Entry<TopicPartition, S> entry : map.entrySet()) {
result.add(new PartitionState<>(entry.getKey(), entry.getValue()));
}
return result;
}
代码示例来源:origin: apache/kylin
private void checkOverrideProps(ProjectInstance prj) throws IOException {
LinkedHashMap<String, String> overrideProps = prj.getOverrideKylinProps();
if (overrideProps != null) {
Iterator<Map.Entry<String, String>> iterator = overrideProps.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, String> entry = iterator.next();
if (StringUtils.isAnyBlank(entry.getKey(), entry.getValue())) {
throw new IllegalStateException("Property key/value must not be blank");
}
}
}
}
代码示例来源:origin: robolectric/robolectric
@Nullable
static Object eldest(LinkedHashMap map) {
return map.isEmpty() ? null : map.entrySet().iterator().next();
}
代码示例来源:origin: redisson/redisson
for (Entry<IdKey,ReadableObjectId> entry : _objectIds.entrySet()) {
ReadableObjectId roid = entry.getValue();
if (!roid.hasReferringProperties()) {
continue;
for (Iterator<Referring> iterator = roid.referringProperties(); iterator.hasNext(); ) {
Referring referring = iterator.next();
exception.addUnresolvedId(key, referring.getBeanType(), referring.getLocation());
代码示例来源:origin: jfinal/jfinal
public Object eval(Scope scope) {
LinkedHashMap<Object, Object> valueMap = new LinkedHashMap<Object, Object>(map.size());
for (Entry<Object, Expr> e : map.entrySet()) {
valueMap.put(e.getKey(), e.getValue().eval(scope));
}
return valueMap;
}
}
代码示例来源:origin: alibaba/druid
public JdbcSqlStat getSqlStat(long id) {
lock.readLock().lock();
try {
for (Map.Entry<String, JdbcSqlStat> entry : this.sqlStatMap.entrySet()) {
if (entry.getValue().getId() == id) {
return entry.getValue();
}
}
return null;
} finally {
lock.readLock().unlock();
}
}
内容来源于网络,如有侵权,请联系作者删除!