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

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

Introduction

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

Prototype

int size();

Source Link

Document

Returns the number of elements in this collection.

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;
    }// w w w  .j a  va2  s . c  o  m
    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;
}