List return_List = new ArrayList();
List nextNeighbours_List = new ArrayList();
List epsilonRange_List = new ArrayList();
PriorityQueue priorityQueue = new PriorityQueue();
while (iterator.hasNext()) {
DataObject next_dataObject = (DataObject) iterator.next();
double dist = dataObject.distance(next_dataObject);
if (dist <= epsilon) epsilonRange_List.add(new EpsilonRange_ListElement(dist, next_dataObject));
if (priorityQueue.size() < k) {
priorityQueue.add(dist, next_dataObject);
} else {
if (dist < priorityQueue.getPriority(0)) {
priorityQueue.next(); //removes the highest distance
priorityQueue.add(dist, next_dataObject);
}
}
}
while (priorityQueue.hasNext()) {
nextNeighbours_List.add(0, priorityQueue.next());
}
return_List.add(nextNeighbours_List);
return_List.add(epsilonRange_List);
return return_List;