Interface MemoizedSparseCollection<T>

  • Type Parameters:
    T - Type of memoized items
    All Known Implementing Classes:
    MemoizingIterator, SmilesMemoizingMoleculeIterator

    @Beta
    @PublicAPI
    public interface MemoizedSparseCollection<T>
    Represents an ordered sparse collection of memoized items. Typical usage is to retrieve structure sources captured during import.

    Note that the typical usage of term Memoization usually refers to an operation of storing the results of a potentially expensive calculation (see https://en.wikipedia.org/wiki/Memoization.

    • Method Detail

      • size

        int size()
        Collected items count. Including missing items.
        Returns:
        collected items count
      • getMemoizedIfPresent

        Optional<T> getMemoizedIfPresent​(int i)
        Get item when present.
        Parameters:
        i - Index which refers to either a missing or a present element
        Returns:
        Collected remembered element
      • getMemoizedOrDefault

        T getMemoizedOrDefault​(int i,
                               T defaultValue)
        Get item when present or a default value when missing.
        Parameters:
        i - Index which refers to either a missing or a present element
        defaultValue - value for return when missing
        Returns:
        Collected remembered element or default when missing
      • getMemoized

        T getMemoized​(int i)
               throws NoSuchElementException
        Get a non-missing memoiozed.
        Parameters:
        i - Index of an item which is not missing
        Returns:
        Collected remembered item
        Throws:
        NoSuchElementException - when given index refers to a missing item