@@ -8596,7 +8596,7 @@ public final BlockingObservable<T> toBlocking() {
8596
8596
* you do not have the option to unsubscribe.
8597
8597
* <dl>
8598
8598
* <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>
8600
8600
* <dt><b>Scheduler:</b></dt>
8601
8601
* <dd>{@code toList} does not operate by default on a particular {@link Scheduler}.</dd>
8602
8602
* </dl>
@@ -8797,7 +8797,7 @@ public final <K, V> Observable<Map<K, Collection<V>>> toMultimap(Func1<? super T
8797
8797
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toSortedList.png" alt="">
8798
8798
* <dl>
8799
8799
* <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>
8801
8801
* <dt><b>Scheduler:</b></dt>
8802
8802
* <dd>{@code toSortedList} does not operate by default on a particular {@link Scheduler}.</dd>
8803
8803
* </dl>
@@ -8810,7 +8810,7 @@ public final <K, V> Observable<Map<K, Collection<V>>> toMultimap(Func1<? super T
8810
8810
* @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a>
8811
8811
*/
8812
8812
public final Observable <List <T >> toSortedList () {
8813
- return lift (new OperatorToObservableSortedList <T >());
8813
+ return lift (new OperatorToObservableSortedList <T >(10 ));
8814
8814
}
8815
8815
8816
8816
/**
@@ -8820,7 +8820,7 @@ public final Observable<List<T>> toSortedList() {
8820
8820
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toSortedList.f.png" alt="">
8821
8821
* <dl>
8822
8822
* <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>
8824
8824
* <dt><b>Scheduler:</b></dt>
8825
8825
* <dd>{@code toSortedList} does not operate by default on a particular {@link Scheduler}.</dd>
8826
8826
* </dl>
@@ -8833,7 +8833,60 @@ public final Observable<List<T>> toSortedList() {
8833
8833
* @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a>
8834
8834
*/
8835
8835
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 ));
8837
8890
}
8838
8891
8839
8892
/**
0 commit comments