- Notifications
You must be signed in to change notification settings - Fork1.8k
Add findFirst(int), findLast(int) and findRandom(int)#6778
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
nhachicha left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Hi@zihuaweng Thanks for your contribution, as mentioned in the comments above there are issues with your implementation (at least forfindLast_limit andfindRandom_limit),findFirst(limit) could be added best as an extension method for example.
| } | ||
| RealmResults<E>results =findAll(); | ||
| Collections.shuffle(results); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
shuffle is not supported by 'RealmResults' or 'OrderedRealmCollectionSnapshot', this will throw aUnsupportedOperationException at runtime.
| } | ||
| RealmResults<E>results =findAll(); | ||
| results =results.subList(Math.max(results.size() -limit,0),results.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
java.util.SubList cannot be cast toio.realm.RealmResults, this will throwClassCastException at runtime
Fixes#1050