当前位置: 首页>>代码示例>>Java>>正文


Java TreeMultimap.put方法代码示例

本文整理汇总了Java中com.google.common.collect.TreeMultimap.put方法的典型用法代码示例。如果您正苦于以下问题:Java TreeMultimap.put方法的具体用法?Java TreeMultimap.put怎么用?Java TreeMultimap.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.TreeMultimap的用法示例。


在下文中一共展示了TreeMultimap.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: build

import com.google.common.collect.TreeMultimap; //导入方法依赖的package包/类
private IndexToIndexMultiMap build() throws IOException {
    final TreeMultimap<Integer, Integer> elements = TreeMultimap.create();
    for (int i = 0; i < DOCS; i++) {
        elements.put(i / 2, i);
    }
    final com.yandex.yoctodb.util.mutable.IndexToIndexMultiMap mutable =
            new com.yandex.yoctodb.util.mutable.impl.BitSetIndexToIndexMultiMap(
                    elements.asMap().values(),
                    DOCS);

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    mutable.writeTo(baos);

    final Buffer buf = Buffer.from(baos.toByteArray());

    assertEquals(
            V1DatabaseFormat.MultiMapType.LONG_ARRAY_BIT_SET_BASED.getCode(),
            buf.getInt());

    final IndexToIndexMultiMap result =
            BitSetIndexToIndexMultiMap.from(buf);

    assertEquals(DOCS / 2, result.getKeysCount());

    return result;
}
 
开发者ID:yandex,项目名称:yoctodb,代码行数:27,代码来源:BitSetIndexToIndexMultiMapTest.java

示例9: buildInt

import com.google.common.collect.TreeMultimap; //导入方法依赖的package包/类
@Test
public void buildInt() throws IOException {
    final TreeMultimap<Integer, Integer> elements = TreeMultimap.create();
    for (int i = 0; i < DOCS; i++) {
        elements.put(i / 2, i);
    }
    final com.yandex.yoctodb.util.mutable.IndexToIndexMultiMap mutable =
            new com.yandex.yoctodb.util.mutable.impl.IntIndexToIndexMultiMap(
                    elements.asMap().values());

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    mutable.writeTo(baos);

    final Buffer buf = Buffer.from(baos.toByteArray());

    final IndexToIndexMultiMap result =
            IndexToIndexMultiMapReader.from(buf);

    assertTrue(result instanceof IntIndexToIndexMultiMap);
}
 
开发者ID:yandex,项目名称:yoctodb,代码行数:21,代码来源:IndexToIndexMultiMapReaderTest.java

示例10: buildBitSet

import com.google.common.collect.TreeMultimap; //导入方法依赖的package包/类
@Test
public void buildBitSet() throws IOException {
    final TreeMultimap<Integer, Integer> elements = TreeMultimap.create();
    for (int i = 0; i < DOCS; i++) {
        elements.put(i / 2, i);
    }
    final com.yandex.yoctodb.util.mutable.IndexToIndexMultiMap mutable =
            new com.yandex.yoctodb.util.mutable.impl.BitSetIndexToIndexMultiMap(
                    elements.asMap().values(),
                    DOCS);

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    mutable.writeTo(baos);

    final Buffer buf = Buffer.from(baos.toByteArray());

    final IndexToIndexMultiMap result =
            IndexToIndexMultiMapReader.from(buf);

    assertTrue(result instanceof BitSetIndexToIndexMultiMap);
}
 
开发者ID:yandex,项目名称:yoctodb,代码行数:22,代码来源:IndexToIndexMultiMapReaderTest.java

示例11: build

import com.google.common.collect.TreeMultimap; //导入方法依赖的package包/类
private IndexToIndexMultiMap build() throws IOException {
    final TreeMultimap<Integer, Integer> elements = TreeMultimap.create();
    for (int i = 0; i < VALUES; i++) {
        elements.put(i / 2, i);
    }
    final com.yandex.yoctodb.util.mutable.IndexToIndexMultiMap mutable =
            new com.yandex.yoctodb.util.mutable.impl.IntIndexToIndexMultiMap(
                    elements.asMap().values());

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    mutable.writeTo(baos);

    final Buffer buf = Buffer.from(baos.toByteArray());

    assertEquals(
            V1DatabaseFormat.MultiMapType.LIST_BASED.getCode(),
            buf.getInt());

    final IndexToIndexMultiMap result =
            IntIndexToIndexMultiMap.from(buf);

    assertEquals(VALUES / 2, result.getKeysCount());

    return result;
}
 
