Skip to content

takeLast() javadoc fixes, standardize parameter names (count instead of num) #3033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 29 additions & 27 deletions src/main/java/rx/Observable.java
Original file line number Diff line number Diff line change
Expand Up @@ -5141,28 +5141,28 @@ public final Observable<T> lastOrDefault(T defaultValue, Func1<? super T, Boolea
}

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

/**
Expand Down Expand Up @@ -6894,7 +6894,7 @@ public final Observable<T> singleOrDefault(T defaultValue, Func1<? super T, Bool
}

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

/**
Expand Down Expand Up @@ -7766,26 +7766,27 @@ public final <R> Observable<R> switchMap(Func1<? super T, ? extends Observable<?
}

/**
* Returns an Observable that emits only the first {@code num} items emitted by the source Observable.
* Returns an Observable that emits only the first {@code count} items emitted by the source Observable. If the source emits fewer than
* {@code count} items then all of its items are emitted.
* <p>
* <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/take.png" alt="">
* <p>
* This method returns an Observable that will invoke a subscribing {@link Observer}'s
* {@link Observer#onNext onNext} function a maximum of {@code num} times before invoking
* {@link Observer#onNext onNext} function a maximum of {@code count} times before invoking
* {@link Observer#onCompleted onCompleted}.
* <dl>
* <dt><b>Scheduler:</b></dt>
* <dd>This version of {@code take} does not operate by default on a particular {@link Scheduler}.</dd>
* </dl>
*
* @param num
* @param count
* the maximum number of items to emit
* @return an Observable that emits only the first {@code num} items emitted by the source Observable, or
* all of the items from the source Observable if that Observable emits fewer than {@code num} items
* @return an Observable that emits only the first {@code count} items emitted by the source Observable, or
* all of the items from the source Observable if that Observable emits fewer than {@code count} items
* @see <a href="http://reactivex.io/documentation/operators/take.html">ReactiveX operators documentation: Take</a>
*/
public final Observable<T> take(final int num) {
return lift(new OperatorTake<T>(num));
public final Observable<T> take(final int count) {
return lift(new OperatorTake<T>(count));
}

/**
Expand Down Expand Up @@ -7855,7 +7856,8 @@ public final Observable<T> takeFirst(Func1<? super T, Boolean> predicate) {
}

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

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

/**
* Returns an Observable that emits a single List containing the last {@code count} elements emitted by the
* source Observable.
* Returns an Observable that emits a single List containing at most the last {@code count} elements emitted by the
* source Observable. If the source emits fewer than {@code count} items then the emitted List will contain all of the source emissions.
* <p>
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/takeLastBuffer.png" alt="">
* <dl>
Expand All @@ -7993,8 +7995,8 @@ public final Observable<T> takeLast(long time, TimeUnit unit, Scheduler schedule
* </dl>
*
* @param count
* the number of items to emit in the list
* @return an Observable that emits a single list containing the last {@code count} elements emitted by the
* the maximum number of items to emit in the list
* @return an Observable that emits a single list containing at most the last {@code count} elements emitted by the
* source Observable
* @see <a href="http://reactivex.io/documentation/operators/takelast.html">ReactiveX operators documentation: TakeLast</a>
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/rx/internal/operators/OperatorTakeLast.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import rx.Subscriber;

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

public OperatorTakeLast(int count) {
if (count < 0) {
throw new IndexOutOfBoundsException("count could not be negative");
throw new IndexOutOfBoundsException("count cannot be negative");
}
this.count = count;
}
Expand Down