Class ImmutableSortedMultiset<E>

    • Method Detail

      • of

        public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> of(E e1,
                                                                                      E e2,
                                                                                      E e3,
                                                                                      E e4)
        Returns an immutable sorted multiset containing the given elements sorted by their natural ordering.
        Throws:
        NullPointerException - if any element is null
      • of

        public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> of(E e1,
                                                                                      E e2,
                                                                                      E e3,
                                                                                      E e4,
                                                                                      E e5)
        Returns an immutable sorted multiset containing the given elements sorted by their natural ordering.
        Throws:
        NullPointerException - if any element is null
      • of

        public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> of(E e1,
                                                                                      E e2,
                                                                                      E e3,
                                                                                      E e4,
                                                                                      E e5,
                                                                                      E e6,
                                                                                      E... remaining)
        Returns an immutable sorted multiset containing the given elements sorted by their natural ordering.
        Throws:
        NullPointerException - if any element is null
      • copyOf

        public static <E extends Comparable<? super E>> ImmutableSortedMultiset<E> copyOf(E[] elements)
        Returns an immutable sorted multiset containing the given elements sorted by their natural ordering.
        Throws:
        NullPointerException - if any of elements is null
      • copyOf

        public static <E> ImmutableSortedMultiset<E> copyOf(Iterable<? extends E> elements)
        Returns an immutable sorted multiset containing the given elements sorted by their natural ordering. To create a copy of a SortedMultiset that preserves the comparator, call copyOfSorted(com.google.common.collect.SortedMultiset<E>) instead. This method iterates over elements at most once.

        Note that if s is a multiset<String>, then ImmutableSortedMultiset.copyOf(s) returns an ImmutableSortedMultiset<String> containing each of the strings in s, while ImmutableSortedMultiset.of(s) returns an ImmutableSortedMultiset<multiset<String>> containing one element (the given multiset itself).

        Despite the method name, this method attempts to avoid actually copying the data when it is safe to do so. The exact circumstances under which a copy will or will not be performed are undocumented and subject to change.

        This method is not type-safe, as it may be called on elements that are not mutually comparable.

        Throws:
        ClassCastException - if the elements are not mutually comparable
        NullPointerException - if any of elements is null
      • copyOf

        public static <E> ImmutableSortedMultiset<E> copyOf(Iterator<? extends E> elements)
        Returns an immutable sorted multiset containing the given elements sorted by their natural ordering.

        This method is not type-safe, as it may be called on elements that are not mutually comparable.

        Throws:
        ClassCastException - if the elements are not mutually comparable
        NullPointerException - if any of elements is null
      • copyOf

        public static <E> ImmutableSortedMultiset<E> copyOf(Comparator<? super E> comparator,
                                                            Iterable<? extends E> elements)
        Returns an immutable sorted multiset containing the given elements sorted by the given Comparator. This method iterates over elements at most once.

        Despite the method name, this method attempts to avoid actually copying the data when it is safe to do so. The exact circumstances under which a copy will or will not be performed are undocumented and subject to change.

        Throws:
        NullPointerException - if comparator or any of elements is null
      • copyOfSorted

        public static <E> ImmutableSortedMultiset<E> copyOfSorted(SortedMultiset<E> sortedMultiset)
        Returns an immutable sorted multiset containing the elements of a sorted multiset, sorted by the same Comparator. That behavior differs from copyOf(Iterable), which always uses the natural ordering of the elements.

        Despite the method name, this method attempts to avoid actually copying the data when it is safe to do so. The exact circumstances under which a copy will or will not be performed are undocumented and subject to change.

        This method is safe to use even when sortedMultiset is a synchronized or concurrent collection that is currently being modified by another thread.

        Throws:
        NullPointerException - if sortedMultiset or any of its elements is null
      • comparator

        public final Comparator<? super E> comparator()
        Description copied from interface: SortedMultiset
        Returns the comparator that orders this multiset, or Ordering.natural() if the natural ordering of the elements is used.
      • descendingMultiset

        public ImmutableSortedMultiset<E> descendingMultiset()
        Description copied from interface: SortedMultiset
        Returns a descending view of this multiset. Modifications made to either map will be reflected in the other.
      • headMultiset

        public abstract ImmutableSortedMultiset<E> headMultiset(E upperBound,
                                                                BoundType boundType)
        Description copied from interface: SortedMultiset
        Returns a view of this multiset restricted to the elements less than upperBound, optionally including upperBound itself. The returned multiset is a view of this multiset, so changes to one will be reflected in the other. The returned multiset supports all operations that this multiset supports.

        The returned multiset will throw an IllegalArgumentException on attempts to add elements outside its range.

      • subMultiset

        public ImmutableSortedMultiset<E> subMultiset(E lowerBound,
                                                      BoundType lowerBoundType,
                                                      E upperBound,
                                                      BoundType upperBoundType)
        Description copied from interface: SortedMultiset
        Returns a view of this multiset restricted to the range between lowerBound and upperBound. The returned multiset is a view of this multiset, so changes to one will be reflected in the other. The returned multiset supports all operations that this multiset supports.

        The returned multiset will throw an IllegalArgumentException on attempts to add elements outside its range.

        This method is equivalent to tailMultiset(lowerBound, lowerBoundType).headMultiset(upperBound, upperBoundType).

      • tailMultiset

        public abstract ImmutableSortedMultiset<E> tailMultiset(E lowerBound,
                                                                BoundType boundType)
        Description copied from interface: SortedMultiset
        Returns a view of this multiset restricted to the elements greater than lowerBound, optionally including lowerBound itself. The returned multiset is a view of this multiset, so changes to one will be reflected in the other. The returned multiset supports all operations that this multiset supports.

        The returned multiset will throw an IllegalArgumentException on attempts to add elements outside its range.

      • reverseOrder

        public static <E extends Comparable<?>> ImmutableSortedMultiset.Builder<E> reverseOrder()
        Returns a builder that creates immutable sorted multisets whose elements are ordered by the reverse of their natural ordering.

        Note: the type parameter E extends Comparable<?> rather than Comparable<? super E> as a workaround for javac bug 6468354.

      • naturalOrder

        public static <E extends Comparable<?>> ImmutableSortedMultiset.Builder<E> naturalOrder()
        Returns a builder that creates immutable sorted multisets whose elements are ordered by their natural ordering. The sorted multisets use Ordering.natural() as the comparator. This method provides more type-safety than builder(), as it can be called only for classes that implement Comparable.

        Note: the type parameter E extends Comparable<?> rather than Comparable<? super E> as a workaround for javac bug 6468354.