Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
zihuaweng wants to merge4 commits intorealm:main
base:main
Choose a base branch
Loading
fromsolution-accepted:issue-1050-fix

Conversation

@zihuaweng
Copy link

Fixes#1050

joxon reacted with thumbs up emoji
Copy link
Collaborator

@nhachichanhachicha left a 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);
Copy link
Collaborator

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());
Copy link
Collaborator

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

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nhachichanhachichanhachicha requested changes

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

New feature: findLast(int), findFirst(int), findRandom(int)

3 participants

@zihuaweng@nhachicha@bmunkholm

[8]ページ先頭

©2009-2025 Movatter.jp