Guava SortedMultiset - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava SortedMultiset class.

This code example shows how to use the following methods:entrySet, iterator, subMultiset, isEmpty, size
  } 
 
  @CollectionSize.Require(SEVERAL) 
  @CollectionFeature.Require(SUPPORTS_ADD) 
  public void testConflictingBounds() { 
    testEmptyRangeSubMultiset(sortedMultiset.subMultiset(a.getElement(), CLOSED, a.getElement(),
        OPEN));
    testEmptyRangeSubMultiset(sortedMultiset.subMultiset(a.getElement(), OPEN, a.getElement(),
        OPEN));
    testEmptyRangeSubMultiset(sortedMultiset.subMultiset(a.getElement(), OPEN, a.getElement(),
        CLOSED));
    testEmptyRangeSubMultiset(sortedMultiset.subMultiset(b.getElement(), CLOSED, a.getElement(),
        CLOSED));
    testEmptyRangeSubMultiset(sortedMultiset.subMultiset(b.getElement(), CLOSED, a.getElement(),
        OPEN));
    testEmptyRangeSubMultiset(sortedMultiset.subMultiset(b.getElement(), OPEN, a.getElement(),
        OPEN));
  } 
 
  public void testEmptyRangeSubMultiset(SortedMultiset<E> multiset) {

5
CodeRank
This code example shows how to use the following methods:headMultiset
      } 
 
      @Override 
      <E> SortedMultiset<E> subMultiset(SortedMultiset<E> multiset, List<Entry<E>> entries,
          int targetEntry) {
        return multiset.headMultiset(entries.get(targetEntry).getElement(), OPEN); 
      } 
    }; 
    abstract <E> List<Entry<E>> expectedEntries(int targetEntry, List<Entry<E>> entries);
 
    abstract <E> SortedMultiset<E> subMultiset(SortedMultiset<E> multiset, List<Entry<E>> entries,
        int targetEntry);
  } 
 
  private void testSubMultisetEntrySet(SubMultisetSpec spec) {
    List<Entry<E>> entries = copyToList(sortedMultiset.entrySet());
    for (int i = 0; i < entries.size(); i++) {
      List<Entry<E>> expected = spec.expectedEntries(i, entries);
      SortedMultiset<E> subMultiset = spec.subMultiset(sortedMultiset, entries, i);
      assertEquals(expected, copyToList(subMultiset.entrySet()));
2
CodeRank
This code example shows how to use the following methods:tailMultiset
      } 
 
      @Override 
      <E> SortedMultiset<E> subMultiset(SortedMultiset<E> multiset, List<Entry<E>> entries,
          int targetEntry) {
        return multiset.tailMultiset(entries.get(targetEntry).getElement(), CLOSED); 
      } 
    }, 
    TAIL_OPEN {
      @Override 
      <E> List<Entry<E>> expectedEntries(int targetEntry, List<Entry<E>> entries) {
        return entries.subList(targetEntry + 1, entries.size()); 
      } 
 
      @Override 
      <E> SortedMultiset<E> subMultiset(SortedMultiset<E> multiset, List<Entry<E>> entries,
          int targetEntry) {
        return multiset.tailMultiset(entries.get(targetEntry).getElement(), OPEN); 
      } 
    }, 
1
CodeRank
See Code Examples for Guava SortedMultiset Methods: