dominion-dev / dominion-ecs-java

Insanely fast ECS (Entity Component System) for Java
https://dominion-dev.github.io
MIT License
288 stars 17 forks source link

dev.dominion.ecs.api.Results add size() method which returns the number of entities in this result. #185

Closed endison1986 closed 10 months ago

endison1986 commented 10 months ago

dev.dominion.ecs.api.Results add size() method which returns the number of entities in this result. It can be used in debugging output, data statistics and other scenarios. Please check my unit tests and benchmark, I'm not good at these, Thank you.

enricostara commented 10 months ago

Hi @endison1986 ,

unfortunately we cannot promote this PR.

As a general rule, it's much better if you open an issue before you spend your time implementing a new feature. With a dedicated issue we can discuss whether to make the change before you start implementing it.

As for this specific PR, the "size" method cannot be implemented like this even if it is intended for debugging purposes. A high performance library can't really have a method that iterates and counts all possible elements just to know how many of them there are.

The biggest issue here is that end users only see the "size()" api method and didn't expect to get an O(n) time complexity API implementation behind it - they expect to get an O(1)