Skip to content
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

Introduce an IndexedHashMap, which has constant time lookup and stable iteration order. #864

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Jan 11, 2023

Introduce an IndexedHashMap, which has constant time lookup and stable iteration order.

This change introduces an IndexedHashMap, which has O(1) lookup but stable iteration order. Under the hood, this is just a combination of a absl::flat_hash_map from key to index and a std::vector containing the values. This can't really use a standard C++ interface due to the key and the value not being co-located, but we can provide a sensible alternative map interface for it.

…ble iteration order.

This change introduces an `IndexedHashMap`, which has O(1) lookup but stable iteration order. Under the hood, this is just a combination of a `absl::flat_hash_map` from key to index and a `std::vector` containing the values. This can't really use a standard C++ interface due to the key and the value not being co-located, but we can provide a sensible alternative map interface for it.

PiperOrigin-RevId: 501124236
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants