support comma-separated multi-range input #852
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.
fixes: #835
This PR adds full support for using multiple port ranges in a single command, using a simple comma-separated format for range like:
Random Mode
All provided ranges are merged together, automatically handling overlaps and neighboring ranges so users don't have to worry about cleanup.
These merged ranges are then fed into an extended LCG-based iterator—building on the original design but now able to handle complex inputs.
Most importantly, the behavior you expect is preserved:
Serial Mode
Ranges are scanned in natural order, nice and straightforward.
A tiny BitSet takes care of any overlapping ranges so the output stays clean.
This avoids the heavier logic used in randomized mode, keeping the serial path fast and predictable.
Added detailed internal docs explaining:
Expanded the test suite to properly cover all multi-range behaviors.
I ended up removing the earlier Fenwick+BitSet prototype—it was interesting, but ultimately added complexity without giving meaningful performance wins. This new approach is about 80–120 µs slower in single range case form previous -range implementation, but in exchange it stays simple, readable, and true to the spirit of the original iterator while finally supporting multi-range inputs properly.
Happy to adjust anything — feedback, suggestions, or changes of any kind are always welcome.