code: @SuppressWarnings("WeakerAccess")
      public static int computeInitialLoadSize(@NonNull LoadInitialParams params,
              int initialLoadPosition, int totalCount) {
          return Math.min(totalCount - initialLoadPosition, params.requestedLoadSize);
      }
docs: Helper for computing an initial load size in
  {@link #loadInitial(LoadInitialParams, LoadInitialCallback)} when total data set size can be
  computed ahead of loading.
  <p>
  This function takes the requested load size, and bounds checks it against the value returned
  by {@link #computeInitialLoadPosition(LoadInitialParams, int)}.
  <p>
  Example usage in a PositionalDataSource subclass:
  <pre>
  class ItemDataSource extends PositionalDataSource&lt;Item> {
  private int computeCount() {
  // actual count code here
  }
  
  private List&lt;Item> loadRangeInternal(int startPosition, int loadCount) {
  // actual load code here
  }
  
  {@literal @}Override
  public void loadInitial({@literal @}NonNull LoadInitialParams params,
  {@literal @}NonNull LoadInitialCallback&lt;Item> callback) {
  int totalCount = computeCount();
  int position = computeInitialLoadPosition(params, totalCount);
  int loadSize = computeInitialLoadSize(params, position, totalCount);
  callback.onResult(loadRangeInternal(position, loadSize), position, totalCount);
  }
  
  {@literal @}Override
  public void loadRange({@literal @}NonNull LoadRangeParams params,
  {@literal @}NonNull LoadRangeCallback&lt;Item> callback) {
  callback.onResult(loadRangeInternal(params.startPosition, params.loadSize));
  }
  }</pre>
  
  @param params Params passed to {@link #loadInitial(LoadInitialParams, LoadInitialCallback)},
  including page size, and requested start/loadSize.
  @param initialLoadPosition Value returned by
  {@link #computeInitialLoadPosition(LoadInitialParams, int)}
  @param totalCount Total size of the data set.
  @return Number of items to load.
  
  @see #computeInitialLoadPosition(LoadInitialParams, int)