@@ -8578,7 +8578,7 @@ public final BlockingObservable<T> toBlocking() {
85788578 * you do not have the option to unsubscribe.
85798579 * <dl>
85808580 * <dt><b>Backpressure Support:</b></dt>
8581- * <dd>This operator does not support backpressure as by intent it is requesting and buffering everything .</dd>
8581+ * <dd>The operator buffers everything from its upstream but it only emits the aggregated list when the downstream requests at least one item .</dd>
85828582 * <dt><b>Scheduler:</b></dt>
85838583 * <dd>{@code toList} does not operate by default on a particular {@link Scheduler}.</dd>
85848584 * </dl>
@@ -8779,7 +8779,7 @@ public final <K, V> Observable<Map<K, Collection<V>>> toMultimap(Func1<? super T
87798779 * <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toSortedList.png" alt="">
87808780 * <dl>
87818781 * <dt><b>Backpressure Support:</b></dt>
8782- * <dd>This operator does not support backpressure as by intent it is requesting and buffering everything .</dd>
8782+ * <dd>The operator buffers everything from its upstream but it only emits the sorted list when the downstream requests at least one item .</dd>
87838783 * <dt><b>Scheduler:</b></dt>
87848784 * <dd>{@code toSortedList} does not operate by default on a particular {@link Scheduler}.</dd>
87858785 * </dl>
@@ -8792,7 +8792,7 @@ public final <K, V> Observable<Map<K, Collection<V>>> toMultimap(Func1<? super T
87928792 * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a>
87938793 */
87948794 public final Observable <List <T >> toSortedList () {
8795- return lift (new OperatorToObservableSortedList <T >());
8795+ return lift (new OperatorToObservableSortedList <T >(10 ));
87968796 }
87978797
87988798 /**
@@ -8802,7 +8802,7 @@ public final Observable<List<T>> toSortedList() {
88028802 * <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toSortedList.f.png" alt="">
88038803 * <dl>
88048804 * <dt><b>Backpressure Support:</b></dt>
8805- * <dd>This operator does not support backpressure as by intent it is requesting and buffering everything .</dd>
8805+ * <dd>The operator buffers everything from its upstream but it only emits the sorted list when the downstream requests at least one item .</dd>
88068806 * <dt><b>Scheduler:</b></dt>
88078807 * <dd>{@code toSortedList} does not operate by default on a particular {@link Scheduler}.</dd>
88088808 * </dl>
@@ -8815,7 +8815,60 @@ public final Observable<List<T>> toSortedList() {
88158815 * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a>
88168816 */
88178817 public final Observable <List <T >> toSortedList (Func2 <? super T , ? super T , Integer > sortFunction ) {
8818- return lift (new OperatorToObservableSortedList <T >(sortFunction ));
8818+ return lift (new OperatorToObservableSortedList <T >(sortFunction , 10 ));
8819+ }
8820+
8821+ /**
8822+ * Returns an Observable that emits a list that contains the items emitted by the source Observable, in a
8823+ * sorted order. Each item emitted by the Observable must implement {@link Comparable} with respect to all
8824+ * other items in the sequence.
8825+ * <p>
8826+ * <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toSortedList.png" alt="">
8827+ * <dl>
8828+ * <dt><b>Backpressure Support:</b></dt>
8829+ * <dd>The operator buffers everything from its upstream but it only emits the sorted list when the downstream requests at least one item.</dd>
8830+ * <dt><b>Scheduler:</b></dt>
8831+ * <dd>{@code toSortedList} does not operate by default on a particular {@link Scheduler}.</dd>
8832+ * </dl>
8833+ *
8834+ * @throws ClassCastException
8835+ * if any item emitted by the Observable does not implement {@link Comparable} with respect to
8836+ * all other items emitted by the Observable
8837+ * @param initialCapacity
8838+ * the initial capacity of the ArrayList used to accumulate items before sorting
8839+ * @return an Observable that emits a list that contains the items emitted by the source Observable in
8840+ * sorted order
8841+ * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a>
8842+ */
8843+ @ Experimental
8844+ public final Observable <List <T >> toSortedList (int initialCapacity ) {
8845+ return lift (new OperatorToObservableSortedList <T >(initialCapacity ));
8846+ }
8847+
8848+ /**
8849+ * Returns an Observable that emits a list that contains the items emitted by the source Observable, in a
8850+ * sorted order based on a specified comparison function.
8851+ * <p>
8852+ * <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toSortedList.f.png" alt="">
8853+ * <dl>
8854+ * <dt><b>Backpressure Support:</b></dt>
8855+ * <dd>The operator buffers everything from its upstream but it only emits the sorted list when the downstream requests at least one item.</dd>
8856+ * <dt><b>Scheduler:</b></dt>
8857+ * <dd>{@code toSortedList} does not operate by default on a particular {@link Scheduler}.</dd>
8858+ * </dl>
8859+ *
8860+ * @param sortFunction
8861+ * a function that compares two items emitted by the source Observable and returns an Integer
8862+ * that indicates their sort order
8863+ * @param initialCapacity
8864+ * the initial capacity of the ArrayList used to accumulate items before sorting
8865+ * @return an Observable that emits a list that contains the items emitted by the source Observable in
8866+ * sorted order
8867+ * @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a>
8868+ */
8869+ @ Experimental
8870+ public final Observable <List <T >> toSortedList (Func2 <? super T , ? super T , Integer > sortFunction , int initialCapacity ) {
8871+ return lift (new OperatorToObservableSortedList <T >(sortFunction , initialCapacity ));
88198872 }
88208873
88218874 /**
0 commit comments