void table_base::rename_field_impl(const abstract_mapper_base &before, const abstract_mapper_base &after) const { if (_is_open) throw table_open_exception(); const column_id_set my_columns = _value_mapper.column_ids(); if (! ( is_subset(before.column_ids(), my_columns) || is_subset(after.column_ids(), my_columns) )) throw outside_table_exception(_binomen); vector<string> names_before; vector<string> names_after; before.for_each_persistent_column([&](const persistent_column_mapper &p) { names_before.push_back(p.name()); } ); after.for_each_persistent_column([&](const persistent_column_mapper &p) { names_after.push_back(p.name()); } ); const size_t n = names_before.size(); assert(names_after.size() == n); transaction txn(_database); unique_ptr<sql> cmd; for (size_t i = 0; i < n; i++) { cmd = _database.make_sql(); cmd->write_rename_column(_binomen, names_before[i], names_after[i]); _database.get_session()->exec(*cmd); } txn.commit(); }
void table_base::set_field_type(const abstract_mapper_base &mapper) const { if (is_open()) throw table_open_exception(); if (! is_subset(mapper.column_ids(), _value_mapper.column_ids())) throw outside_table_exception(_binomen); transaction txn(_database); unique_ptr<sql> cmd; // In case some fields went from non-optional to optional, and also to avoid duplication // of abiding non-null constraints, which will be re-added by constrain_as_not_null() below: // cmd = _database.make_sql(); cmd->write_unconstrain_as_not_null(_binomen, mapper); _database.get_session()->exec(*cmd); cmd = _database.make_sql(); cmd->write_set_columns_types(_binomen, mapper, readback_id()); _database.get_session()->exec(*cmd); // In case some fields went from optional to non-optional: // cmd = _database.make_sql(); cmd->write_constrain_as_not_null_where_appropriate(_binomen, mapper); _database.get_session()->exec(*cmd); txn.commit(); }
void table_base::add_field_impl(const abstract_mapper_base &dest, const Src &src) const { if (_is_open) throw table_open_exception(); if (! is_subset(dest.column_ids(), _value_mapper.column_ids())) throw outside_table_exception(_binomen); const optional<column_id> readback = readback_id(); transaction txn(_database); unique_ptr<sql> cmd; cmd = _database.make_sql(); cmd->write_add_columns(_binomen, dest, readback); _database.get_session()->exec(*cmd); if (! readback || dest.column_ids() != column_id_set{*readback}) update_with_no_output(dest, src, predicate(true)); cmd = _database.make_sql(); cmd->write_constrain_as_not_null_where_appropriate(_binomen, dest); _database.get_session()->exec(*cmd); txn.commit(); }
INT fancy_set::is_equal(fancy_set *set2) { if (is_subset(set2) && k == set2->k) { return TRUE; } return FALSE; }
void table_base::check_metadata(bool db_may_have_extra_columns) const { const set<string> actual = to_set(_database.retrieve_column_titles(_binomen)); set<string> expected; get_value_mapper_base().for_each_persistent_column([&](const persistent_column_mapper &p) { const column_type type = _database.retrievable_column_type( p.get_column_type(p.id() == readback_id()) ); expected.insert( "\"" + p.name() + "\" " + _database.column_type_name(type) ); }); if ( ! is_subset(expected, actual) // deficit || (! db_may_have_extra_columns && ! is_subset(actual, expected)) // surplus ) throw table_mismatch_exception(_binomen, expected, actual); }
void table_base::drop_field(const abstract_mapper_base &deletion) const { if (is_open()) throw table_open_exception(); if (! is_subset(deletion.column_ids(), _value_mapper.column_ids())) throw outside_table_exception(_binomen); const unique_ptr<sql> cmd = _database.make_sql(); cmd->write_drop_columns(_binomen, deletion); _database.get_session()->exec(*cmd); }
int main() { do { DBG::test(); cout << "\n?? another test (*/q) ?"; } while (getche() != 'q'); data_tree p, q; p | q; is_subset(p, q); is_equal(p, q); return 0; }
bool ufbv_rewriter::is_demodulator(expr * e, expr_ref & large, expr_ref & small) const { if (e->get_kind() == AST_QUANTIFIER) { quantifier * q = to_quantifier(e); if (q->is_forall()) { expr * qe = q->get_expr(); if ((m_manager.is_eq(qe) || m_manager.is_iff(qe))) { app * eq = to_app(q->get_expr()); expr * lhs = eq->get_arg(0); expr * rhs = eq->get_arg(1); int subset = is_subset(lhs, rhs); int smaller = is_smaller(lhs, rhs); TRACE("demodulator", tout << "testing is_demodulator:\n" << mk_pp(lhs, m_manager) << "\n" << mk_pp(rhs, m_manager) << "\n" << "subset: " << subset << ", smaller: " << smaller << "\n";);
unique_ptr<sql> table_base::sql_update( const abstract_mapper_base &dest, const Src &src, const abstract_predicate &pred, const abstract_mapper_base *returning ) const { if (! is_subset(dest.columns(), _value_mapper.columns())) throw outside_table_exception(_binomen); unique_ptr<sql> cmd = _database.make_sql(); cmd->write_update(_binomen, dest, src, readback_id()); if (! a_priori_true(pred)) cmd->write_where(pred); if (returning != nullptr) cmd->write_returning(*returning); return cmd; }
main () { int i; bit_set a,b,c,d; a = create_bit_set (35); b = create_bit_set (35); c = create_bit_set (35); d = create_bit_set (35); for (i = 0; i < 35; i++){ bit_on (a,i); bit_on (b,2*(i/2)); bit_on (c,i); bit_on (d,2*(i/2)); } printf ("a == b %d a sub b %d b sub a %d\n", bit_set_equal (a,b),is_subset(a,b),is_subset(b,a)); printf ("a == c %d a sub c %d c sub a %d\n", bit_set_equal (a,c),is_subset(a,c),is_subset(c,a)); printf ("a == d %d a sub d %d d sub a %d\n", bit_set_equal (a,d),is_subset(a,d),is_subset(d,a)); printf ("b == c %d b sub c %d c sub b %d\n", bit_set_equal (b,c),is_subset(b,c),is_subset(c,b)); printf ("b == d %d b sub d %d d sub b %d\n", bit_set_equal (b,d),is_subset(b,d),is_subset(d,b)); printf ("c == d %d c sub d %d d sub c %d\n", bit_set_equal (c,d),is_subset(c,d),is_subset(d,c)); bit_off (d,6); bit_off (c,7); printf ("\n\na == b %d a sub b %d b sub a %d\n", bit_set_equal (a,b),is_subset(a,b),is_subset(b,a)); printf ("a == c %d a sub c %d c sub a %d\n", bit_set_equal (a,c),is_subset(a,c),is_subset(c,a)); printf ("a == d %d a sub d %d d sub a %d\n", bit_set_equal (a,d),is_subset(a,d),is_subset(d,a)); printf ("b == c %d b sub c %d c sub b %d\n", bit_set_equal (b,c),is_subset(b,c),is_subset(c,b)); printf ("b == d %d b sub d %d d sub b %d\n", bit_set_equal (b,d),is_subset(b,d),is_subset(d,b)); printf ("c == d %d c sub d %d d sub c %d\n", bit_set_equal (c,d),is_subset(c,d),is_subset(d,c)); }
bool Seq::implies(const Seq& seq) const { return is_subset(conj, seq.conj) && is_subset(disj, seq.disj); }
static constexpr auto apply(Xs xs, Ys ys) { return and_(is_subset(xs, ys), is_subset(ys, xs)); }
struct constraint * add_cutset_to_list ( bitmap_t * cutset, /* IN - new cutset to add */ struct constraint * cutlist, /* IN - list to add to */ double * x, /* IN - current LP solution */ bitmap_t * vert_mask, /* IN - set of valid terminals */ bitmap_t * edge_mask, /* IN - set of valid hyperedges */ struct cinfo * cip /* IN - compatibility info */ ) { int i; int j; int nedges; int nmasks; int num_in_cut; int count; int * vp1; int * vp2; struct constraint * p; struct constraint ** hookp; bitmap_t * cut_edges; double z; nedges = cip -> num_edges; nmasks = cip -> num_edge_masks; cut_edges = NEWA (nmasks, bitmap_t); memset (cut_edges, 0, nmasks * sizeof (*cut_edges)); count = 0; z = 0.0; for (i = 0; i < cip -> num_edges; i++) { if (NOT BITON (edge_mask, i)) continue; num_in_cut = 0; vp1 = cip -> edge [i]; vp2 = cip -> edge [i + 1]; while (vp1 < vp2) { j = *vp1++; if (BITON (cutset, j)) { ++num_in_cut; } } if (num_in_cut <= 0) { /* this hyperedge resides entirely */ /* outside of the cut... doesn't span! */ continue; } if (num_in_cut >= cip -> edge_size [i]) { /* this hyperedge resides entirely */ /* within the cut... doesn't span! */ continue; } SETBIT (cut_edges, i); ++count; z += x [i]; } /* Check for an all-zero cutset. These occasionally */ /* happen because of numeric issues... */ if (count <= 0) { /* Empty cutset! OOOPS! */ #if 1 tracef (" %% WARNING! empty cutset!\n"); #endif free ((char *) cut_edges); return (cutlist); } if (z >= 1.0 - FUZZ) { #if 1 tracef (" %% WARNING! bogus cutset!\n"); #endif free ((char *) cut_edges); return (cutlist); } /* If this new cutset is a superset of an existing one, */ /* then there is nothing to add, and nothing to delete. */ for (p = cutlist; p NE NULL; p = p -> next) { if (is_subset (p -> mask, cut_edges, nmasks)) { free (cut_edges); return (cutlist); } } /* Delete all current cutsets which have this new one */ /* as a subset. */ hookp = &cutlist; while ((p = *hookp) NE NULL) { if (p -> type NE CT_CUTSET) { hookp = &(p -> next); } else if (is_subset (cut_edges, p -> mask, nmasks)) { *hookp = p -> next; free ((char *) (p -> mask)); free ((char *) p); } else { hookp = &(p -> next); } } p = NEW (struct constraint); p -> next = NULL; p -> iteration = 0; p -> type = CT_CUTSET; p -> mask = cut_edges; *hookp = p; return (cutlist); }
int main(int argc, char *argv[]) { if (argc != 3) { perror("Not enough arguments"); return EXIT_FAILURE; } /* Allocate initial array of size 16 */ int words_size = 16; char **words = malloc(words_size * sizeof(char*)); if (words == NULL) { perror("malloc() failed"); return EXIT_FAILURE; } printf("Allocated initial array of %d character pointers.\n", words_size); /* Open the input text file */ FILE *fp; if ((fp = fopen(argv[1], "r")) == NULL) { perror("Error openning file"); return EXIT_FAILURE; } /* Add words to array */ int num_words = 0; int i; char oneword[100]; char c; while (c != EOF) { c = fscanf(fp, "%s", oneword); if (c == EOF) break; words[i] = malloc(sizeof(char) * (strlen(oneword) + 1)); strcpy(words[i], oneword); num_words++; /* Resize when array is full */ if (num_words == words_size) { words_size = words_size * 2; char **temp = realloc(words, words_size * sizeof(int*)); if (temp == NULL) { /* Error reallocating */ perror("realloc() failed"); return EXIT_FAILURE; } words = temp; printf("Re-allocated array of %d character pointers.\n", words_size); } i++; } /* Close the input text file */ fclose(fp); printf("All done (successfully read %d words).\n", num_words); printf("Words containing substring \"%s\" are:\n", argv[2]); /* Print all stored items in array */ for (i = 0; i < num_words; i++) { if (is_subset(words[i], argv[2])) printf("%s\n", words[i]); /* Free each word after it is compared with substring */ free(words[i]); } /* Free allocated memory */ free(words); return EXIT_SUCCESS; }
bool Bvector::is_proper_subset(const Bvector* super) const { return (is_subset(super) && !is_equal(super)); }