Пример #1
0
  bool OBStereo::ContainsSameRefs(const OBStereo::Refs &refs1, const OBStereo::Refs &refs2)
  {
    if (refs1.size() != refs2.size())
      return false;

    int count = 0;
    for (ConstRefIter i = refs1.begin(); i != refs1.end(); ++i)
      for (ConstRefIter j = refs2.begin(); j != refs2.end(); ++j)
        if (*i == *j) {
          count++;
          break;
        }

    return (count == refs1.size());
  }
Пример #2
0
  bool OBStereo::ContainsRef(const OBStereo::Refs &refs, unsigned long id)
  {
    for (ConstRefIter i = refs.begin(); i != refs.end(); ++i)
      if (*i == id)
        return true;

    return false;
  }
Пример #3
0
  int OBStereo::NumInversions(const OBStereo::Refs &refs)
  {
    OBStereo::Refs invVec; // the inversion vector
    OBStereo::ConstRefIter i, j;
    for (i = refs.begin(); i != refs.end(); ++i) {
      int e = 0; // ith element
      // loop over elements to the right
      for (j = i; j != refs.end(); ++j)
        // increment e if element to the right is lower
        if (*j < *i)
          e++;

      invVec.push_back(e);
    }

    int sum = 0;
    for (OBStereo::RefIter k = invVec.begin(); k != invVec.end(); ++k)
      sum += *k;

    return sum;
  }