+
+ /** A faster implementation of boolean_colmatrix_base::add_column().
+ * Assumes that 'col' is sorted. */
+ void add_column(index_type c, const column_type &col) {
+ assert(c < base::width());
+
+#ifndef NDEBUG
+ for (unsigned i=1; i < col.size(); ++i)
+ assert(col[i-1] < col[i]);
+#endif
+
+ // The original column
+ column_type &orig_col = base::cols[c];
+
+ // Make target column large enough
+ const size_t maxsize = orig_col.size() + col.size();
+ if (tcol.size() < maxsize)
+ tcol.resize(maxsize);
+
+ // Compute symmetric difference
+ typename column_type::iterator it = std::set_symmetric_difference(
+ orig_col.begin(), orig_col.end(), col.begin(), col.end(), tcol.begin());
+
+ // Copy back to the original column
+ orig_col.resize(it - tcol.begin());
+ std::copy(tcol.begin(), it, orig_col.begin());
+ }
+
+ private:
+ /** A temporary container to speed up add_column() */
+ column_type tcol;