• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LinkedHashMultiset类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



LinkedHashMultiset类属于com.google.common.collect包,在下文中一共展示了LinkedHashMultiset类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: add

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
public void add(Key<?> key, State state, Object source) {
  if (backingMap == null) {
    backingMap = Maps.newHashMap();
  }
  // if it's an instanceof Class, it was a JIT binding, which we don't
  // want to retain.
  if (source instanceof Class || source == SourceProvider.UNKNOWN_SOURCE) {
    source = null;
  }
  Multiset<Object> sources = backingMap.get(key);
  if (sources == null) {
    sources = LinkedHashMultiset.create();
    backingMap.put(key, sources);
  }
  Object convertedSource = Errors.convert(source);
  sources.add(convertedSource);

  // Avoid all the extra work if we can.
  if (state.parent() != State.NONE) {
    Set<KeyAndSource> keyAndSources = evictionCache.getIfPresent(state);
    if (keyAndSources == null) {
      evictionCache.put(state, keyAndSources = Sets.newHashSet());
    }
    keyAndSources.add(new KeyAndSource(key, convertedSource));
  }
}
 
开发者ID:maetrive,项目名称:businessworks,代码行数:27,代码来源:WeakKeySet.java


示例2: main

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
public static void main(String[] args) {
    // Parse text to separate words
    String INPUT_TEXT = "Hello World! Hello All! Hi World!";
    // Create Multiset
    Multiset<String> multiset = LinkedHashMultiset.create(Arrays.asList(INPUT_TEXT.split(" ")));

    // Print count words
    System.out.println(multiset); // print [Hello x 2, World! x 2, All!, Hi]- in predictable iteration order
    // Print all unique words
    System.out.println(multiset.elementSet());    // print [Hello, World!, All!, Hi] - in predictable iteration order

    // Print count occurrences of words
    System.out.println("Hello = " + multiset.count("Hello"));    // print 2
    System.out.println("World = " + multiset.count("World!"));    // print 2
    System.out.println("All = " + multiset.count("All!"));    // print 1
    System.out.println("Hi = " + multiset.count("Hi"));    // print 1
    System.out.println("Empty = " + multiset.count("Empty"));    // print 0

    // Print count all words
    System.out.println(multiset.size());    //print 6

    // Print count unique words
    System.out.println(multiset.elementSet().size());    //print 4
}
 
开发者ID:Vedenin,项目名称:java_in_examples,代码行数:25,代码来源:GuavaLinkedHashMultisetTest.java


示例3: main

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
public static void main(String[] args) {
    // Разберем текст на слова
    String INPUT_TEXT = "Hello World! Hello All! Hi World!";
    // Создаем Multiset
    Multiset<String> multiset = LinkedHashMultiset.create(Arrays.asList(INPUT_TEXT.split(" ")));

    // Выводим кол-вом вхождений слов
    System.out.println(multiset); // напечатает [Hello x 2, World! x 2, All!, Hi]- в порядке первого добавления элемента
    // Выводим все уникальные слова
    System.out.println(multiset.elementSet());    // напечатает [Hello, World!, All!, Hi] - в порядке первого добавления элемента

    // Выводим количество по каждому слову
    System.out.println("Hello = " + multiset.count("Hello"));    // напечатает 2
    System.out.println("World = " + multiset.count("World!"));    // напечатает 2
    System.out.println("All = " + multiset.count("All!"));    // напечатает 1
    System.out.println("Hi = " + multiset.count("Hi"));    // напечатает 1
    System.out.println("Empty = " + multiset.count("Empty"));    // напечатает 0

    // Выводим общее количества всех слов в тексте
    System.out.println(multiset.size());    //напечатает 6

    // Выводим общее количество всех уникальных слов
    System.out.println(multiset.elementSet().size());    //напечатает 4
}
 
开发者ID:Vedenin,项目名称:java_in_examples,代码行数:25,代码来源:GuavaLinkedHashMultisetTest.java


示例4: collectFilePaths

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
/**
 * Collect the file paths of the variation points of the selected elements.
 *
 * Each variation point is registered only once, even if several variants of the same variation
 * point have been selected.
 *
 * @param selection
 *            The current selection
 * @return The multi-set of variation point file paths.
 */
