Answer the question
In order to leave comments, you need to log in
How to take 2 elements from the queue with a minimum distance between them?
Hello!
There is a PriorityBlockingQueue, it has 40 objects of type Client (essentially a player). Each such object has its position in the world, which is set using Vector3D. To be more precise, then:
org.apache.commons.math3.geometry.euclidean.threed.Vector3D
public class TankDistanceComparator implements Comparator<Client> {
@Override
public int compare(Client o1, Client o2) {
/*Имплементация getPosition упущена за ненадобностью.*/
Vector3D o1p = getPosition(o1);
Vector3D o2p = getPosition(o2);
double distance = o1p.distance(o2p);
/*Что тут нужно сделать?*/
return 0;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question