modify collect_ranges to take param on whether to join ranges

This commit is contained in:
llama 2025-05-17 01:41:04 +08:00
parent d3d6bd8ce0
commit b9eeb891df
No known key found for this signature in database
GPG key ID: 0B7543854B9413C3

View file

@ -899,7 +899,7 @@ impl RequiredTable {
/// contiguous numbers.
trait CollectRanges {
type Item;
fn collect_ranges(self) -> Vec<Range<Self::Item>>;
fn collect_ranges(self, join: bool) -> Vec<Range<Self::Item>>;
}
impl<
@ -909,7 +909,7 @@ impl<
{
type Item = Idx;
fn collect_ranges(self) -> Vec<Range<Self::Item>> {
fn collect_ranges(self, join: bool) -> Vec<Range<Self::Item>> {
let mut result = Vec::new();
let mut iter = self.into_iter();
let next = iter.next();
@ -920,7 +920,7 @@ impl<
let mut end = next.unwrap();
for i in iter {
if i == end + 1.into() {
if join && i == end + 1.into() {
end = end + 1.into();
} else {
result.push(start..end + 1.into());