Interface IMemoryView<T>

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default java.util.Map<T,​java.lang.Integer> asMap()
      For compatibility with legacy code relying on element-to-integer maps.
      default java.util.stream.Stream<T> asStream()  
      boolean containsNonZero​(T value)  
      boolean containsNonZeroUnsafe​(java.lang.Object value)  
      java.util.Set<T> distinctValues()
      The set of distinct values
      default java.lang.Iterable<java.util.Map.Entry<T,​java.lang.Integer>> entriesWithMultiplicities()  
      static <T> boolean equals​(IMemoryView<T> self, java.lang.Object obj)
      Provides semantic equality comparison.
      default void forEachEntryWithMultiplicities​(java.util.function.BiConsumer<T,​java.lang.Integer> entryConsumer)
      Process contained values with their multiplicities
      static <T> IMemoryView<T> fromMap​(java.util.Map<T,​java.lang.Integer> wrapped)
      For compatibility with legacy code relying on element-to-integer maps.
      int getCount​(T value)
      Returns the number of occurrences of the given value.
      int getCountUnsafe​(java.lang.Object value)
      Returns the number of occurrences of the given value (which may be of any type).
      static <T> int hashCode​(IMemoryView<T> memory)
      Provides semantic hashCode() comparison.
      boolean isEmpty()  
      int size()  
      default T theContainedVersionOf​(T value)
      Where supported, returns the stored element that is equal to the given value, or null if none.
      default T theContainedVersionOfUnsafe​(java.lang.Object value)
      Where supported, returns the stored element that is equal to the given value (of any type), or null if none.
      • Methods inherited from interface java.lang.Iterable

        forEach, iterator, spliterator
    • Method Detail

      • getCount

        int getCount​(T value)
        Returns the number of occurrences of the given value.
        Returns:
        the number of occurrences
      • getCountUnsafe

        int getCountUnsafe​(java.lang.Object value)
        Returns the number of occurrences of the given value (which may be of any type).
        Returns:
        the number of occurrences
      • containsNonZero

        boolean containsNonZero​(T value)
        Returns:
        true if the given value is contained with a nonzero multiplicity
      • containsNonZeroUnsafe

        boolean containsNonZeroUnsafe​(java.lang.Object value)
        Returns:
        true if the given value (which may be of any type) is contained with a nonzero multiplicity
      • size

        int size()
        Returns:
        the number of distinct values
      • isEmpty

        boolean isEmpty()
        Returns:
        iff contains at least one value with non-zero occurrences
      • distinctValues

        java.util.Set<T> distinctValues()
        The set of distinct values
      • theContainedVersionOf

        default T theContainedVersionOf​(T value)
        Where supported, returns the stored element that is equal to the given value, or null if none. Useful for canonicalization in case of non-identity equals().

        For collections that do not support canonicalization, simply returns the argument if contained, null if none.

        Returns:
        a value equal to the argument if such a value is stored, or null if none
      • theContainedVersionOfUnsafe

        default T theContainedVersionOfUnsafe​(java.lang.Object value)
        Where supported, returns the stored element that is equal to the given value (of any type), or null if none. Useful for canonicalization in case of non-identity equals().

        For collections that do not support canonicalization, simply returns the argument if contained, null if none.

        Returns:
        a value equal to the argument if such a value is stored, or null if none
      • entriesWithMultiplicities

        default java.lang.Iterable<java.util.Map.Entry<T,​java.lang.Integer>> entriesWithMultiplicities()
        Returns:
        an unmodifiable view of contained values with their multiplicities
      • forEachEntryWithMultiplicities

        default void forEachEntryWithMultiplicities​(java.util.function.BiConsumer<T,​java.lang.Integer> entryConsumer)
        Process contained values with their multiplicities
      • asMap

        default java.util.Map<T,​java.lang.Integer> asMap()
        For compatibility with legacy code relying on element-to-integer maps.
        Returns:
        an unmodifiable view of contained values with their multiplicities
      • fromMap

        static <T> IMemoryView<T> fromMap​(java.util.Map<T,​java.lang.Integer> wrapped)
        For compatibility with legacy code relying on element-to-integer maps.
        Returns:
        an unmodifiable view of contained values with their multiplicities
      • asStream

        default java.util.stream.Stream<T> asStream()
        Returns:
        a stream of values, iterable once
        Since:
        2.1
      • equals

        static <T> boolean equals​(IMemoryView<T> self,
                                  java.lang.Object obj)
        Provides semantic equality comparison.
      • hashCode

        static <T> int hashCode​(IMemoryView<T> memory)
        Provides semantic hashCode() comparison.