public void expandKeys() {
keyLen++;
Set<String> unusedKeysSet = new TreeSet<>();
generateKeys(keyLen, "", unusedKeysSet);
ArrayList<String> newUnusedKeys = new ArrayList<>(unusedKeysSet);
BiMap<String, TileInstance> newInstances = HashBiMap.create();
Map<Location, String> newMap = new HashMap<>();
Map<String, String> substitutions = new HashMap<>();
for(Map.Entry<String, TileInstance> instance : instances.entrySet()) {
String newKey = newUnusedKeys.get(rand.nextInt(newUnusedKeys.size()));
newUnusedKeys.remove(newKey);
substitutions.put(instance.getKey(), newKey);
newInstances.put(newKey, instance.getValue());
}
for(Map.Entry<Location, String> mapInst : map.entrySet()) {
newMap.put(mapInst.getKey(), substitutions.get(mapInst.getValue()));
}
diffStack.push(new DMMDiff.ExpandKeysDiff(this, map, newMap, instances, newInstances, unusedKeys, newUnusedKeys, keyLen-1, keyLen));
instances = newInstances;
map = newMap;
unusedKeys = newUnusedKeys;
}
java类com.google.common.collect.HashBiMap的实例源码
DMM.java 文件源码
项目:FastDMM
阅读 32
收藏 0
点赞 0
评论 0
DurabilityRegistry.java 文件源码
项目:CustomItemLibrary
阅读 27
收藏 0
点赞 0
评论 0
public void register(ItemType itemType, PluginContainer pluginContainer, Iterable<String> models, String modelDirectoryName) {
models.forEach(model -> {
BiMap<Integer, Identifier> durabilityToModelId = typeToDurabilityToModelId.computeIfAbsent(itemType, k -> HashBiMap.create());
Identifier modelId = new Identifier(pluginContainer.getId(), model);
// Is the model already registered? If so, skip.
Integer registeredDurability = durabilityToModelId.inverse().get(modelId);
if(registeredDurability == null) {
registeredDurability = getAvailableDurability(itemType);
}
DurabilityIdentifier durabilityId = new DurabilityIdentifier(itemType, registeredDurability);
durabilityIdToDirectoryName.put(durabilityId, modelDirectoryName);
durabilityIdToModelId.put(durabilityId, modelId);
durabilityToModelId.put(registeredDurability, modelId);
});
}
SqlResultSetProcessor.java 文件源码
项目:fili
阅读 29
收藏 0
点赞 0
评论 0
/**
* Builds something to process a set of sql results and return them as the
* same format as a GroupBy query to Druid.
*
* @param druidQuery The original query that was converted to a sql query.
* @param apiToFieldMapper The mapping from api to physical name.
* @param objectMapper The mapper for all JSON processing.
* @param sqlTimeConverter The time converter used with making the query.
*/
public SqlResultSetProcessor(
DruidAggregationQuery<?> druidQuery,
ApiToFieldMapper apiToFieldMapper,
ObjectMapper objectMapper,
SqlTimeConverter sqlTimeConverter
) {
this.druidQuery = druidQuery;
this.apiToFieldMapper = apiToFieldMapper;
this.objectMapper = objectMapper;
this.sqlTimeConverter = sqlTimeConverter;
this.sqlResults = new ArrayList<>();
this.columnToColumnName = HashBiMap.create();
this.groupByDimensionsCount = druidQuery.getDimensions().size();
}
DefaultValidationNotificationService.java 文件源码
项目:dhis2-core
阅读 27
收藏 0
点赞 0
评论 0
private Map<Set<User>, NotificationMessage> createSingleNotifications( SortedSet<MessagePair> messagePairs )
{
BiMap<Set<User>, NotificationMessage> singleNotificationCollection = HashBiMap.create();
for ( MessagePair messagePair : messagePairs )
{
NotificationMessage notificationMessage = notificationMessageRenderer
.render( messagePair.result, messagePair.template );
notificationMessage.setPriority( getPriority( messagePair.result.getValidationRule().getImportance() ) );
singleNotificationCollection.put( new HashSet<>(), notificationMessage );
resolveRecipients( messagePair )
.forEach( user -> singleNotificationCollection.inverse().get( notificationMessage ).add( user ) );
}
return singleNotificationCollection;
}
DefaultValidationNotificationService.java 文件源码
项目:dhis2-core
阅读 31
收藏 0
点赞 0
评论 0
private static Map<Set<User>, SortedSet<MessagePair>> groupRecipientsForMessagePairs(
Map<User, SortedSet<MessagePair>> messagePairsPerUser )
{
BiMap<Set<User>, SortedSet<MessagePair>> grouped = HashBiMap.create();
for ( Map.Entry<User, SortedSet<MessagePair>> entry : messagePairsPerUser.entrySet() )
{
User user = entry.getKey();
SortedSet<MessagePair> setOfPairs = entry.getValue();
if ( grouped.containsValue( setOfPairs ) )
{
// Value exists -> Add user to the existing key set
grouped.inverse().get( setOfPairs ).add( user );
}
else
{
// Value doesn't exist -> Add the [user, set] as a new entry
grouped.put( Sets.newHashSet( user ), setOfPairs );
}
}
return grouped;
}
P1Header.java 文件源码
项目:AppInventorRaspberryPiCompanion
阅读 92
收藏 0
点赞 0
评论 0
public P1Header() {
pinConfiguration = HashBiMap.create();
pinConfiguration.put(3, RaspiPin.GPIO_08);
pinConfiguration.put(5, RaspiPin.GPIO_09);
pinConfiguration.put(7, RaspiPin.GPIO_07);
pinConfiguration.put(8, RaspiPin.GPIO_15);
pinConfiguration.put(10, RaspiPin.GPIO_16);
pinConfiguration.put(11, RaspiPin.GPIO_00);
pinConfiguration.put(12, RaspiPin.GPIO_01);
pinConfiguration.put(13, RaspiPin.GPIO_02);
pinConfiguration.put(15, RaspiPin.GPIO_03);
pinConfiguration.put(16, RaspiPin.GPIO_04);
pinConfiguration.put(18, RaspiPin.GPIO_05);
pinConfiguration.put(19, RaspiPin.GPIO_12);
pinConfiguration.put(21, RaspiPin.GPIO_13);
pinConfiguration.put(22, RaspiPin.GPIO_06);
pinConfiguration.put(23, RaspiPin.GPIO_14);
pinConfiguration.put(24, RaspiPin.GPIO_10);
pinConfiguration.put(26, RaspiPin.GPIO_11);
}
StringToIntMapper.java 文件源码
项目:powsybl-core
阅读 36
收藏 0
点赞 0
评论 0
public StringToIntMapper(Class<S> clazz) {
this.clazz = clazz;
id2num = new EnumMap<>(clazz);
counter = new EnumMap<>(clazz);
for (S s : clazz.getEnumConstants()) {
id2num.put(s, HashBiMap.<String, Integer>create());
counter.put(s, s.getInitialValue());
}
}
StringToIntMapper.java 文件源码
项目:powsybl-core
阅读 36
收藏 0
点赞 0
评论 0
public synchronized void reset(S subset) {
if (subset == null) {
throw new IllegalArgumentException("subset is null");
}
id2num.put(subset, HashBiMap.<String, Integer>create());
counter.put(subset, subset.getInitialValue());
}
DexBuilder.java 文件源码
项目:r8
阅读 28
收藏 0
点赞 0
评论 0
private TryInfo computeTryInfo() {
// Canonical map of handlers.
BiMap<CatchHandlers<BasicBlock>, Integer> canonicalHandlers = HashBiMap.create();
// Compute the list of try items and their handlers.
List<TryItem> tryItems = computeTryItems(canonicalHandlers);
// Compute handler sets before dex items which depend on the handler index.
Try[] tries = getDexTryItems(tryItems, canonicalHandlers);
TryHandler[] handlers = getDexTryHandlers(canonicalHandlers.inverse());
return new TryInfo(tries, handlers);
}
ShellBasedIdMapping.java 文件源码
项目:hadoop-oss
阅读 38
收藏 0
点赞 0
评论 0
synchronized private void loadFullUserMap() throws IOException {
BiMap<Integer, String> uMap = HashBiMap.create();
if (OS.startsWith("Mac")) {
updateMapInternal(uMap, "user", MAC_GET_ALL_USERS_CMD, "\\s+",
staticMapping.uidMapping);
} else {
updateMapInternal(uMap, "user", GET_ALL_USERS_CMD, ":",
staticMapping.uidMapping);
}
uidNameMap = uMap;
lastUpdateTime = Time.monotonicNow();
}