feat: add lookup_index_by_key to Rust Vector for index-based search#8959
Open
statxc wants to merge 3 commits intogoogle:masterfrom
Open
feat: add lookup_index_by_key to Rust Vector for index-based search#8959statxc wants to merge 3 commits intogoogle:masterfrom
statxc wants to merge 3 commits intogoogle:masterfrom
Conversation
Author
|
@jtdavis777 I'd appreciate you also review this PR. |
jtdavis777
reviewed
Mar 7, 2026
…ust/add-lookup-index-by-key
Author
|
Thanks for your feedback @jtdavis777 . I removed duplicated codes. Please review again |
Author
|
@jtdavis777 Any update for me, please |
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.
Closes: #8667
Problem
lookup_by_keyperforms binary search on sorted vectors but can only return the matched object. There is no way to get the element's index, which is needed when using vector positions as references (e.g., graph adjacency lists, ECS entity lookups, index-based cross-referencing between vectors).Fix
Add
lookup_index_by_keytoVector- identical binary search logic aslookup_by_key, but returnsOption<usize>(the index) instead ofOption<T::Inner>(the object).Changes
rust/flatbuffers/src/vector.rs- addlookup_index_by_keymethod onVector<'a, T>tests/rust_usage_test/tests/integration_test.rs- add 5 test cases for the new methodTest plan