Пример #1
0
int varchain::compare(const varchain& l, const varchain& r) {
  size_t n = l.size() < r.size() ? l.size() : r.size();
  for (size_t i=0; i<n; i++) {
    if (l.repr[i] < r.repr[i]) {
      return -1;
    }
    if (r.repr[i] < l.repr[i]) {
      return 1;
    }
  }
  if (l.size() < r.size()) return -1;
  if (l.size() == r.size()) return 0;
  return 1;
}
Пример #2
0
varchain operator * ( varchain c1, const varchain& c2 ) {
  c1.repr.reserve(c1.size() + c2.size());
  for (auto e : c2.repr) c1.repr.push_back(e);
  c1.normalize();
  return c1;
}