Exemplo n.º 1
0
  /**
   * Filter for nodes.
   *
   * @param nodes input set of nodes
   * @return set of filtered nodes
   */
  public Vector filter(Vector nodes) {
    SortedVector result = new SortedVector();
    Vector filtered = new Vector();

    for (int i = 0; i < nodes.size(); i++) result = addNode((Node) nodes.get(i), result);

    for (int i = 0; i < result.size(); i++) filtered.add(((NodeDistance) result.get(0)).node);

    return filtered;
  }
Exemplo n.º 2
0
 /**
  * Add node to samples.
  *
  * @param node node to add to samples
  * @param resultSet set of resulting nodes
  * @return set of n nodes
  */
 protected SortedVector addNode(Node node, SortedVector resultSet) {
   resultSet.add(new NodeDistance(node, point.distance(node)));
   while (resultSet.size() > n) resultSet.remove(resultSet.size() - 1);
   return resultSet;
 }