當前位置: 首頁>>代碼示例>>Java>>正文


Java TreeMultimap類代碼示例

本文整理匯總了Java中com.google.common.collect.TreeMultimap的典型用法代碼示例。如果您正苦於以下問題:Java TreeMultimap類的具體用法?Java TreeMultimap怎麽用?Java TreeMultimap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TreeMultimap類屬於com.google.common.collect包,在下文中一共展示了TreeMultimap類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: build

import com.google.common.collect.TreeMultimap; //導入依賴的package包/類
public ColumnFilter build()
{
    boolean isFetchAll = metadata != null;

    PartitionColumns queried = queriedBuilder == null ? null : queriedBuilder.build();
    // It's only ok to have queried == null in ColumnFilter if isFetchAll. So deal with the case of a selectionBuilder
    // with nothing selected (we can at least happen on some backward compatible queries - CASSANDRA-10471).
    if (!isFetchAll && queried == null)
        queried = PartitionColumns.NONE;

    SortedSetMultimap<ColumnIdentifier, ColumnSubselection> s = null;
    if (subSelections != null)
    {
        s = TreeMultimap.create(Comparator.<ColumnIdentifier>naturalOrder(), Comparator.<ColumnSubselection>naturalOrder());
        for (ColumnSubselection subSelection : subSelections)
            s.put(subSelection.column().name, subSelection);
    }

    return new ColumnFilter(isFetchAll, metadata, queried, s);
}
 
開發者ID:Netflix,項目名稱:sstable-adaptor,代碼行數:21,代碼來源:ColumnFilter.java

示例2: build

