Skip to content

Commit

Permalink
maybe size() too
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Aug 19, 2023
1 parent 04c6438 commit 512c6bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gnucash/gnome-utils/gnc-tree-container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ class GncTreeContainer
return TreeModelIterator(m_model, iter);
};

size_t size()
{
int i = 0;
for (auto n = begin(); n.has_value(); ++n)
i++;
return i;
};

bool empty() { return begin() == end(); };

private:
Expand Down
1 change: 1 addition & 0 deletions gnucash/gnome-utils/test/test-tree-container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ TEST(GncTreeContainer, Basic) {

// test non-empty
EXPECT_EQ(false, container.empty());
EXPECT_EQ(10, container.size());

{
auto is_five = [](auto it){ return it.template get_int(COLUMN_INT) == 5; };
Expand Down

0 comments on commit 512c6bf

Please sign in to comment.