vnedilko / artemis-framework

Automatically exported from code.google.com/p/artemis-framework
0 stars 0 forks source link

ImmutableBag should extend Iterable #8

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The ImmutableBag class has scope to extend the Iterable interface. The concrete 
classes such as Bag can implement those iterators.

Then it would be possible to use java's built in enhanced for loop:-

ImmutableBag<Entity> monsters = 
world.getManager(GroupManager.class).getEntities("MONSTERS");

for (Entity monster : monsters)
   monsters.doStuff();

Original issue reported on code.google.com by VeasM...@gmail.com on 21 Mar 2013 at 8:28

GoogleCodeExporter commented 9 years ago
This would cause an Iterator to be instantiated each time, unless Bag holds a 
single Iterator per instance - which might not be expected behavior. Generally 
speaking, I think a plain for loop is better.

Original comment by black...@gmail.com on 9 Sep 2013 at 4:00