Exemplo n.º 1
0
 /**
  * Refine a range query.
  *
  * @param neighc Original result
  * @param adjustedEps New epsilon
  * @return refined list
  */
 private DoubleDBIDList refineRange(DoubleDBIDList neighc, double adjustedEps) {
   ModifiableDoubleDBIDList n = DBIDUtil.newDistanceDBIDList(neighc.size());
   // We don't have a guarantee for this list to be sorted
   for (DoubleDBIDListIter neighbor = neighc.iter(); neighbor.valid(); neighbor.advance()) {
     DoubleDBIDPair p = neighbor.getPair();
     double dist = p.doubleValue();
     if (dist <= adjustedEps) {
       n.add(dist, p);
     }
   }
   return n;
 }
 @Override
 public void insert(DoubleDBIDPair e) {
   final int kminus1 = k - 1;
   final double dist = e.doubleValue();
   if (size < k || dist <= data[kminus1].doubleValue()) {
     // Ensure we have enough space.
     if (size > data.length) {
       grow();
     }
     if (e instanceof DoubleIntegerDBIDPair) {
       insertionSort((DoubleIntegerDBIDPair) e);
     } else {
       insertionSort(new DoubleIntegerDBIDPair(dist, e.internalGetIndex()));
     }
     // Truncate if necessary:
     if (size > k && data[k].doubleValue() > data[kminus1].doubleValue()) {
       truncate();
     }
   }
 }