Interface SortedMultiset<T extends java.lang.Comparable<T>>

Type Parameters:
T - value class
All Superinterfaces:
java.lang.Comparable<SortedMultiset<T>>, java.util.Map<T,​java.lang.Integer>, Multiset<T>, java.util.SortedMap<T,​java.lang.Integer>
All Known Implementing Classes:
IntegerPartition, MpiPartition, SortedMultiset_BottomUp, SortedMultiset_TopDown

public interface SortedMultiset<T extends java.lang.Comparable<T>>
extends Multiset<T>, java.util.SortedMap<T,​java.lang.Integer>, java.lang.Comparable<SortedMultiset<T>>
A multiset with a sort relation between elements.
The sorting of elements has the following consequences: - elements must be Comparable - SortedMaps are a bit slower than HashMaps - output of sorted multisets looks nicer than that of unsorted multisets Since elements are sorted, we can easily define a sorting on SortedMultisets, too: A sorted multiset is bigger than another one if it's biggest element is bigger than the largest element of the other multiset; or the 2.nd-biggest if the biggest elements are equal; or the 3.rd biggest, and so on.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface java.util.Map

    java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
  • Method Summary

    Modifier and Type Method Description
    T getBiggestElement()  
    T getSmallestElement()  
    java.util.Iterator<java.util.Map.Entry<T,​java.lang.Integer>> getTopDownIterator()  
    SortedMultiset<T> intersect​(Multiset<T> other)
    Returns the multiset of elements contained in both this and in the other multiset.
    java.lang.String toString​(java.lang.String entrySep, java.lang.String expSep)
    Conversion to String, with

    Methods inherited from interface java.lang.Comparable

    compareTo

    Methods inherited from interface java.util.Map

    clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, equals, forEach, get, getOrDefault, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size

    Methods inherited from interface de.tilman_neumann.util.Multiset

    add, add, addAll, addAll, addAll, entrySet, equals, get, keySet, remove, remove, removeAll, size, toList, toString, totalCount

    Methods inherited from interface java.util.SortedMap

    comparator, entrySet, firstKey, headMap, keySet, lastKey, subMap, tailMap, values
  • Method Details

    • getSmallestElement

      T getSmallestElement()
      Returns:
      The smallest element.
    • getBiggestElement

      T getBiggestElement()
      Returns:
      The biggest element.
    • getTopDownIterator

      java.util.Iterator<java.util.Map.Entry<T,​java.lang.Integer>> getTopDownIterator()
      Returns:
      an iterator that returns biggest elements first.
    • intersect

      SortedMultiset<T> intersect​(Multiset<T> other)
      Returns the multiset of elements contained in both this and in the other multiset.
      Specified by:
      intersect in interface Multiset<T extends java.lang.Comparable<T>>
      Parameters:
      other -
      Returns:
      the intersection of this and the other multiset
    • toString

      java.lang.String toString​(java.lang.String entrySep, java.lang.String expSep)
      Conversion to String, with
      Parameters:
      entrySep - e.g. "*" for multiplicative elements
      expSep - e.g. "^" for multiplicative elements
      Returns:
      a string representation of this