varchain operator * ( varchain c1, const varchain& c2 ) { c1.repr.reserve(c1.repr.size() + c2.repr.size()); c1.repr.insert(end(c1.repr), begin(c2.repr), end(c2.repr)); c1.normalize(); return c1; }
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; }
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; }