Set iterator doesn't work
So, the code is simple:
However, does not work.
for (Iterator<Monster> it = monsters.iterator(); it.hasNext(); )
Monster m = it.next();
Vec2d v = new Vec2d(game.playerC.x, game.playerC.y);
v.subVec(new Vec2d(m.x, m.y));
m.movement = v;
The set is declared as follows inside this class:
Nothing happens. However, when I use HashSet instead, it acts only for one element and ignores next ones.
Set<Character> characters = Collections.synchronizedSet(new TreeSet<Character>());
I use trivial hash function for that, maybe it's the reason:
Still, all I need is unordered collection with random access.
public int compareTo(Object o)
Your feedback would be appreciated.