Class WindowQueryList<T>

    • Constructor Detail

      • WindowQueryList

        public WindowQueryList​(List<? extends T> list,
                               int offset,
                               int count)
        Constructor when the original list is given with window bounds.
        Parameters:
        list - original list from which to cache elements
        offset - index in the list of the first element in the window
        count - number of elements in the window
        Throws:
        IllegalArgumentException - if list is null
        IllegalArgumentException - if offset and/or count are invalid
      • WindowQueryList

        public WindowQueryList​(long offset,
                               List<? extends T> window,
                               long totalSize)
        Constructor when a "window" list is given with its position in the original list.
        Parameters:
        window - list of only those elements in the "window"
        offset - offset of the "window" in the original list
        totalSize - total size of the original list
        Throws:
        IllegalArgumentException - if window is null
        IllegalArgumentException - if offset < 0
        IllegalArgumentException - if offset + window.size() > totalSize
    • Method Detail

      • size

        public long size()
        Description copied from interface: QueryList
        Get the total size of this list.

        For any given QueryList instance, this method is expected to return a the same value if invoked multiple times. Therefore, callers may safely choose to invoke it only once on a given instance and cache the result.

        Specified by:
        size in interface QueryList<T>
        Returns:
        total size of list
      • get

        public T get​(long index)
              throws InvalidQueryListException
        Description copied from interface: QueryList
        Get an item in the list, or throw an exception if this instance is no longer valid or cannot provide the item.
        Specified by:
        get in interface QueryList<T>
        Parameters:
        index - index of the item (zero-based)
        Returns:
        the list item at index
        Throws:
        InvalidQueryListException - if this list has become invalid or cannot provide the item