import com.google.common.collect.TreeMultimap; //導入依賴的package包/類
public void build() {
    groups = TreeMultimap.create(new Comparator<String>() {
        public int compare(String string1, String string2) {
            return string1.compareToIgnoreCase(string2);
        }
    }, new Comparator<TaskDetails>() {
        public int compare(TaskDetails task1, TaskDetails task2) {
            return task1.getPath().compareTo(task2.getPath());
        }
    });
    for (TaskReportModel project : projects) {
        for (String group : project.getGroups()) {
            if (isVisible(group)) {
                for (final TaskDetails task : project.getTasksForGroup(group)) {
                    groups.put(group, mergeTasksWithSameName ? new MergedTaskDetails(task) : task);
                }
            }
        }
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:21,代碼來源:AggregateMultiProjectTaskReportModel.java

示例3: mapOpenPorts

import com.google.common.collect.TreeMultimap; //導入依賴的package包/類
private static Map<String, Map<String, Multimap<Protocol, Integer>>> mapOpenPorts(@NonNull final List<PropertyChange> _propertyChanges,
                                                                                  @NonNull final PortScannerResult _portScannerResult) {
    final Map<String, Map<String, Multimap<Protocol, Integer>>> result = new TreeMap<>();

    for(final PropertyChange propertyChange : _propertyChanges) {
        final String networkId = getNetworkId(propertyChange, _portScannerResult);
        final Pair<String, OpenHost> openHost = getOpenHost(propertyChange, _portScannerResult);
        final Port port = openHost.getValue().getOpenPorts().get(Integer.parseInt(propertyChange.getKey()));

        result.putIfAbsent(networkId, new TreeMap<>());
        final Map<String, Multimap<Protocol, Integer>> openHostToOpenPortsMultimap = result.get(networkId);

        openHostToOpenPortsMultimap.putIfAbsent(openHost.getKey(), TreeMultimap.create());
        final Multimap<Protocol, Integer> openPortsMultimap = openHostToOpenPortsMultimap.get(openHost.getKey());

        openPortsMultimap.put(port.getProtocol(), port.getPortNumber());
    }

    return result;
}
 
開發者ID:jonfryd,項目名稱:tifoon,代碼行數:21,代碼來源:PortScannerStatsServiceImpl.java

示例4: alternateNames

import com.google.common.collect.TreeMultimap; //導入依賴的package包/類
private static TreeMultimap<Integer, AlternateName> alternateNames(String path) {
    Stopwatch stopwatch = Stopwatch.createStarted();
    TreeMultimap<Integer, AlternateName> multimap = TreeMultimap.create();
    try (BufferedReader br = new BufferedReader(new FileReader(path))) {
        for (String line = br.readLine(); line != null; line = br.readLine()) {
            List<String> list = Splitter.on('\t').splitToList(line);
            if ("fr".equals(list.get(2))) {
                AlternateName name = new AlternateName(list.get(3), "1".equals(list.get(4)), "1".equals(list.get(5)), "1".equals(list.get(6)), "1".equals(list.get(7)));
                multimap.put(parseInt(list.get(1)), name);
            }
        }
    }
    catch (IOException e) {
        throw propagate(e);
    }
    log.info("Alternate names loaded: {}s", stopwatch.elapsed(SECONDS));
    return multimap;
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:19,代碼來源:Geonames.java

示例5: spFile

import com.google.common.collect.TreeMultimap; //導入依賴的package包/類
private static Multimap<Long, SignPostPath> spFile(TomtomFolder folder) {
    File file = new File(folder.getFile("sp.dbf"));
    Multimap<Long, SignPostPath> result = TreeMultimap.create();
    if (!file.exists()) {
        return result;
    }
    log.info("Reading SP {}", file);
    try (DbfReader reader = new DbfReader(file)) {
        DbfRow row;
        while ((row = reader.nextRow()) != null) {
            SignPostPath path = SignPostPath.fromRow(row);
            result.put(path.getId(), path);
        }
    }
    log.info("Loaded {} sign paths", result.size());
    return result;
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:18,代碼來源:SignPosts.java

示例6: loadTimeDomains

import com.google.common.collect.TreeMultimap; //導入依賴的package包/類
private Multimap<Long, TimeDomains> loadTimeDomains(String filename) {
    Multimap<Long, TimeDomains> times = TreeMultimap.create();
    File file = new File(filename);
    if (!file.exists()) {
        log.info("File not found : {}", file.getAbsolutePath());
        return times;
    }

    log.info("Reading TD {}", file);
    processDbf(file, row -> {
        TimeDomains restriction = new TimeDomains(((Double)row[0]).longValue(), new String((byte[]) row[3]).trim());
        times.put(restriction.getId(), restriction);
    });

    log.info("Loaded {} times domains", times.size());

    return times;
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:19,代碼來源:TdDbf.java

示例7: loadSpeedProfiles

import com.google.common.collect.TreeMultimap; //導入依賴的package包/類
private static Map<Integer, PrecomputeSpeedProfile> loadSpeedProfiles(String filename) {
    File file = new File(filename);
    if (!file.exists()) {
        log.info("File not found : {}", file.getAbsolutePath());
        return newHashMap();
    }

    TreeMultimap<Integer, SpeedProfile> profilesMap = TreeMultimap.create();
    log.info("Reading HSPR {}", file);
    try (DbfReader reader = new DbfReader(file)) {
        DbfRow row;
        while ((row = reader.nextRow()) != null) {
            SpeedProfile profile = new SpeedProfile(row.getInt("PROFILE_ID"), row.getInt("TIME_SLOT"), row.getDouble("REL_SP"));
            profilesMap.put(profile.getId(), profile);
        }
    }
    log.info("Loaded {} hspr", profilesMap.size());

    return profilesMap.asMap().entrySet().stream().collect(toMap(Entry::getKey, e -> precomputeProfile(e.getValue())));
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:21,代碼來源:HsprDbf.java

示例8: tag

import com.google.common.collect.TreeMultimap; //導入依賴的package包/類
public Map<String, String> tag(Feature feature) {
    TreeMultimap<String, Integer> speeds = TreeMultimap.create();
    List<SpeedRestriction> restrictions = dbf.getSpeedRestrictions(feature.getLong("ID"));
    boolean reversed = isReversed(feature);
    for (SpeedRestriction restriction : restrictions) {
        switch (restriction.getValidity()) {
            case positive:
                speeds.put(reversed ? "maxspeed:backward" : "maxspeed:forward", restriction.getSpeed());
                break;
            case negative:
                speeds.put(reversed ? "maxspeed:forward" : "maxspeed:backward", restriction.getSpeed());
                break;
            case both:
                speeds.put("maxspeed", restriction.getSpeed());
                break;
        }
    }
    Map<String, String> result = Maps.newHashMap();
    for (String key : speeds.keySet()) {
        result.put(key, String.valueOf(speeds.get(key).iterator().next()));
    }
    return result;
}
 
開發者ID:Mappy,項目名稱:fpm,代碼行數:24,代碼來源:SpeedRestrictionTagger.java

示例9: visitObjectLiteral

import com.google.common.collect.TreeMultimap; //導入依賴的package包/類
@Override
public String visitObjectLiteral(ObjectLiteral node, Void context) {
    StringBuilder builder = new StringBuilder("{");
    boolean first = true;
    TreeMultimap<String, Expression> sorted = TreeMultimap.create(
            Ordering.natural().nullsLast(),
            Ordering.usingToString().nullsLast()
    );
    sorted.putAll(node.values());
    for (Map.Entry<String, Expression> entry : sorted.entries()) {
        if (!first) {
            builder.append(", ");
        } else {
            first = false;
        }
        builder.append(formatIdentifier(entry.getKey()))
               .append("= ")
               .append(entry.getValue().accept(this, context));

    }
    return builder.append("}").toString();
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:23,代碼來源:ExpressionFormatter.java

示例10: indexSolutionGeneratorsOld

import com.google.common.collect.TreeMultimap; //導入依賴的package包/類
/**
     * Repartition subsequent partitions while the predicate is true
     *
     * This unifies three common use cases:
     * - k = 0   : Do not repartition at all
     * - k = 1   : Repartition the next largest equivalence class
     * - k = null: Repartition all equivalence classes
     *
     */
//    public static <N, M> Entry<? extends Collection<M>, ? extends Collection<M>>
//        nextEquivClassRepartitionK(TreeMultimap<K, V> equivClasses, BiPredicate<Integer, Entry<? extends Collection<M>, ? extends Collection<M>>>) {
//        return null;
//    }
//


    public static <S> TreeMultimap<Long, Problem<S>> indexSolutionGeneratorsOld(Collection<Problem<S>> solGens) {
        TreeMultimap<Long, Problem<S>> result = TreeMultimap.create();

        for(Problem<S> solutionGenerator : solGens) {
            long size = solutionGenerator.getEstimatedCost();
            result.put(size, solutionGenerator);
        }

        return result;
    }
 
開發者ID:SmartDataAnalytics,項目名稱:SubgraphIsomorphismIndex,代碼行數:27,代碼來源:IsoUtils.java

示例11: testCreate

import com.google.common.collect.TreeMultimap; //導入依賴的package包/類
/**
 * 基本數據類型的排序
 */
@Test
public void testCreate() {
    TreeMultimap<String, Integer> treeMultimap = TreeMultimap.create();
    treeMultimap.put("list_1", 1);
    treeMultimap.put("list_1", 1);
    treeMultimap.put("list_1", 2);
    treeMultimap.put("list_1", 9);
    treeMultimap.put("list_1", 7);
    treeMultimap.put("list_1", 3);

    treeMultimap.put("list_2", 9);
    treeMultimap.put("list_2", 7);

    // {list_1=[1, 2, 3, 7, 9], list_2=[7, 9]}
    System.out.println(treeMultimap);
}
 
開發者ID:cbooy,項目名稱:cakes,代碼行數:20,代碼來源:TreeMultimapDemo.java

示例12: testSelfDataOrdered

import com.google.common.collect.TreeMultimap; //導入依賴的package包/類
/**
 * 測試 TreeMultimap,自定義數據結構的排序
 */
@Test
public void testSelfDataOrdered() {
    // 創建TreeMultimap,使用Ordering.natural()指定自然排序,Ordering.from指定排序規則
    // Order4TreeMultimap::compareTo 是lambda的簡寫形式
    TreeMultimap<String, Order4TreeMultimap> treeMultimap = TreeMultimap
            .create(Ordering.natural(),
                    Ordering.from(Order4TreeMultimap::compareTo));

    // 列表2
    treeMultimap.put("order_list1", new Order4TreeMultimap(1, "haha1"));
    treeMultimap.put("order_list1", new Order4TreeMultimap(5, "haha2"));
    treeMultimap.put("order_list1", new Order4TreeMultimap(9, "haha3"));
    treeMultimap.put("order_list1", new Order4TreeMultimap(10, "haha3"));
    treeMultimap.put("order_list1", new Order4TreeMultimap(22, "haha4"));
    treeMultimap.put("order_list1", new Order4TreeMultimap(444, "haha5"));

    // 列表2
    treeMultimap.put("order_list2", new Order4TreeMultimap(1, "haha3"));
    treeMultimap.put("order_list2", new Order4TreeMultimap(3, "haha4"));
    treeMultimap.put("order_list3", new Order4TreeMultimap(2, "haha5"));

    // 輸出
    treeMultimap.forEach((key, order) -> System.out.println("key=" + key + ",order=" + order));
}
 
開發者ID:cbooy,項目名稱:cakes,代碼行數:28,代碼來源:TreeMultimapDemo.java

示例13: identifyDuplicates

import com.google.common.collect.TreeMultimap; //導入依賴的package包/類
private void identifyDuplicates(List<ModContainer> mods)
{
    TreeMultimap<ModContainer, File> dupsearch = TreeMultimap.create(new ModIdComparator(), Ordering.arbitrary());
    for (ModContainer mc : mods)
    {
        if (mc.getSource() != null)
        {
            dupsearch.put(mc, mc.getSource());
        }
    }

    ImmutableMultiset<ModContainer> duplist = Multisets.copyHighestCountFirst(dupsearch.keys());
    SetMultimap<ModContainer, File> dupes = LinkedHashMultimap.create();
    for (Entry<ModContainer> e : duplist.entrySet())
    {
        if (e.getCount() > 1)
        {
            FMLLog.severe("Found a duplicate mod %s at %s", e.getElement().getModId(), dupsearch.get(e.getElement()));
            dupes.putAll(e.getElement(),dupsearch.get(e.getElement()));
        }
    }
    if (!dupes.isEmpty())
    {
        throw new DuplicateModsFoundException(dupes);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:27,代碼來源:Loader.java

示例14: calcCoverage

import com.google.common.collect.TreeMultimap; //導入依賴的package包/類
/**
 * Generates a coverage multimap from split key to Regions that start with the
 * split key.
 * 
 * @return coverage multimap
 */
public Multimap<byte[], R> calcCoverage() {
  // This needs to be sorted to force the use of the comparator on the values,
  // otherwise byte array comparison isn't used
  Multimap<byte[], R> regions = TreeMultimap.create(BYTES_COMPARATOR,
      rangeCmp);

  // march through all splits from the start points
  for (Entry<byte[], Collection<R>> start : starts.asMap().entrySet()) {
    byte[] key = start.getKey();
    for (R r : start.getValue()) {
      regions.put(key, r);

      for (byte[] coveredSplit : splits.subSet(r.getStartKey(),
          specialEndKey(r))) {
        regions.put(coveredSplit, r);
      }
    }
  }
  return regions;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:27,代碼來源:RegionSplitCalculator.java

示例15: chooseBestRecord

import com.google.common.collect.TreeMultimap; //導入依賴的package包/類
/**
 * Chooses the best SMTP server, given a list of MX records.
 * TODO: Actually choose the best record!
 *
 * @param records The MX records.
 * @return An optional, possibly containing an SMTP server address.
 */
private Optional<String> chooseBestRecord(List<Record> records) {
    TreeMultimap<Integer, String> recordMap = decodeRecords(records);

    if(!recordMap.isEmpty()) {
        List<String> topRecords = new LinkedList<>(recordMap.asMap().firstEntry().getValue());

        if(!topRecords.isEmpty()) {
            String record = topRecords.get(0);

            return Optional.of(record.substring(0, record.length() - 1));
        }

    }

    return Optional.empty();
}
 
開發者ID:stevesoltys,項目名稱:carrier,代碼行數:24,代碼來源:MailResolverService.java


注:本文中的com.google.common.collect.TreeMultimap類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。