Ejemplo n.º 1
0
void Object::InsertAndRemoveDuplicates(ObjectList& set,
					      int old)  {
  cout << "******* Object::InsertAndRemoveDuplicates() " << endl;
  // This _is_ still used by Query::GatherNewObjects() by CombineMapsVQ().
  // I think no place uses this nomore.  Should be obsoleted ???

  for (size_t i=old; i<set.size(); i++) {
    size_t p = i, q = i;
    double val = set[i].Value();
    for (int j=old-1; j>=0; j--) {
      if (val>set[j].Value())
	p = j;
      else if (q!=i)
	break;
      if (q==i && set[j].Match(set[i])) {
	val = set[j].AddValue(val);  // OBS! AddValue()
	p = q = j;
      }
    }
    set.move(q, p);
    if (q==i)
      old++;
    else {
      set.swap_objects(i, set.size()-1);
      set.erase(set.size()-1);
      i--;
    }
  }
}
Ejemplo n.º 2
0
  void Object::SortListByRank(ObjectList& list) {
    int k = 0;
    for (size_t j=1; j<list.size(); j++) {
      if (!list[j].Retained())
	continue; 
      int r = list[j].Rank();
      for (k=j-1; k>=0; k--)
	if (list[k].Retained() && list[k].Rank()<=r)
	  break;
      
      /*
      cout << "Object::SortList() val[" << j << "]=" << val
	   << " val[" << k+1 << "]=" << list[k+1].Rank() << endl;
      */

      list.move(j, k+1);
    }
  }
Ejemplo n.º 3
0
  void Object::SortListByValue(ObjectList& list) {
    // This _is_ still used by Query::StageFinalSelect().
    //Obsoleted("Object::SortList(ObjectList&)");

    int k = 0;
    for (size_t j=1; j<list.size(); j++) {
      if (!list[j].Retained())
	continue; 
      float val = list[j].Value();
      for (k=j-1; k>=0; k--)
	if (list[k].Retained() && list[k].Value()>val)
	  break;
      
      /*
      cout << "Object::SortList() val[" << j << "]=" << val
	   << " val[" << k+1 << "]=" << list[k+1].Value() << endl;
      */

      list.move(j, k+1);
    }
  }