@@ -8596,7 +8596,7 @@ public final BlockingObservable<T> toBlocking() {
85968596 * you do not have the option to unsubscribe.
85978597 * <dl>
85988598 * <dt><b>Backpressure Support:</b></dt>
8599- * <dd>This operator does not support backpressure as by intent it is requesting and buffering everything .</dd>
8599+ * <dd>The operator buffers everything from its upstream but it only emits the aggregated list when the downstream requests at least one item .</dd>
86008600 * <dt><b>Scheduler:</b></dt>
86018601 * <dd>{@code toList} does not operate by default on a particular {@link Scheduler}.</dd>
86028602 * </dl>
@@ -8797,7 +8797,7 @@ public final <K, V> Observable<Map<K, Collection<V>>> toMultimap(Func1<? super T
87978797 * <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toSortedList.png" alt="">
87988798 * <dl>
87998799 * <dt><b>Backpressure Support:</b></dt>
8800- * <dd>This operator does not support backpressure as by intent it is requesting and buffering everything .</dd>
8800+ * <dd>The operator buffers everything from its upstream but it only emits the sorted list when the downstream requests at least one item .</dd>
88018801 * <dt><b>Scheduler:</b></dt>
88028802 * <dd>{@code toSortedList} does not operate by default on a particular {@link Scheduler}.</dd>
88038803 * </dl>
@@ -8810,7 +8810,7 @@ public final <K, V> Observable<Map<K, Collection<V>>> toMultimap(Func1<? super T
88108810 * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a>
88118811 */
88128812 public final Observable <List <T >> toSortedList () {
8813- return lift (new OperatorToObservableSortedList <T >());
8813+ return lift (new OperatorToObservableSortedList <T >(10 ));
88148814 }
88158815
88168816 /**
@@ -8820,7 +8820,7 @@ public final Observable<List<T>> toSortedList() {
88208820 * <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toSortedList.f.png" alt="">
88218821 * <dl>
88228822 * <dt><b>Backpressure Support:</b></dt>
8823- * <dd>This operator does not support backpressure as by intent it is requesting and buffering everything .</dd>
8823+ * <dd>The operator buffers everything from its upstream but it only emits the sorted list when the downstream requests at least one item .</dd>
88248824 * <dt><b>Scheduler:</b></dt>
88258825 * <dd>{@code toSortedList} does not operate by default on a particular {@link Scheduler}.</dd>
88268826 * </dl>
@@ -8833,7 +8833,60 @@ public final Observable<List<T>> toSortedList() {
88338833 * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a>
88348834 */
88358835 public final Observable <List <T >> toSortedList (Func2 <? super T , ? super T , Integer > sortFunction ) {
8836- return lift (new OperatorToObservableSortedList <T >(sortFunction ));
8836+ return lift (new OperatorToObservableSortedList <T >(sortFunction , 10 ));
8837+ }
8838+
8839+ /**
8840+ * Returns an Observable that emits a list that contains the items emitted by the source Observable, in a
8841+ * sorted order. Each item emitted by the Observable must implement {@link Comparable} with respect to all
8842+ * other items in the sequence.
8843+ * <p>
8844+ * <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toSortedList.png" alt="">
8845+ * <dl>
8846+ * <dt><b>Backpressure Support:</b></dt>
8847+ * <dd>The operator buffers everything from its upstream but it only emits the sorted list when the downstream requests at least one item.</dd>
8848+ * <dt><b>Scheduler:</b></dt>
8849+ * <dd>{@code toSortedList} does not operate by default on a particular {@link Scheduler}.</dd>
8850+ * </dl>
8851+ *
8852+ * @throws ClassCastException
8853+ * if any item emitted by the Observable does not implement {@link Comparable} with respect to
8854+ * all other items emitted by the Observable
8855+ * @param initialCapacity
8856+ * the initial capacity of the ArrayList used to accumulate items before sorting
8857+ * @return an Observable that emits a list that contains the items emitted by the source Observable in
8858+ * sorted order
8859+ * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a>
8860+ */
8861+ @ Experimental
8862+ public final Observable <List <T >> toSortedList (int initialCapacity ) {
8863+ return lift (new OperatorToObservableSortedList <T >(initialCapacity ));
8864+ }
8865+
8866+ /**
8867+ * Returns an Observable that emits a list that contains the items emitted by the source Observable, in a
8868+ * sorted order based on a specified comparison function.
8869+ * <p>
8870+ * <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toSortedList.f.png" alt="">
8871+ * <dl>
8872+ * <dt><b>Backpressure Support:</b></dt>
8873+ * <dd>The operator buffers everything from its upstream but it only emits the sorted list when the downstream requests at least one item.</dd>
8874+ * <dt><b>Scheduler:</b></dt>
8875+ * <dd>{@code toSortedList} does not operate by default on a particular {@link Scheduler}.</dd>
8876+ * </dl>
8877+ *
8878+ * @param sortFunction
8879+ * a function that compares two items emitted by the source Observable and returns an Integer
8880+ * that indicates their sort order
8881+ * @param initialCapacity
8882+ * the initial capacity of the ArrayList used to accumulate items before sorting
8883+ * @return an Observable that emits a list that contains the items emitted by the source Observable in
8884+ * sorted order
8885+ * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a>
8886+ */
8887+ @ Experimental
8888+ public final Observable <List <T >> toSortedList (Func2 <? super T , ? super T , Integer > sortFunction , int initialCapacity ) {
8889+ return lift (new OperatorToObservableSortedList <T >(sortFunction , initialCapacity ));
88378890 }
88388891
88398892 /**
0 commit comments