Exemplo n.º 1
0
void Fragment::set_residue_indexes(kernel::Model *m, kernel::ParticleIndex pi,
                                   Ints o) {
  if (o.empty()) {
    set_residue_indexes(m, pi, IntPairs());
    return;
  }
  std::sort(o.begin(), o.end());
  o.erase(std::unique(o.begin(), o.end()), o.end());
  IntPairs pairs;
  int begin = 0;
  for (unsigned int i = 1; i < o.size(); ++i) {
    if (o[i] != o[i - 1] + 1) {
      pairs.push_back(IntPair(o[begin], o[i - 1] + 1));
      begin = i;
    }
  }
  pairs.push_back(IntPair(o[begin], o.back() + 1));
  set_residue_indexes(m, pi, pairs);
  using IMP::operator<<;
  IMP_IF_CHECK(USAGE) {
    for (unsigned int i = 0; i < o.size(); ++i) {
      IMP_INTERNAL_CHECK(Fragment(m, pi).get_contains_residue(o[i]),
                         "Residue index not found after addition: "
                             << o << " became " << pairs);
    }
  }
}
Exemplo n.º 2
0
static void eraseElements(Ints& vect, int val) {
    Ints::iterator begin = vect.begin();
    Ints::iterator end = vect.end();
    vect.erase(std::remove(begin, end, val), end);
}