protected static void addPreferredActivityInternal( IntentFilter filter, ComponentName activity, SortedMap<ComponentName, List<IntentFilter>> preferredActivitiesMap) { List<IntentFilter> filters = preferredActivitiesMap.get(activity); if (filters == null) { filters = new ArrayList<>(); preferredActivitiesMap.put(activity, filters); } filters.add(filter); }
@Override protected Map<Integer, TypeDefinition> resolveInitializationTypes(ArgumentHandler argumentHandler) { SortedMap<Integer, TypeDefinition> namedTypes = new TreeMap<Integer, TypeDefinition>(); for (Map.Entry<String, TypeDefinition> entry : this.namedTypes.entrySet()) { namedTypes.put(argumentHandler.named(entry.getKey()), entry.getValue()); } return namedTypes; }
private List<RecordField> getRecordFields() { if (this.recordFields != null) { return this.recordFields; } // Use a SortedMap keyed by index of the field so that we can get a List of field names in the correct order final SortedMap<Integer, String> sortedMap = new TreeMap<>(); for (final Map.Entry<String, Integer> entry : csvParser.getHeaderMap().entrySet()) { sortedMap.put(entry.getValue(), entry.getKey()); } final List<RecordField> fields = new ArrayList<>(); final List<String> rawFieldNames = new ArrayList<>(sortedMap.values()); for (final String rawFieldName : rawFieldNames) { final Optional<RecordField> option = schema.getField(rawFieldName); if (option.isPresent()) { fields.add(option.get()); } else { fields.add(new RecordField(rawFieldName, RecordFieldType.STRING.getDataType())); } } this.recordFields = fields; return fields; }
private void mapBufferEntries() throws IOException { SortedMap<Long, IndexEntry> indexStartMap = new TreeMap<>(); for (Map.Entry<IndexKey, IndexEntry> columnEntry : columnEntries.entrySet()) { long startOffset = columnEntry.getValue().startOffset; indexStartMap.put(startOffset, columnEntry.getValue()); } long runningSize = 0; List<Long> offsetAccum = new ArrayList<>(); for (Map.Entry<Long, IndexEntry> offsetEntry : indexStartMap.entrySet()) { IndexEntry entry = offsetEntry.getValue(); runningSize += entry.size; if (runningSize >= MAX_ALLOCATION_SIZE) { mapAndSliceFile(indexStartMap, offsetAccum, offsetEntry.getKey()); runningSize = entry.size; offsetAccum.clear(); } offsetAccum.add(offsetEntry.getKey()); } if (offsetAccum.size() > 0) { mapAndSliceFile(indexStartMap, offsetAccum, offsetAccum.get(0) + runningSize); } }
for(final WeightedHostAddress record : records) { if (byPriority.containsKey(record.getPriority())) { byPriority.get(record.getPriority()).add(record); } else { final Set<WeightedHostAddress> set = new HashSet<>(); set.add(record); byPriority.put(record.getPriority(), set); for(Map.Entry<Integer, Set<WeightedHostAddress>> weights : byPriority.entrySet()) { final Iterator<WeightedHostAddress> i = weights.getValue().iterator(); while (i.hasNext()) { final WeightedHostAddress next = i.next(); if (next.weight == 0) { zeroWeights.add(next); i.remove(); continue; Iterator<WeightedHostAddress> iter = weights.getValue().iterator(); while (iter.hasNext()) { int needle = new Random().nextInt(iterationWeight); iter = weights.getValue().iterator(); result.add(zero);
public void installNodes(List<Address> new_nodes) { nodes.clear(); for(Address node: new_nodes) { int hash=Math.abs((node.hashCode() * FACTOR) & (HASH_SPACE - 1)); for(int i=hash; i < hash + HASH_SPACE; i++) { short new_index=(short)(i & (HASH_SPACE - 1)); if(!nodes.containsKey(new_index)) { nodes.put(new_index, node); break; } } } if(log.isTraceEnabled()) { StringBuilder sb=new StringBuilder("node mappings:\n"); for(Map.Entry<Short,Address> entry: nodes.entrySet()) { sb.append(entry.getKey() + ": " + entry.getValue()).append("\n"); } log.trace(sb); } }
public void testTailMapWriteThrough() { final SortedMap<K, V> map; try { map = makePopulatedMap(); } catch (UnsupportedOperationException e) { return; } if (map.size() < 2 || !supportsPut) { return; } Iterator<Entry<K, V>> iterator = map.entrySet().iterator(); Entry<K, V> firstEntry = iterator.next(); Entry<K, V> secondEntry = iterator.next(); K key = secondEntry.getKey(); SortedMap<K, V> subMap = map.tailMap(key); V value = getValueNotInPopulatedMap(); subMap.put(key, value); assertEquals(secondEntry.getValue(), value); assertEquals(map.get(key), value); try { subMap.put(firstEntry.getKey(), value); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
private Describe appendAllAttributes() { Map<String, String> map = driver.executeJavaScript( "var s = {};" + "var attrs = arguments[0].attributes;" + "for (var i = 0; i < attrs.length; i++) {" + " var a = attrs[i]; " + " if (a.name != 'style') {" + " s[a.name] = a.value;" + " }" + "}" + "return s;", element); SortedMap<String, String> sortedByName = new TreeMap<>(); if (map != null) { sortedByName.putAll(map); } sortedByName.put("value", element.getAttribute("value")); if (!sortedByName.containsKey("type")) { sortedByName.put("type", element.getAttribute("type")); } for (Map.Entry<String, String> entry : sortedByName.entrySet()) { attr(entry.getKey(), entry.getValue()); } return this; }
@Override public EventIndex build(String eventType) { String eventIndexDirectory = String.format("%s/%s/", shardedEventIndexDirectory, eventType); List<String> dates = Lists.newArrayList(); File[] files = new File(eventIndexDirectory).listFiles(new PatternFilenameFilter("[0-9]{8}\\.ser")); if (files != null) { for (File file : files){ dates.add(file.getName().substring(0, 8)); } } SortedMap<String, IdList> eventIdListMap = Maps.newTreeMap(); for (String date : dates) { eventIdListMap.put(date, dmaIdListFactory.build( EventIndex.getEventIdListFilename( eventIndexDirectory, date))); } return new EventIndex(eventIndexDirectory, dmaIdListFactory, eventIdListMap); } };
/** * Get a map of partitions by topic names. */ public SortedMap<String, List<Partition>> getPartitionsByTopic() { SortedMap<String, List<Partition>> partitionsByTopic = new TreeMap<>(); for (String topicName: topics()) { partitionsByTopic.put(topicName, new ArrayList<>()); } for (Map.Entry<TopicPartition, Partition> entry: _partitionsByTopicPartition.entrySet()) { partitionsByTopic.get(entry.getKey().topic()).add(entry.getValue()); } return partitionsByTopic; }
for (Path entry : stream) { if (Files.isRegularFile(entry.resolve(GameManifest.DEFAULT_FILE_NAME))) { savedGamePaths.put(Files.getLastModifiedTime(entry.resolve(GameManifest.DEFAULT_FILE_NAME)), entry); for (Map.Entry<FileTime, Path> world : savedGamePaths.entrySet()) { Path gameManifest = world.getValue().resolve(GameManifest.DEFAULT_FILE_NAME); try { if (!info.getTitle().isEmpty()) { Date date = new Date(world.getKey().toMillis()); result.add(new GameInfo(info, date, world.getValue()));
final List<RexNode> conditions = new ArrayList<>(); RexNode joinCond = join.getCondition(); conditions.add(joinCond); conditions.add(decorrelateExpr(rel.getCondition(), valueGenerator)); final RexNode condition = : new ArrayList<>(corDefOutputs.entrySet())) { final CorDef corDef = rightOutput.getKey(); if (!corDef.corr.equals(rel.getCorrelationId())) { continue; final int newRightPos = rightOutput.getValue(); SqlOperator callOp = corDef.getPredicateKind() == null ? SqlStdOperatorTable.EQUALS: corDef.getPredicateKind(); int newPos = corDefOutputs.get(corDef) + newLeftFieldCount; corDefOutputs.put(corDef, newPos);
protected String getCanonicalizedHeadersForStringToSign(SignableRequest<?> request) { List<String> headersToSign = getHeadersForStringToSign(request); for (int i = 0; i < headersToSign.size(); i++) { headersToSign.set(i, StringUtils.lowerCase(headersToSign.get(i))); } SortedMap<String, String> sortedHeaderMap = new TreeMap<String, String>(); for (Map.Entry<String, String> entry : request.getHeaders().entrySet()) { if (headersToSign.contains(StringUtils.lowerCase(entry.getKey()))) { sortedHeaderMap.put(StringUtils.lowerCase(entry.getKey()), entry.getValue()); } } StringBuilder builder = new StringBuilder(); for (Map.Entry<String, String> entry : sortedHeaderMap.entrySet()) { builder.append(StringUtils.lowerCase(entry.getKey())).append(":") .append(entry.getValue()).append("\n"); } return builder.toString(); }
for (Map.Entry<String, PackageStats> entry : stats2.packageStatsMap.entrySet()) { String key = entry.getKey(); PackageStats pkgStats2 = entry.getValue(); if (packageStatsMap.containsKey(key)) { PackageStats pkgStats = packageStatsMap.get(key); for (ClassStats classStats : pkgStats2.getClassStats()) { pkgStats.addClass(classStats, true); packageStatsMap.put(key, pkgStats2);