Add findFirst(int), findLast(int) and findRandom(int)#6778
Open
zihuaweng wants to merge 4 commits intorealm:mainfrom
Open
Add findFirst(int), findLast(int) and findRandom(int)#6778zihuaweng wants to merge 4 commits intorealm:mainfrom
zihuaweng wants to merge 4 commits intorealm:mainfrom
Conversation
nhachicha
requested changes
Apr 28, 2020
Collaborator
nhachicha
left a comment
There was a problem hiding this comment.
Hi @zihuaweng Thanks for your contribution, as mentioned in the comments above there are issues with your implementation (at least for findLast_limit and findRandom_limit), findFirst(limit) could be added best as an extension method for example.
| } | ||
|
|
||
| RealmResults<E> results = findAll(); | ||
| Collections.shuffle(results); |
Collaborator
There was a problem hiding this comment.
shuffle is not supported by 'RealmResults' or 'OrderedRealmCollectionSnapshot', this will throw a UnsupportedOperationException at runtime.
| } | ||
|
|
||
| RealmResults<E> results = findAll(); | ||
| results = results.subList(Math.max(results.size() - limit, 0), results.size()); |
Collaborator
There was a problem hiding this comment.
java.util.SubList cannot be cast to io.realm.RealmResults, this will throw ClassCastException at runtime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1050