开发者ID:yandex,项目名称:yoctodb,代码行数:26,代码来源:IntIndexToIndexMultiMapTest.java

示例12: prepareData

import com.google.common.collect.TreeMultimap; //导入方法依赖的package包/类
private Buffer prepareData(
        final int keys,
        final int values) throws IOException {
    final TreeMultimap<Integer, Integer> elements = TreeMultimap.create();
    for (int i = 0; i < keys; i++) {
        //same elements
        elements.put(i, (keys - i) % values);
        elements.put(i, (keys - i) % values);
        elements.put(i, (keys - i) % values);
        elements.put(i, (keys - i) % values);

        elements.put(i, (2 * keys - i) % values);
        elements.put(i, (3 * keys - i) % values);
    }
    final com.yandex.yoctodb.util.mutable.IndexToIndexMultiMap indexToIndexMultiMap =
            new com.yandex.yoctodb.util.mutable.impl.IntIndexToIndexMultiMap(
                    elements.asMap().values());

    final ByteArrayOutputStream os = new ByteArrayOutputStream();
    indexToIndexMultiMap.writeTo(os);
    Assert.assertEquals(os.size(), indexToIndexMultiMap.getSizeInBytes());
    return Buffer.from(os.toByteArray());
}
 
开发者ID:yandex,项目名称:yoctodb,代码行数:24,代码来源:IntIndexToIndexMultiMapTest.java

示例13: string

import com.google.common.collect.TreeMultimap; //导入方法依赖的package包/类
@Test
public void string() {
    final TreeMultimap<Integer, Integer> elements = TreeMultimap.create();
    final int documents = 10;
    for (int i = 0; i < documents; i++)
        elements.put(i / 2, i);
    final IndexToIndexMultiMap set =
            new BitSetIndexToIndexMultiMap(
                    elements.asMap().values(),
                    documents);
    final String text = set.toString();
    assertTrue(text.contains(Integer.toString(documents / 2)));
    assertTrue(text.contains(Integer.toString(documents)));
    set.getSizeInBytes();
    assertTrue(text.contains(Integer.toString(documents / 2)));
    assertTrue(text.contains(Integer.toString(documents)));
}
 
开发者ID:yandex,项目名称:yoctodb,代码行数:18,代码来源:BitSetIndexToIndexMultiMapTest.java

示例14: forkByClassifier

import com.google.common.collect.TreeMultimap; //导入方法依赖的package包/类
private Map<String, TreeMultimap<Calendar, ItemInfo>> forkByClassifier(
        TreeMultimap<Calendar, ItemInfo> cleanupCandidates) {
    Map<String, TreeMultimap<Calendar, ItemInfo>> result= Maps.newHashMap();
    for (Calendar calendar : cleanupCandidates.keySet()) {
        NavigableSet<ItemInfo> itemInfos = cleanupCandidates.get(calendar);
        for (ItemInfo itemInfo : itemInfos) {
            String classifier=resolveClassifier(itemInfo);
            TreeMultimap<Calendar, ItemInfo> classifierMap = result.get(classifier);
            if(classifierMap==null){
                //classifierMap= TreeMultimap.create(Ordering.natural().reverse(), Ordering.natural().reverse());
                classifierMap= TreeMultimap.create(Ordering.natural(), Ordering.natural());;
                result.put(classifier,classifierMap);
            }
            classifierMap.put(calendar,itemInfo);
        }
    }
    return result;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:19,代码来源:IntegrationCleanupServiceImpl.java

示例15: findCandidatesFor

import com.google.common.collect.TreeMultimap; //导入方法依赖的package包/类
private TreeMultimap<String, MatchCandidate> findCandidatesFor(Map<String, Field> fields) throws StageException {
  TreeMultimap<String, MatchCandidate> candidates = TreeMultimap.create();

  for (String outputField : outputFieldNames) {
    for (Map.Entry<String, Field> entry : fields.entrySet()) {
      String fieldPath = entry.getKey();
      Field field = entry.getValue();
      int score = FuzzyMatch.getRatio(outputField, fieldPath, true);
      if (score >= matchThreshold) {
        if (greaterScore(candidates.get(outputField), score) || allCandidates) {
          if (!allCandidates) {
            // If not storing all candidates we must clear any existing candidates for this key
            // since a Multimap won't replace multiple values for a key.
            candidates.get(outputField).clear();
          }
          candidates.put(outputField, new MatchCandidate(outputField, score, fieldPath, field));
        }
      }
    }
  }

  return candidates;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:24,代码来源:FuzzyFieldProcessor.java


注:本文中的com.google.common.collect.TreeMultimap.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。