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

Simplify IndexSet::add_index() #15536

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 3 additions & 14 deletions include/deal.II/base/index_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -1686,16 +1686,7 @@ IndexSet::compress() const
inline void
IndexSet::add_index(const size_type index)
{
AssertIndexRange(index, index_space_size);

const Range new_range(index, index + 1);
if (ranges.size() == 0 || index > ranges.back().end)
ranges.push_back(new_range);
else if (index == ranges.back().end)
ranges.back().end++;
else
add_range_lower_bound(new_range);
is_compressed = false;
add_range(index, index + 1);
}


Expand All @@ -1712,16 +1703,14 @@ IndexSet::add_range(const size_type begin, const size_type end)

if (begin != end)
{
const Range new_range(begin, end);

// the new index might be larger than the last index present in the
// ranges. Then we can skip the binary search
if (ranges.size() == 0 || begin > ranges.back().end)
ranges.push_back(new_range);
ranges.emplace_back(begin, end);
else if (begin == ranges.back().end)
ranges.back().end = end;
else
add_range_lower_bound(new_range);
add_range_lower_bound(Range(begin, end));

is_compressed = false;
}
Expand Down