private LinkedHashMultiset<String> collectFilePaths(IStructuredSelection selection) {
    LinkedHashMultiset<String> filePaths = LinkedHashMultiset.create();

    Set<VariationPoint> vps = Sets.newLinkedHashSet();

    for (Object selectedItem : selection.toList()) {
        if (selectedItem instanceof Variant) {
            vps.add(((Variant) selectedItem).getVariationPoint());
        } else if (selectedItem instanceof VariationPoint) {
            vps.add((VariationPoint) selectedItem);
        }
    }

    for (VariationPoint vp : vps) {
        if (vp != null) {
            filePaths.add(getFile(vp));
        }
    }

    return filePaths;
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:32,代码来源:CopyContainingFilenameHandler.java


示例5: testSerialization

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
public void testSerialization() {
    BeanWithMultisetTypes bean = new BeanWithMultisetTypes();

    List<String> list = Arrays.asList( "foo", "abc", null, "abc" );
    List<String> listWithNonNull = Arrays.asList( "foo", "abc", "bar", "abc" );

    bean.multiset = LinkedHashMultiset.create( list );
    bean.hashMultiset = HashMultiset.create( Arrays.asList( "abc", "abc" ) );
    bean.linkedHashMultiset = LinkedHashMultiset.create( list );
    bean.sortedMultiset = TreeMultiset.create( listWithNonNull );
    bean.treeMultiset = TreeMultiset.create( listWithNonNull );
    bean.immutableMultiset = ImmutableMultiset.copyOf( listWithNonNull );
    bean.enumMultiset = EnumMultiset.create( Arrays.asList( AlphaEnum.B, AlphaEnum.A, AlphaEnum.D, AlphaEnum.A ) );

    String expected = "{" +
            "\"multiset\":[\"foo\",\"abc\",\"abc\",null]," +
            "\"hashMultiset\":[\"abc\",\"abc\"]," +
            "\"linkedHashMultiset\":[\"foo\",\"abc\",\"abc\",null]," +
            "\"sortedMultiset\":[\"abc\",\"abc\",\"bar\",\"foo\"]," +
            "\"treeMultiset\":[\"abc\",\"abc\",\"bar\",\"foo\"]," +
            "\"immutableMultiset\":[\"foo\",\"abc\",\"abc\",\"bar\"]," +
            "\"enumMultiset\":[\"A\",\"A\",\"B\",\"D\"]" +
            "}";

    assertEquals( expected, BeanWithMultisetTypesMapper.INSTANCE.write( bean ) );
}
 
开发者ID:nmorel,项目名称:gwt-jackson,代码行数:27,代码来源:MultisetGwtTest.java


示例6: testDeserialization

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
public void testDeserialization() {
    String input = "{" +
            "\"multiset\":[\"foo\",\"abc\",\"abc\",null]," +
            "\"hashMultiset\":[\"abc\",\"abc\"]," +
            "\"linkedHashMultiset\":[\"foo\",\"abc\",\"abc\",null]," +
            "\"sortedMultiset\":[\"foo\",\"abc\",\"bar\",\"abc\",null]," +
            "\"treeMultiset\":[\"bar\",\"abc\",\"abc\",\"foo\",null]," +
            "\"immutableMultiset\":[\"foo\",\"abc\",\"abc\",\"bar\",null]," +
            "\"enumMultiset\":[\"B\",\"A\",\"A\",\"D\",null]" +
            "}";

    BeanWithMultisetTypes result = BeanWithMultisetTypesMapper.INSTANCE.read( input );
    assertNotNull( result );

    List<String> expectedList = Arrays.asList( "foo", "abc", null, "abc" );
    List<String> expectedListWithNonNull = Arrays.asList( "foo", "abc", "bar", "abc" );

    assertEquals( LinkedHashMultiset.create( expectedList ), result.multiset );
    assertEquals( HashMultiset.create( Arrays.asList( "abc", "abc" ) ), result.hashMultiset );
    assertEquals( LinkedHashMultiset.create( expectedList ), result.linkedHashMultiset );
    assertEquals( TreeMultiset.create( expectedListWithNonNull ), result.sortedMultiset );
    assertEquals( TreeMultiset.create( expectedListWithNonNull ), result.treeMultiset );
    assertEquals( ImmutableMultiset.copyOf( expectedListWithNonNull ), result.immutableMultiset );
    assertEquals( EnumMultiset.create( Arrays.asList( AlphaEnum.B, AlphaEnum.A, AlphaEnum.D, AlphaEnum.A ) ), result.enumMultiset );
}
 
开发者ID:nmorel,项目名称:gwt-jackson,代码行数:26,代码来源:MultisetGwtTest.java


示例7: CSSContext

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
public CSSContext() {
  selectors = LinkedHashMultiset.create();
  classes = LinkedHashMultiset.create();
  javaClasses = LinkedHashMultiset.create();
  ids = LinkedHashMultiset.create();
  states = LinkedHashMultiset.create();
  entries = LinkedListMultimap.create();
  paints = LinkedListMultimap.create();
}
 
开发者ID:XDean,项目名称:CSS-Editor-FX,代码行数:10,代码来源:CSSContext.java


示例8: cumulateDistance

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
/**
 * Keeps the cumulated distance for all the common raw super types of the given references.
 * Interfaces that are more directly implemented will get a lower total count than more general
 * interfaces.
 */
protected void cumulateDistance(final List<LightweightTypeReference> references, Multimap<JvmType, LightweightTypeReference> all,
		Multiset<JvmType> cumulatedDistance) {
	for(LightweightTypeReference other: references) {
		Multiset<JvmType> otherDistance = LinkedHashMultiset.create();
		initializeDistance(other, all, otherDistance);
		cumulatedDistance.retainAll(otherDistance);
		for(Multiset.Entry<JvmType> typeToDistance: otherDistance.entrySet()) {
			if (cumulatedDistance.contains(typeToDistance.getElement()))
				cumulatedDistance.add(typeToDistance.getElement(), typeToDistance.getCount());
		}
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:TypeConformanceComputer.java


示例9: parseArray

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
private static Multiset<Field> parseArray(List<Object> array) throws ParserException {
    Multiset<Field> members = LinkedHashMultiset.create();
    for(Object member: array) {
        members.add(parseField(null, member));
    }
    return members;
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:8,代码来源:Schema.java


示例10: fillStats

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
private void fillStats(List<Status> list, Map<DateMidnight, Integer> map, DateMidnight start, DateMidnight end) {
    LinkedList<Status> linkedList = new LinkedList<Status>(list);
    Iterator<Status> iterator = linkedList.descendingIterator();
    if (!iterator.hasNext()) {
        return;
    }

    Multiset<DateMidnight> data = LinkedHashMultiset.create();

    Status currentStatus = iterator.next();
    DateMidnight current = new DateMidnight(currentStatus.getCreatedAt());
    while (iterator.hasNext() || currentStatus != null) {
        DateMidnight msgTime = new DateMidnight(currentStatus.getCreatedAt());
        if (current.equals(msgTime)) {
            data.add(current);
            if (iterator.hasNext()) {
                currentStatus = iterator.next();
            } else {
                currentStatus = null;
            }
        } else {
            current = current.plusDays(1);
        }
    }

    for (DateMidnight dm = start; !dm.isAfter(end); dm = dm.plusDays(1)) {
        map.put(dm, data.count(dm));
    }
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:30,代码来源:TwitterService.java


示例11: identifyDependencies

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
/**
 * Identify the dependencies between the variation points based on referring and referred
 * elements.<br>
 * Build and return an edge descriptor for each of those pairs.
 *
 * @param referenceSelector
 *            The selector for the references to consider.
 * @param index
 *            The index containing previously identified element references.
 * @return The list of identified edge descriptors.
 */
private List<VPMEdgeDescriptor> identifyDependencies(ReferenceSelector referenceSelector, VPReferenceIndex index) {
    List<VPMEdgeDescriptor> edges = Lists.newArrayList();
    List<String> edgeRegistry = new ArrayList<String>();
    Multiset<DependencyType> statistics = LinkedHashMultiset.create();

    for (Commentable element : index.referencedElementsIndex.keySet()) {
        List<VPMEdgeDescriptor> vpEdges = identifyRelatedVPsForReferencedElement(edgeRegistry, element,
                referenceSelector, index, statistics);
        edges.addAll(vpEdges);
    }

    printStatistics(statistics);
    return edges;
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:26,代码来源:JaMoPPProgramDependencyVPMAnalyzer.java


示例12: execute

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

    ISelection curSelection = HandlerUtil.getCurrentSelection(event);
    if (curSelection == null || !(curSelection instanceof IStructuredSelection)) {
        return null;
    }

    IStructuredSelection selection = (IStructuredSelection) curSelection;
    LinkedHashMultiset<String> filePaths = collectFilePaths(selection);
    String clipboardContent = buildClipboardContent(filePaths);
    copyToClipboard(clipboardContent);

    return null;
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:16,代码来源:CopyContainingFilenameHandler.java


示例13: buildClipboardContent

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
private String buildClipboardContent(LinkedHashMultiset<String> filePaths) {
    StringBuilder copyContent = new StringBuilder();
    for (String file : filePaths.elementSet()) {
        copyContent.append(FilenameUtils.getName(file));
        copyContent.append(",");
        copyContent.append(filePaths.count(file));
        copyContent.append("\r\n");
    }
    return copyContent.toString();
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:11,代码来源:CopyContainingFilenameHandler.java


示例14: add

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
public void add(Key<?> key, State state, Object source) {
  if (backingSet == null) {
    backingSet = Maps.newHashMap();
  }
  // if it's an instanceof Class, it was a JIT binding, which we don't
  // want to retain.
  if (source instanceof Class || source == SourceProvider.UNKNOWN_SOURCE) {
    source = null;
  }
  Object mapKey = toMapKey(key);
  Multiset<Object> sources = backingSet.get(mapKey);
  if (sources == null) {
    sources = LinkedHashMultiset.create();
    backingSet.put(mapKey, sources);
  }
  Object convertedSource = Errors.convert(source);
  sources.add(convertedSource);

  // Avoid all the extra work if we can.
  if (state.parent() != State.NONE) {
    Set<KeyAndSource> keyAndSources = evictionCache.getIfPresent(state);
    if (keyAndSources == null) {
      evictionCache.put(state, keyAndSources = Sets.newHashSet());
    }
    keyAndSources.add(new KeyAndSource(mapKey, convertedSource));
  }
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:28,代码来源:WeakKeySet.java


示例15: RandomRoutePlanner

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
/**
 * Creates a random route planner using the specified random seed.
 * @param seed The random seed.
 */
public RandomRoutePlanner(long seed) {
  LOGGER.info("constructor {}", seed);
  assignedParcels = LinkedHashMultiset.create();
  current = Optional.absent();
  rng = new RandomAdaptor(new MersenneTwister(seed));
}
 
开发者ID:rinde,项目名称:RinLog,代码行数:11,代码来源:RandomRoutePlanner.java


示例16: generateLinkedHashMultiset

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
@Generates private static <E> LinkedHashMultiset<E> generateLinkedHashMultiset(E freshElement) {
  LinkedHashMultiset<E> multiset = LinkedHashMultiset.create();
  multiset.add(freshElement);
  return multiset;
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:6,代码来源:FreshValueGenerator.java


示例17: testLinkedHashMultiset

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
public void testLinkedHashMultiset() {
  assertFreshInstance(new TypeToken<LinkedHashMultiset<String>>() {});
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:4,代码来源:FreshValueGeneratorTest.java


示例18: addBuilderFieldDeclaration

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
@Override
public void addBuilderFieldDeclaration(SourceBuilder code) {
  code.addLine("private final %1$s<%2$s> %3$s = %1$s.create();",
      LinkedHashMultiset.class, elementType, property.getField());
}
 
开发者ID:google,项目名称:FreeBuilder,代码行数:6,代码来源:MultisetProperty.java


示例19: TermFrequencyMap

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
public TermFrequencyMap() {
  this.termFrequencies = LinkedHashMultiset.create();
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:4,代码来源:SumBasicModel.java


示例20: IDFMap

import com.google.common.collect.LinkedHashMultiset; //导入依赖的package包/类
public IDFMap() {
  this.documentFreqMap = LinkedHashMultiset.create();
  this.totalDocumentCount = 0;
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:5,代码来源:TfidfExtractor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FormFactory类代码示例发布时间:2022-05-21
下一篇:
Java Authentication类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap