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 f1aa2e7 commit 94853c2
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 @@ -60,6 +60,7 @@ TEST(GncTreeContainer, Basic) {

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

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

0 comments on commit 94853c2

Please sign in to comment.