Class IMultisets

java.lang.Object
org.javimmutable.collections.IMultisets

public final class IMultisets extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> IMultiset<T>
    Constructs an unsorted multiset.
    static <T> IMultiset<T>
    hashed(Iterable<? extends T> source)
    Constructs an unsorted multiset containing the values from source.
    static <T> IMultiset<T>
    hashed(Iterator<? extends T> source)
    Constructs an unsorted multiset containing the values from source.
    static <T> IMultiset<T>
    hashed(T... source)
    Constructs an unsorted multiset containing the values from source.
    static <T> IMultiset<T>
    Constructs a multiset containing all of the values in source that sorts values based on the order they were originally added to the multiset.
    static <T> IMultiset<T>
    ordered(Iterable<? extends T> source)
    Constructs a multiset containing all of the values in source that sorts values based on the order they were originally added to the multiset.
    static <T> IMultiset<T>
    ordered(Iterator<? extends T> source)
    Constructs a multiset containing all of the values in source that sorts values based on the order they were originally added to the multiset.
    static <T> IMultiset<T>
    ordered(T... source)
    Constructs a multiset containing all of the values in source that sorts values based on the order they were originally added to the multiset.
    static <T extends Comparable<T>>
    IMultiset<T>
    Constructs an empty set that sorts values in their natural sort order (using ComparableComparator).
    static <T extends Comparable<T>>
    IMultiset<T>
    sorted(Iterable<? extends T> source)
    Constructs a multiset containing all of the values in source that sorts values in their natural sort order (using ComparableComparator).
    static <T> IMultiset<T>
    sorted(Comparator<T> comparator)
    Constructs an empty multiset that sorts values using comparator.
    static <T> IMultiset<T>
    sorted(Comparator<T> comparator, Iterable<? extends T> source)
    Constructs a multiset containing all of the values in source that sorts values using comparator.
    static <T> IMultiset<T>
    sorted(Comparator<T> comparator, Iterator<? extends T> source)
    Constructs a multiset containing all of the values in source that sorts values using comparator.
    static <T> IMultiset<T>
    sorted(Comparator<T> comparator, T... source)
    Constructs a multiset containing all of the values in source that sorts values using comparator.
    static <T extends Comparable<T>>
    IMultiset<T>
    sorted(Iterator<? extends T> source)
    Constructs a multiset containing all of the values in source that sorts values in their natural sort order (using ComparableComparator).
    static <T extends Comparable<T>>
    IMultiset<T>
    sorted(T... source)
    Constructs a multiset containing all of the values in source that sorts values in their natural sort order (using ComparableComparator).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • hashed

      @Nonnull public static <T> IMultiset<T> hashed()
      Constructs an unsorted multiset.

      Implementation note: The multiset will adopt a hash code collision strategy based on the first value assigned to the multiset. All values in the map must either implement Comparable (and be comparable to all other values in the set) or not implement Comparable. Attempting to use values some of which implement Comparable and some of which do not will lead to runtime errors. It is always safest to use homogeneous values in any set.

    • hashed

      @Nonnull @SafeVarargs public static <T> IMultiset<T> hashed(T... source)
      Constructs an unsorted multiset containing the values from source.

      Implementation note: The multiset will adopt a hash code collision strategy based on the first value in source. All values in the map must either implement Comparable (and be comparable to all other values in the set) or not implement Comparable. Attempting to use values some of which implement Comparable and some of which do not will lead to runtime errors. It is always safest to use homogeneous values in any set.

    • hashed

      @Nonnull public static <T> IMultiset<T> hashed(@Nonnull Iterable<? extends T> source)
      Constructs an unsorted multiset containing the values from source.

      Implementation note: The multiset will adopt a hash code collision strategy based on the first value in source. All values in the map must either implement Comparable (and be comparable to all other values in the set) or not implement Comparable. Attempting to use values some of which implement Comparable and some of which do not will lead to runtime errors. It is always safest to use homogeneous values in any set.

    • hashed

      @Nonnull public static <T> IMultiset<T> hashed(@Nonnull Iterator<? extends T> source)
      Constructs an unsorted multiset containing the values from source.

      Implementation note: The multiset will adopt a hash code collision strategy based on the first value in source. All values in the map must either implement Comparable (and be comparable to all other values in the set) or not implement Comparable. Attempting to use values some of which implement Comparable and some of which do not will lead to runtime errors. It is always safest to use homogeneous values in any set.

    • sorted

      @Nonnull public static <T extends Comparable<T>> IMultiset<T> sorted()
      Constructs an empty set that sorts values in their natural sort order (using ComparableComparator).
    • sorted

      @Nonnull @SafeVarargs public static <T extends Comparable<T>> IMultiset<T> sorted(T... source)
      Constructs a multiset containing all of the values in source that sorts values in their natural sort order (using ComparableComparator).
    • sorted

      @Nonnull public static <T extends Comparable<T>> IMultiset<T> sorted(@Nonnull Iterable<? extends T> source)
      Constructs a multiset containing all of the values in source that sorts values in their natural sort order (using ComparableComparator).
    • sorted

      @Nonnull public static <T extends Comparable<T>> IMultiset<T> sorted(@Nonnull Iterator<? extends T> source)
      Constructs a multiset containing all of the values in source that sorts values in their natural sort order (using ComparableComparator).
    • sorted

      @Nonnull public static <T> IMultiset<T> sorted(@Nonnull Comparator<T> comparator)
      Constructs an empty multiset that sorts values using comparator.

      Note that the Comparator MUST BE IMMUTABLE. The Comparator will be retained and used throughout the life of the map and its offspring and will be aggressively shared so it is imperative that the Comparator be completely immutable.

    • sorted

      @Nonnull @SafeVarargs public static <T> IMultiset<T> sorted(@Nonnull Comparator<T> comparator, T... source)
      Constructs a multiset containing all of the values in source that sorts values using comparator.

      Note that the Comparator MUST BE IMMUTABLE. The Comparator will be retained and used throughout the life of the map and its offspring and will be aggressively shared so it is imperative that the Comparator be completely immutable.

    • sorted

      @Nonnull public static <T> IMultiset<T> sorted(@Nonnull Comparator<T> comparator, @Nonnull Iterable<? extends T> source)
      Constructs a multiset containing all of the values in source that sorts values using comparator.

      Note that the Comparator MUST BE IMMUTABLE. The Comparator will be retained and used throughout the life of the map and its offspring and will be aggressively shared so it is imperative that the Comparator be completely immutable.

    • sorted

      @Nonnull public static <T> IMultiset<T> sorted(@Nonnull Comparator<T> comparator, @Nonnull Iterator<? extends T> source)
      Constructs a multiset containing all of the values in source that sorts values using comparator.

      Note that the Comparator MUST BE IMMUTABLE. The Comparator will be retained and used throughout the life of the map and its offspring and will be aggressively shared so it is imperative that the Comparator be completely immutable.

    • ordered

      @Nonnull public static <T> IMultiset<T> ordered()
      Constructs a multiset containing all of the values in source that sorts values based on the order they were originally added to the multiset.
    • ordered

      @Nonnull @SafeVarargs public static <T> IMultiset<T> ordered(T... source)
      Constructs a multiset containing all of the values in source that sorts values based on the order they were originally added to the multiset.
    • ordered

      @Nonnull public static <T> IMultiset<T> ordered(@Nonnull Iterable<? extends T> source)
      Constructs a multiset containing all of the values in source that sorts values based on the order they were originally added to the multiset.
    • ordered

      @Nonnull public static <T> IMultiset<T> ordered(@Nonnull Iterator<? extends T> source)
      Constructs a multiset containing all of the values in source that sorts values based on the order they were originally added to the multiset.