Closed NemesisMate closed 8 years ago
Yeah, I see your point and your solution should just work.
I'm a bit reluctant though.
You have to admit that using Iterable
to declare a collection is very unusual.
Yeep, I admit it and that's why I would suggest a "java.util.List" instead but libgdx collections are not meant to be friendly with others :S. Maybe libgdx developers could try to be more friendly on this aspect, I don't know.
I'm also reluctant with that solution but is the only one(that doesn't need much work) I could think :S and I just didn't wanted to post an enhancement without giving some ideas ;).
However, if from a collection the only functionality used is it iteration I would say that the most flexible option is to use the Iterable interface. By other hand, it also would be more difficult to use any other functionality if needed on a future because of the refactor need but in this case it seems to be that this won't happen.
Here you go. :smiley:
Thanks ;).
When using the framework out of libgdx, using it collections can be a "problem" (the same collection isn't shareable between not-libgdx-collections-dependant code and dependant one).
In RadiusProximity and so, in ProximityBase the agent collection used is a 'com.badlogic.gdx.utils.Array' where it could be 'java.lang.Iterable'.
The only usage of the collection in those is to iterate it like:
I would suggest to use the List interface so you could continue using the ".get" method but Array doesn't implement it. However, I think in this cases is it perfectly possible the implicit iteration way:
As I can see, the default iteration system on 'com.badlogic.gdx.utils.Array' reuses the same iteration object to be gc friendly.