Skip to content

Commit 7fdbcbf

Browse files
committed
Merge pull request ReactiveX#3033 from davidmoten/take-last-javadoc
takeLast() javadoc fixes, standardize parameter names (count instead of num)
2 parents f44b2be + 2d5ce69 commit 7fdbcbf

File tree

2 files changed

+31
-29
lines changed

2 files changed

+31
-29
lines changed

src/main/java/rx/Observable.java

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5143,28 +5143,28 @@ public final Observable<T> lastOrDefault(T defaultValue, Func1<? super T, Boolea
51435143
}
51445144

51455145
/**
5146-
* Returns an Observable that emits only the first {@code num} items emitted by the source Observable.
5146+
* Returns an Observable that emits only the first {@code count} items emitted by the source Observable.
51475147
* <p>
51485148
* Alias of {@link #take(int)} to match Java 8 Stream API naming convention.
51495149
* <p>
51505150
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/take.png" alt="">
51515151
* <p>
51525152
* This method returns an Observable that will invoke a subscribing {@link Observer}'s
5153-
* {@link Observer#onNext onNext} function a maximum of {@code num} times before invoking
5153+
* {@link Observer#onNext onNext} function a maximum of {@code count} times before invoking
51545154
* {@link Observer#onCompleted onCompleted}.
51555155
* <dl>
51565156
* <dt><b>Scheduler:</b></dt>
51575157
* <dd>{@code limit} does not operate by default on a particular {@link Scheduler}.</dd>
51585158
* </dl>
51595159
*
5160-
* @param num
5160+
* @param count
51615161
* the maximum number of items to emit
5162-
* @return an Observable that emits only the first {@code num} items emitted by the source Observable, or
5163-
* all of the items from the source Observable if that Observable emits fewer than {@code num} items
5162+
* @return an Observable that emits only the first {@code count} items emitted by the source Observable, or
5163+
* all of the items from the source Observable if that Observable emits fewer than {@code count} items
51645164
* @see <a href="http://reactivex.io/documentation/operators/take.html">ReactiveX operators documentation: Take</a>
51655165
*/
5166-
public final Observable<T> limit(int num) {
5167-
return take(num);
5166+
public final Observable<T> limit(int count) {
5167+
return take(count);
51685168
}
51695169

51705170
/**
@@ -6896,7 +6896,7 @@ public final Observable<T> singleOrDefault(T defaultValue, Func1<? super T, Bool
68966896
}
68976897

68986898
/**
6899-
* Returns an Observable that skips the first {@code num} items emitted by the source Observable and emits
6899+
* Returns an Observable that skips the first {@code count} items emitted by the source Observable and emits
69006900
* the remainder.
69016901
* <p>
69026902
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/skip.png" alt="">
@@ -6905,14 +6905,14 @@ public final Observable<T> singleOrDefault(T defaultValue, Func1<? super T, Bool
69056905
* <dd>This version of {@code skip} does not operate by default on a particular {@link Scheduler}.</dd>
69066906
* </dl>
69076907
*
6908-
* @param num
6908+
* @param count
69096909
* the number of items to skip
69106910
* @return an Observable that is identical to the source Observable except that it does not emit the first
6911-
* {@code num} items that the source Observable emits
6911+
* {@code count} items that the source Observable emits
69126912
* @see <a href="http://reactivex.io/documentation/operators/skip.html">ReactiveX operators documentation: Skip</a>
69136913
*/
6914-
public final Observable<T> skip(int num) {
6915-
return lift(new OperatorSkip<T>(num));
6914+
public final Observable<T> skip(int count) {
6915+
return lift(new OperatorSkip<T>(count));
69166916
}
69176917

69186918
/**
@@ -7768,26 +7768,27 @@ public final <R> Observable<R> switchMap(Func1<? super T, ? extends Observable<?
77687768
}
77697769

77707770
/**
7771-
* Returns an Observable that emits only the first {@code num} items emitted by the source Observable.
7771+
* Returns an Observable that emits only the first {@code count} items emitted by the source Observable. If the source emits fewer than
7772+
* {@code count} items then all of its items are emitted.
77727773
* <p>
77737774
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/take.png" alt="">
77747775
* <p>
77757776
* This method returns an Observable that will invoke a subscribing {@link Observer}'s
7776-
* {@link Observer#onNext onNext} function a maximum of {@code num} times before invoking
7777+
* {@link Observer#onNext onNext} function a maximum of {@code count} times before invoking
77777778
* {@link Observer#onCompleted onCompleted}.
77787779
* <dl>
77797780
* <dt><b>Scheduler:</b></dt>
77807781
* <dd>This version of {@code take} does not operate by default on a particular {@link Scheduler}.</dd>
77817782
* </dl>
77827783
*
7783-
* @param num
7784+
* @param count
77847785
* the maximum number of items to emit
7785-
* @return an Observable that emits only the first {@code num} items emitted by the source Observable, or
7786-
* all of the items from the source Observable if that Observable emits fewer than {@code num} items
7786+
* @return an Observable that emits only the first {@code count} items emitted by the source Observable, or
7787+
* all of the items from the source Observable if that Observable emits fewer than {@code count} items
77877788
* @see <a href="http://reactivex.io/documentation/operators/take.html">ReactiveX operators documentation: Take</a>
77887789
*/
7789-
public final Observable<T> take(final int num) {
7790-
return lift(new OperatorTake<T>(num));
7790+
public final Observable<T> take(final int count) {
7791+
return lift(new OperatorTake<T>(count));
77917792
}
77927793

77937794
/**
@@ -7857,7 +7858,8 @@ public final Observable<T> takeFirst(Func1<? super T, Boolean> predicate) {
78577858
}
78587859

78597860
/**
7860-
* Returns an Observable that emits only the last {@code count} items emitted by the source Observable.
7861+
* Returns an Observable that emits at most the last {@code count} items emitted by the source Observable. If the source emits fewer than
7862+
* {@code count} items then all of its items are emitted.
78617863
* <p>
78627864
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/takeLast.n.png" alt="">
78637865
* <dl>
@@ -7866,9 +7868,9 @@ public final Observable<T> takeFirst(Func1<? super T, Boolean> predicate) {
78667868
* </dl>
78677869
*
78687870
* @param count
7869-
* the number of items to emit from the end of the sequence of items emitted by the source
7871+
* the maximum number of items to emit from the end of the sequence of items emitted by the source
78707872
* Observable
7871-
* @return an Observable that emits only the last {@code count} items emitted by the source Observable
7873+
* @return an Observable that emits at most the last {@code count} items emitted by the source Observable
78727874
* @throws IndexOutOfBoundsException
78737875
* if {@code count} is less than zero
78747876
* @see <a href="http://reactivex.io/documentation/operators/takelast.html">ReactiveX operators documentation: TakeLast</a>
@@ -7884,7 +7886,7 @@ else if (count == 1 )
78847886

78857887
/**
78867888
* Returns an Observable that emits at most a specified number of items from the source Observable that were
7887-
* emitted in a specified window of time before the Observable completed.
7889+
* emitted in a specified window of time before the Observable completed.
78887890
* <p>
78897891
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/takeLast.tn.png" alt="">
78907892
* <dl>
@@ -7985,8 +7987,8 @@ public final Observable<T> takeLast(long time, TimeUnit unit, Scheduler schedule
79857987
}
79867988

79877989
/**
7988-
* Returns an Observable that emits a single List containing the last {@code count} elements emitted by the
7989-
* source Observable.
7990+
* Returns an Observable that emits a single List containing at most the last {@code count} elements emitted by the
7991+
* source Observable. If the source emits fewer than {@code count} items then the emitted List will contain all of the source emissions.
79907992
* <p>
79917993
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/takeLastBuffer.png" alt="">
79927994
* <dl>
@@ -7995,8 +7997,8 @@ public final Observable<T> takeLast(long time, TimeUnit unit, Scheduler schedule
79957997
* </dl>
79967998
*
79977999
* @param count
7998-
* the number of items to emit in the list
7999-
* @return an Observable that emits a single list containing the last {@code count} elements emitted by the
8000+
* the maximum number of items to emit in the list
8001+
* @return an Observable that emits a single list containing at most the last {@code count} elements emitted by the
80008002
* source Observable
80018003
* @see <a href="http://reactivex.io/documentation/operators/takelast.html">ReactiveX operators documentation: TakeLast</a>
80028004
*/

src/main/java/rx/internal/operators/OperatorTakeLast.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import rx.Subscriber;
2323

2424
/**
25-
* Returns an Observable that emits the last <code>count</code> items emitted by the source Observable.
25+
* Returns an Observable that emits the at most the last <code>count</code> items emitted by the source Observable.
2626
* <p>
2727
* <img width="640" src="https://github.com/ReactiveX/RxJava/wiki/images/rx-operators/last.png" alt="">
2828
*/
@@ -32,7 +32,7 @@ public final class OperatorTakeLast<T> implements Operator<T, T> {
3232

3333
public OperatorTakeLast(int count) {
3434
if (count < 0) {
35-
throw new IndexOutOfBoundsException("count could not be negative");
35+
throw new IndexOutOfBoundsException("count cannot be negative");
3636
}
3737
this.count = count;
3838
}

0 commit comments

Comments
 (0)