本文整理了Java中com.google.common.collect.Maps.newLinkedHashMap()
方法的一些代码示例,展示了Maps.newLinkedHashMap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Maps.newLinkedHashMap()
方法的具体详情如下:
包路径:com.google.common.collect.Maps
类名称:Maps
方法名:newLinkedHashMap
[英]Creates a mutable, empty, insertion-ordered LinkedHashMapinstance.
Note: if mutability is not required, use ImmutableMap#of() instead.
[中]创建可变的、空的、按插入顺序排列的LinkedHashMapinstance。
注意:如果不需要可变性,请改用ImmutableMap#of()。
代码示例来源:origin: google/guava
@Override
protected Map<String, String> create(Entry<String, String>[] entries) {
Map<String, String> builder = Maps.newLinkedHashMap();
for (Entry<String, String> entry : entries) {
builder.put(entry.getKey(), entry.getValue());
}
return ImmutableMap.copyOf(builder);
}
}
代码示例来源:origin: apache/kylin
private Map<Integer, String> convertKeyToInteger(Map<String, String> map) {
Map<Integer, String> result = Maps.newLinkedHashMap();
for (Entry<String, String> entry : map.entrySet()) {
result.put(Integer.valueOf(entry.getKey()), entry.getValue());
}
return result;
}
代码示例来源:origin: google/guava
ImmutableSet<C> columnSpace) {
Map<R, Integer> rowIndex = Maps.indexMap(rowSpace);
Map<R, Map<C, V>> rows = Maps.newLinkedHashMap();
for (R row : rowSpace) {
rows.put(row, new LinkedHashMap<C, V>());
Map<C, Map<R, V>> columns = Maps.newLinkedHashMap();
for (C col : columnSpace) {
columns.put(col, new LinkedHashMap<R, V>());
V value = cell.getValue();
cellRowIndices[i] = rowIndex.get(rowKey);
Map<C, V> thisRow = rows.get(rowKey);
cellColumnInRowIndices[i] = thisRow.size();
V oldValue = thisRow.put(columnKey, value);
checkNoDuplicate(rowKey, columnKey, oldValue, value);
columns.get(columnKey).put(rowKey, value);
ImmutableMap.Builder<R, ImmutableMap<C, V>> rowBuilder =
new ImmutableMap.Builder<>(rows.size());
for (Entry<R, Map<C, V>> row : rows.entrySet()) {
rowBuilder.put(row.getKey(), ImmutableMap.copyOf(row.getValue()));
for (Entry<C, Map<R, V>> col : columns.entrySet()) {
columnBuilder.put(col.getKey(), ImmutableMap.copyOf(col.getValue()));
代码示例来源:origin: SonarSource/sonarqube
public Map<String, Diff> diffs() {
if (diffs.containsKey(ASSIGNEE)) {
Map<String, Diff> result = Maps.newLinkedHashMap(diffs);
result.put(ASSIGNEE, decode(result.get(ASSIGNEE)));
return result;
}
return diffs;
}
代码示例来源:origin: forcedotcom/phoenix
for (Pair<String,Object> prop : props) {
if (defaultDescriptor.getValue(prop.getFirst()) == null) {
tableProps.put(prop.getFirst(), prop.getSecond());
} else {
commonFamilyProps.put(prop.getFirst(), prop.getSecond());
Map<String, PName> familyNames = Maps.newLinkedHashMap();
boolean isPK = false;
familyNames.put(column.getFamilyName().getString(),column.getFamilyName());
for (String familyName : statement.getProps().keySet()) {
if (!familyName.equals(QueryConstants.ALL_FAMILY_PROPERTIES_KEY)) {
if (familyNames.get(familyName) == null) {
throw new SQLExceptionInfo.Builder(SQLExceptionCode.PROPERTIES_FOR_FAMILY)
.setFamilyName(familyName).build().buildException();
connection.addTable(table);
} else if (tableType == PTableType.INDEX) {
if (tableProps.get(HTableDescriptor.MAX_FILESIZE) == null) {
int nIndexRowKeyColumns = isPK ? 1 : pkColumnsNames.size();
int nIndexKeyValueColumns = columns.size() - nIndexRowKeyColumns;
代码示例来源:origin: apache/incubator-druid
public SimpleQueryableIndex(
Interval dataInterval,
Indexed<String> dimNames,
BitmapFactory bitmapFactory,
Map<String, ColumnHolder> columns,
SmooshedFileMapper fileMapper,
@Nullable Metadata metadata
)
{
Preconditions.checkNotNull(columns.get(ColumnHolder.TIME_COLUMN_NAME));
this.dataInterval = Preconditions.checkNotNull(dataInterval, "dataInterval");
ImmutableList.Builder<String> columnNamesBuilder = ImmutableList.builder();
for (String column : columns.keySet()) {
if (!ColumnHolder.TIME_COLUMN_NAME.equals(column)) {
columnNamesBuilder.add(column);
}
}
this.columnNames = columnNamesBuilder.build();
this.availableDimensions = dimNames;
this.bitmapFactory = bitmapFactory;
this.columns = columns;
this.fileMapper = fileMapper;
this.metadata = metadata;
this.dimensionHandlers = Maps.newLinkedHashMap();
initDimensionHandlers();
}
代码示例来源:origin: apache/incubator-gobblin
@Override
public Dag<JobExecutionPlan> compileFlow(Spec spec) {
// A Map from JobSpec to SpexExecutor, as the output of Flow Compiler.
Map<Spec, SpecExecutor> specExecutorInstanceMap = Maps.newLinkedHashMap();
findPath(specExecutorInstanceMap, spec);
List<JobExecutionPlan> jobExecutionPlans = new ArrayList<>();
for (Map.Entry<Spec, SpecExecutor> entry: specExecutorInstanceMap.entrySet()) {
JobExecutionPlan jobExecutionPlan = new JobExecutionPlan((JobSpec) entry.getKey(), entry.getValue());
jobExecutionPlans.add(jobExecutionPlan);
}
return new JobExecutionPlanDagFactory().createDag(jobExecutionPlans);
}
代码示例来源:origin: com.google.inject/guice
/**
* Applies all scanners to the modules we've installed. We skip certain PrivateModules because
* store them in more than one Modules map and only want to process them through one of the
* maps. (They're stored in both maps to prevent a module from being installed more than once.)
*/
void scanForAnnotatedMethods() {
for (ModuleAnnotatedMethodScanner scanner : scanners) {
// Note: we must iterate over a copy of the modules because calling install(..)
// will mutate modules, otherwise causing a ConcurrentModificationException.
for (Map.Entry<Module, ModuleInfo> entry : Maps.newLinkedHashMap(modules).entrySet()) {
Module module = entry.getKey();
ModuleInfo info = entry.getValue();
if (info.skipScanning) {
continue;
}
moduleSource = entry.getValue().moduleSource;
try {
info.binder.install(ProviderMethodsModule.forModule(module, scanner));
} catch (RuntimeException e) {
Collection<Message> messages = Errors.getMessagesFromThrowable(e);
if (!messages.isEmpty()) {
elements.addAll(messages);
} else {
addError(e);
}
}
}
}
moduleSource = null;
}
代码示例来源:origin: google/j2objc
ImmutableSet<C> columnSpace) {
Map<R, Integer> rowIndex = Maps.indexMap(rowSpace);
Map<R, Map<C, V>> rows = Maps.newLinkedHashMap();
for (R row : rowSpace) {
rows.put(row, new LinkedHashMap<C, V>());
Map<C, Map<R, V>> columns = Maps.newLinkedHashMap();
for (C col : columnSpace) {
columns.put(col, new LinkedHashMap<R, V>());
V value = cell.getValue();
+ oldValue);
columns.get(columnKey).put(rowKey, value);
ImmutableMap.Builder<R, ImmutableMap<C, V>> rowBuilder =
new ImmutableMap.Builder<>(rows.size());
for (Entry<R, Map<C, V>> row : rows.entrySet()) {
rowBuilder.put(row.getKey(), ImmutableMap.copyOf(row.getValue()));
for (Entry<C, Map<R, V>> col : columns.entrySet()) {
columnBuilder.put(col.getKey(), ImmutableMap.copyOf(col.getValue()));
代码示例来源:origin: google/guava
int misses = 0;
Map<K, V> result = Maps.newLinkedHashMap();
Set<K> keysToLoad = Sets.newLinkedHashSet();
for (K key : keys) {
V value = get(key);
if (!result.containsKey(key)) {
result.put(key, value);
if (value == null) {
misses++;
Map<K, V> newEntries = loadAll(keysToLoad, defaultLoader);
for (K key : keysToLoad) {
V value = newEntries.get(key);
if (value == null) {
throw new InvalidCacheLoadException("loadAll failed to return a value for " + key);
result.put(key, value);
result.put(key, get(key, defaultLoader));
代码示例来源:origin: MovingBlocks/Terasology
private Map<Material, Mesh> generateResult() {
Map<Material, Mesh> result = Maps.newLinkedHashMap();
for (Map.Entry<Material, MeshBuilder> entry : meshBuilders.entrySet()) {
result.put(entry.getKey(), entry.getValue().build());
}
return result;
}
代码示例来源:origin: google/guava
@Override
protected BiMap<String, String> create(Entry<String, String>[] entries) {
Map<String, String> builder = Maps.newLinkedHashMap();
for (Entry<String, String> entry : entries) {
builder.put(entry.getKey(), entry.getValue());
}
return ImmutableBiMap.copyOf(builder);
}
}
代码示例来源:origin: io.brooklyn/brooklyn-software-base
protected Map<String,Object> obtainProvisioningFlags(MachineProvisioningLocation location) {
Map<String,Object> result = Maps.newLinkedHashMap(location.getProvisioningFlags(ImmutableList.of(getClass().getName())));
result.putAll(getConfig(PROVISIONING_PROPERTIES));
if (result.get("inboundPorts") == null) {
Collection<Integer> ports = getRequiredOpenPorts();
if (ports != null && ports.size() > 0) result.put("inboundPorts", ports);
}
result.put(LocationConfigKeys.CALLER_CONTEXT.getName(), this);
return result;
}
代码示例来源:origin: apache/kylin
LinkedHashMap<String, String> allOverrideProps = Maps.newLinkedHashMap(overrideKylinProps);
for (Entry<String, String> entry : prjOverrideProps.entrySet()) {
if (!overrideKylinProps.containsKey(entry.getKey())) {
allOverrideProps.put(entry.getKey(), entry.getValue());
代码示例来源:origin: JesusFreke/smali
@Override public LinkedHashMap<String, ClassDef> get() {
Set<String> unresolvedInterfaces = new HashSet<String>(0);
LinkedHashMap<String, ClassDef> interfaces = Maps.newLinkedHashMap();
try {
for (Entry<String, ClassDef> entry: interfaceProto.getInterfaces().entrySet()) {
if (!interfaces.containsKey(entry.getKey())) {
interfaces.put(entry.getKey(), entry.getValue());
代码示例来源:origin: wildfly/wildfly
ImmutableSet<C> columnSpace) {
Map<R, Integer> rowIndex = Maps.indexMap(rowSpace);
Map<R, Map<C, V>> rows = Maps.newLinkedHashMap();
for (R row : rowSpace) {
rows.put(row, new LinkedHashMap<C, V>());
Map<C, Map<R, V>> columns = Maps.newLinkedHashMap();
for (C col : columnSpace) {
columns.put(col, new LinkedHashMap<R, V>());
V value = cell.getValue();
+ oldValue);
columns.get(columnKey).put(rowKey, value);
ImmutableMap.Builder<R, ImmutableMap<C, V>> rowBuilder =
new ImmutableMap.Builder<>(rows.size());
for (Entry<R, Map<C, V>> row : rows.entrySet()) {
rowBuilder.put(row.getKey(), ImmutableMap.copyOf(row.getValue()));
for (Entry<C, Map<R, V>> col : columns.entrySet()) {
columnBuilder.put(col.getKey(), ImmutableMap.copyOf(col.getValue()));
代码示例来源:origin: apache/incubator-gobblin
private Map<String, Map<String, TaskExecutionInfo>> getTasksForJobExecutions(Connection connection,
JobExecutionQuery query, Filter tableFilter,
Map<String, JobExecutionInfo> jobExecutionInfos) throws SQLException {
Map<String, Map<String, TaskExecutionInfo>> taskExecutionInfos = Maps.newLinkedHashMap();
if (query.isIncludeTaskExecutions() && jobExecutionInfos.size() > 0) {
String template = String.format(TASK_EXECUTION_QUERY_STATEMENT_TEMPLATE,
TaskExecutionInfo taskExecutionInfo = resultSetToTaskExecutionInfo(taskRs);
if (!taskExecutionInfos.containsKey(taskExecutionInfo.getJobId())) {
taskExecutionInfos.put(taskExecutionInfo.getJobId(), Maps.<String, TaskExecutionInfo>newLinkedHashMap());
taskExecutionInfos.get(taskExecutionInfo.getJobId()).put(taskExecutionInfo.getTaskId(), taskExecutionInfo);
代码示例来源:origin: MovingBlocks/Terasology
/**
* @return a <b>new</b> map with world-based position entries
*/
public Map<Vector3i, Boolean> getWorldEntries() {
Map<Vector3i, Boolean> result = Maps.newLinkedHashMap();
for (Entry<Vector3i, Boolean> entry : relData.entrySet()) {
Vector3i relPos = entry.getKey();
Vector3i worldPos = relativeToWorld(relPos.x, relPos.y, relPos.z);
result.put(worldPos, entry.getValue());
}
return result;
}
}
代码示例来源:origin: google/guava
@Override
public ImmutableMap<K, V> getAll(Iterable<? extends K> keys) throws ExecutionException {
Map<K, V> result = Maps.newLinkedHashMap();
for (K key : keys) {
if (!result.containsKey(key)) {
result.put(key, get(key));
}
}
return ImmutableMap.copyOf(result);
}
代码示例来源:origin: palantir/atlasdb
SafeArg.of("requestingThread", request.getCreatingThreadName()));
Map<ClientAwareReadWriteLock, LockMode> locks = Maps.newLinkedHashMap();
if (isShutDown.get()) {
throw new ServiceNotAvailableException("This lock server is shut down.");
for (Entry<ClientAwareReadWriteLock, LockMode> entry : locks.entrySet()) {
lockDescriptorMap.put(entry.getKey().getDescriptor(), entry.getValue());
indefinitelyBlockingThreads.remove(Thread.currentThread());
try {
for (Entry<ClientAwareReadWriteLock, LockMode> entry : locks.entrySet()) {
entry.getKey().get(client, entry.getValue()).unlock();
内容来源于网络,如有侵权,请联系作者删除!