MCPcopy Create free account
hub / github.com/Singular/Singular / Main

Function Main

ppcc/adlib/test5.cc:14–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12 }
13} valmapper;
14void Main() {
15 Map<Str *, Int> *to_i = new Map<Str *, Int>();
16 Map<Int, Str *> *to_s = new Map<Int, Str *>();
17 const int n = 1000;
18 for (int i = 0; i < n; i++) {
19 char buf[sizeof(int) * 3 + 1];
20 sprintf(buf, "%d", i);
21 Str *s = S(buf);
22 to_i->add(s, i);
23 to_s->add(i, s);
24 }
25 Check(to_i->count() == n && to_s->count() == n, "map sizes");
26 to_i->union_in_place(to_i);
27 Check(to_i->count() == n, "map union");
28 to_i->intersect_in_place(to_i);
29 Check(to_i->count() == n, "map intersection");
30 Map<Str *, Int> *aux = to_i->diff_with(to_i);
31 Check(aux->count() == 0, "map difference");
32 Check(to_i->keys()->len() == to_i->values()->len(), "keys & values");
33 int mismatch = 0;
34 for (int i = 0; i < n; i++) {
35 if (!to_s->contains(i))
36 mismatch++;
37 Str *s = to_s->get(i, NULL);
38 if (!s || to_i->get(s, -1) == -1)
39 mismatch++;
40 }
41 Check(mismatch == 0, "map indexing");
42 Map<Str *, Int> *r
43 = to_s->map_pairs(new Map<Str *, Int>(), keymapper, valmapper);
44 Check(r->count() == n, "map pair mapping");
45 Dict *dict = to_i->map_values(new Dict(), keymapper);
46 Check(dict->count() == n, "map value mapping");
47}

Callers

nothing calls this directly

Calls 14

CheckFunction · 0.85
keysMethod · 0.80
valuesMethod · 0.80
map_pairsMethod · 0.80
map_valuesMethod · 0.80
SFunction · 0.70
addMethod · 0.45
countMethod · 0.45
union_in_placeMethod · 0.45
intersect_in_placeMethod · 0.45
diff_withMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected