Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/godzilla/IndexSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ class IndexSet : public PetscObjectWrapper<IS> {
/// Checks if the IndexSet is empty (i.e., has no indices)
///
/// @return `true` if the index set is empty, `false` otherwise
bool empty() const;
[[deprecated]] bool empty() const;
bool is_empty() const;

/// Shift all indices by given offset
///
Expand Down
8 changes: 8 additions & 0 deletions src/IndexSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ IndexSet::empty() const
return get_size() == 0;
}

bool
IndexSet::is_empty() const
{
CALL_STACK_MSG();
GODZILLA_ASSERT_TRUE(this->obj != nullptr, "IndexSet is null");
return get_size() == 0;
}

void
IndexSet::shift(Int offset)
{
Expand Down
10 changes: 10 additions & 0 deletions test/src/IndexSet_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,16 @@ TEST(IndexSetTest, oper_bool)
EXPECT_TRUE(cis1);
}

TEST(IndexSetTest, is_empty)
{
TestApp app;
if (app.get_comm().size() != 1)
return;

auto is = IndexSet::create_general(app.get_comm(), {});
EXPECT_TRUE(is.is_empty());
}

TEST(IndexSetTest, range)
{
TestApp app;
Expand Down
Loading