Class RegularImmutableSortedMultiset<E>

    • Field Detail

      • ZERO_CUMULATIVE_COUNTS

        private static final long[] ZERO_CUMULATIVE_COUNTS
      • cumulativeCounts

        private final transient long[] cumulativeCounts
      • offset

        private final transient int offset
      • length

        private final transient int length
    • Constructor Detail

      • RegularImmutableSortedMultiset

        RegularImmutableSortedMultiset​(java.util.Comparator<? super E> comparator)
      • RegularImmutableSortedMultiset

        RegularImmutableSortedMultiset​(RegularImmutableSortedSet<E> elementSet,
                                       long[] cumulativeCounts,
                                       int offset,
                                       int length)
    • Method Detail

      • getCount

        private int getCount​(int index)
      • firstEntry

        public Multiset.Entry<E> firstEntry()
        Description copied from interface: SortedMultiset
        Returns the entry of the first element in this multiset, or null if this multiset is empty.
      • lastEntry

        public Multiset.Entry<E> lastEntry()
        Description copied from interface: SortedMultiset
        Returns the entry of the last element in this multiset, or null if this multiset is empty.
      • count

        public int count​(@Nullable
                         java.lang.Object element)
        Description copied from interface: Multiset
        Returns the number of occurrences of an element in this multiset (the count of the element). Note that for an Object.equals(java.lang.Object)-based multiset, this gives the same result as Collections.frequency(java.util.Collection<?>, java.lang.Object) (which would presumably perform more poorly).

        Note: the utility method Iterables.frequency(java.lang.Iterable<?>, java.lang.Object) generalizes this operation; it correctly delegates to this method when dealing with a multiset, but it can also accept any other iterable type.

        Parameters:
        element - the element to count occurrences of
        Returns:
        the number of occurrences of the element in this multiset; possibly zero but never negative
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<E>
        Specified by:
        size in class java.util.AbstractCollection<E>
      • headMultiset

        public 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.

        Specified by:
        headMultiset in interface SortedMultiset<E>
        Specified by:
        headMultiset in class ImmutableSortedMultiset<E>
      • tailMultiset

        public 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.

        Specified by:
        tailMultiset in interface SortedMultiset<E>
        Specified by:
        tailMultiset in class ImmutableSortedMultiset<E>
      • isPartialView

        boolean isPartialView()
        Description copied from class: ImmutableCollection
        Returns true if this immutable collection's implementation contains references to user-created objects that aren't accessible via this collection's methods. This is generally used to determine whether copyOf implementations should make an explicit copy to avoid memory leaks.
        Specified by:
        isPartialView in class ImmutableCollection<E>