Example usage for com.google.common.collect SortedMultiset elementSet

List of usage examples for com.google.common.collect SortedMultiset elementSet

Introduction

In this page you can find the example usage for com.google.common.collect SortedMultiset elementSet.

Prototype

@Override
SortedSet<E> elementSet();

Source Link

Document

Returns a SortedSet view of the distinct elements in this multiset.

Usage

From source file:cc.kave.commons.model.groum.comparator.ExasVector.java

private static <T extends Comparable<T>> int compare(SortedMultiset<T> s1, SortedMultiset<T> s2) {
    int sizeCompare = Integer.compare(s1.size(), s2.size());
    if (sizeCompare != 0) {
        return sizeCompare;
    }/*from  w  ww  .  java2s .  com*/
    Set<T> o1UniquePaths = s1.elementSet();
    Set<T> o2UniquePaths = s2.elementSet();
    int uniqueSizeCompare = Integer.compare(o1UniquePaths.size(), o2UniquePaths.size());
    if (uniqueSizeCompare != 0) {
        return uniqueSizeCompare;
    }
    TreeMultiset<T> pqNodes2 = TreeMultiset.create(s1);
    TreeMultiset<T> otherPQNodes2 = TreeMultiset.create(s2);

    while (!pqNodes2.isEmpty()) {
        Entry<T> o1First = pqNodes2.pollFirstEntry();
        Entry<T> o2First = otherPQNodes2.pollFirstEntry();
        int entryCompare = compare(o1First, o2First);
        if (entryCompare != 0) {
            return entryCompare;
        }
    }
    return 0;
}