MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / push

Method push

code/data-structures/heap.cpp:30–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28 memset(loc, 255, len << 2); }
29 ~heap() { delete[] q; delete[] loc; }
30 void push(int n, bool fix = true) {
31 if (len == count || n >= len) {
32#ifdef RESIZE
33 int newlen = 2 * len;
34 while (n >= newlen) newlen *= 2;
35 int *newq = new int[newlen], *newloc = new int[newlen];
36 rep(i,0,len) newq[i] = q[i], newloc[i] = loc[i];
37 memset(newloc + len, 255, (newlen - len) << 2);
38 delete[] q, delete[] loc;
39 loc = newloc, q = newq, len = newlen;
40#else
41 assert(false);
42#endif
43 }
44 assert(loc[n] == -1);
45 loc[n] = count, q[count++] = n;
46 if (fix) swim(count-1); }
47 void pop(bool fix = true) {
48 assert(count > 0);
49 loc[q[0]] = -1, q[0] = q[--count], loc[q[0]] = 0;

Callers 12

countMethod · 0.45
aho_corasickMethod · 0.45
gift_wrapFunction · 0.45
propagateMethod · 0.45
stable_marriageFunction · 0.45
queryMethod · 0.45
testFunction · 0.45
random_treeFunction · 0.45
lca_treeMethod · 0.45
sccFunction · 0.45
euler_pathFunction · 0.45
tsort_dfsFunction · 0.45

Calls

no outgoing calls

Tested by 4

queryMethod · 0.36
testFunction · 0.36
random_treeFunction · 0.36
lca_treeMethod · 0.36