-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Reimplement the 'SequenceEqual' operator #575
Conversation
RxJava-pull-requests #512 SUCCESS |
Okay; I think I've got it corrected. It only covers one condition, so might On Fri, Dec 6, 2013 at 7:13 AM, CloudBees pull request builder plugin <
David M. Gross |
@DavidMGross Looks cool. Thanks. |
RxJava-pull-requests #514 SUCCESS |
Good job, just a few things.
|
I really think that def sequenceEqual[T](o1: Observable[T], o2: Observable[T]): Observable[Boolean] = {
val obs1: Observable[Option[T]] = o1.map(Some(_)) ++ Observable(None) // ++ is concat
val obs2: Observable[Option[T]] = o2.map(Some(_)) ++ Observable(None)
// If different length, comparing the `None` of the shorter with `Some(element)`
// of the longer will return false.
(obs1 zip obs2).forall(pair => pair._1 == pair._2)
} |
@samuelgruetter , great idea. Really thanks. I overrode the previous commit. As their is no Option in Java, I use Notification instead. |
RxJava-pull-requests #515 SUCCESS |
I also have a question about /**
* Retrieves a value indicating whether this notification has a value.
*
* @return a value indicating whether this notification has a value.
*/
public boolean hasValue() {
return isOnNext() && value != null;
} Here it checks if value is not null. But I think value can be null. I also checked the Rx.Net codes here: http://rx.codeplex.com/SourceControl/latest#Rx.NET/Source/System.Reactive.Core/Reactive/Notification.cs /// <summary>
/// Returns true.
/// </summary>
public override bool HasValue { get { return true; } } It returns true directly in If |
RxJava-pull-requests #516 SUCCESS |
Much nicer now ;-) Regarding hasValue: I don't know. What is it good for if it's the same as isOnNext? And why would one need the current version? Imho it could just be removed. Something else regarding null values and sequenceEqual with default equality: I think you shouldn't call onError(NullPointerException), but just onNext(true) or onNext(false). |
@samuelgruetter Thanks for reminding me the null issue. |
RxJava-pull-requests #517 SUCCESS |
Reimplement the 'SequenceEqual' operator
Reimplement the 'SequenceEqual' operator
Hi, this PR reimplemented the
SequenceEqual
operator #76 and should fix the issue #564.The wiki page https://github.com/Netflix/RxJava/wiki/Observable-Utility-Operators#sequenceequal still needs to be updated. @DavidMGross could you help update the marble diagram of
SequenceEqual
? Thanks!