Exemple #1
0
 @Override
 public boolean contains(DBIDRef o) {
   int oid = o.internalGetIndex();
   if (oid < start) {
     return false;
   }
   if (oid >= start + len) {
     return false;
   }
   return true;
 }
 @Override
 public double insert(double distance, DBIDRef id) {
   final int kminus1 = k - 1;
   if (size < k || distance <= data[kminus1].doubleValue()) {
     // Ensure we have enough space.
     if (size > data.length) {
       grow();
     }
     insertionSort(new DoubleIntegerDBIDPair(distance, id.internalGetIndex()));
     // Truncate if necessary:
     if (size > k && data[k].doubleValue() > data[kminus1].doubleValue()) {
       truncate();
     }
   }
   return (size < k) ? Double.POSITIVE_INFINITY : get(kminus1).doubleValue();
 }
Exemple #3
0
 /**
  * For storage array offsets.
  *
  * @param dbid ID reference
  * @return array offset
  */
 @Override
 public int getOffset(DBIDRef dbid) {
   return dbid.internalGetIndex() - start;
 }
Exemple #4
0
 @Override
 public final int mapDBIDToOffset(DBIDRef dbid) {
   return dbid.internalGetIndex() - start;
 }