Interface MultiSet<T>

Type Parameters:
T - the type of the objects in this multiset.
All Superinterfaces:
Collection<T>, HTMLToString, Iterable<T>
All Known Subinterfaces:
SortedMultiSet<T>
All Known Implementing Classes:
AbstractMultiSet, HashMultiSet, LinkedHashMultiSet, TreeMultiSet

public interface MultiSet<T> extends Collection<T>, HTMLToString
This class implements a mutliset. The implementation is synchronized.
Author:
bfvdonge
  • Method Details

    • add

      Integer add(T par, Integer weight)
      Adds the given object to the multiset, as many times as indicated by the given weight parameter.
      Parameters:
      par - the object to add
      weight - the number of times to add it
      Returns:
      the new number of occurrences of the object (>0)
    • toList

      List<T> toList()
      Converts this multiset to a list, such that each element occurs as often as returned by the iterator of the multiset (its number of occurrences).
      Returns:
      a list of objects as returned by the iterator
    • isLessOrEqual

      boolean isLessOrEqual(MultiSet<T> multiSet)
      returns true if this multiset is less or equal to the given multiset, i.e. all objects in this multiset should be contained in the given set and the number of occurrences in the given set is at least the number of occurrences in this multiset.
      Parameters:
      multiSet - the multiset to test
      Returns:
      true if the given multiset is less or equal.
    • occurrences

      Integer occurrences(Object source)
      returns the number of occurrences of the given object in this multiset.
      Parameters:
      source - the object to get the occurrences for
      Returns:
      the number of occurrences, 0 if the object does not occur.
    • baseSet

      Set<T> baseSet()
      returns an unmodifiable set of unique objects in the multiset.
      Returns:
      an unmodifiable set of unique objects in the multiset.