@@ -8578,7 +8578,7 @@ public final BlockingObservable<T> toBlocking() {
8578
8578
* you do not have the option to unsubscribe.
8579
8579
* <dl>
8580
8580
* <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>
8582
8582
* <dt><b>Scheduler:</b></dt>
8583
8583
* <dd>{@code toList} does not operate by default on a particular {@link Scheduler}.</dd>
8584
8584
* </dl>
@@ -8779,7 +8779,7 @@ public final <K, V> Observable<Map<K, Collection<V>>> toMultimap(Func1<? super T
8779
8779
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toSortedList.png" alt="">
8780
8780
* <dl>
8781
8781
* <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>
8783
8783
* <dt><b>Scheduler:</b></dt>
8784
8784
* <dd>{@code toSortedList} does not operate by default on a particular {@link Scheduler}.</dd>
8785
8785
* </dl>
@@ -8792,7 +8792,7 @@ public final <K, V> Observable<Map<K, Collection<V>>> toMultimap(Func1<? super T
8792
8792
* @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a>
8793
8793
*/
8794
8794
public final Observable <List <T >> toSortedList () {
8795
- return lift (new OperatorToObservableSortedList <T >());
8795
+ return lift (new OperatorToObservableSortedList <T >(10 ));
8796
8796
}
8797
8797
8798
8798
/**
@@ -8802,7 +8802,7 @@ public final Observable<List<T>> toSortedList() {
8802
8802
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toSortedList.f.png" alt="">
8803
8803
* <dl>
8804
8804
* <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>
8806
8806
* <dt><b>Scheduler:</b></dt>
8807
8807
* <dd>{@code toSortedList} does not operate by default on a particular {@link Scheduler}.</dd>
8808
8808
* </dl>
@@ -8815,7 +8815,60 @@ public final Observable<List<T>> toSortedList() {
8815
8815
* @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a>
8816
8816
*/
8817
8817
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 ));
8819
8872
}
8820
8873
8821
8874
/**
0 commit comments