Skip to content

Added efficient iterators to magic_enum::containers::bitset#450

Open
KenanMillet wants to merge 3 commits intoNeargye:masterfrom
KenanMillet:master
Open

Added efficient iterators to magic_enum::containers::bitset#450
KenanMillet wants to merge 3 commits intoNeargye:masterfrom
KenanMillet:master

Conversation

@KenanMillet
Copy link
Copy Markdown

This change introduces iterators to magic_enum::containers::bitset.
The iterators utilize std::countr_zero (or compiler-based equivalents if below c++20) to efficiently determine what the next set bit is in the bitset, allowing you to iterate over all set Enum values within a bitset much faster than:

  • a magic_enum::containers::set (especially as the number of enums added to the bitset/set increases)
  • and much faster than checking each bit in the bitset individually (especially as the size of the bitset increases)

The change comes with an example, but I did not see anywhere to put benchmark tests, so I left those out.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant