common interator: add count() interface.

This commit is contained in:
Hermet Park 2021-08-10 10:52:43 +09:00 committed by Hermet Park
parent 5b89389161
commit 2337ea2b01
3 changed files with 12 additions and 0 deletions

View file

@ -31,6 +31,7 @@ namespace tvg
{
virtual ~Iterator() {}
virtual const Paint* next() = 0;
virtual uint32_t count() = 0;
};
struct StrategyMethod

View file

@ -42,6 +42,12 @@ struct PictureIterator : Iterator
paint = nullptr;
return ret;
}
uint32_t count() override
{
if (paint) return 1;
else return 0;
}
};

View file

@ -43,6 +43,11 @@ struct SceneIterator : Iterator
if (idx >= paints->count) return nullptr;
return paints->data[idx++];
}
uint32_t count() override
{
return paints->count;
}
};
struct Scene::Impl