📄 collector.cpp
字号:
//*************************** collector.cpp ****************************#include <iostream>#include <cstdlib>using namespace std;#include "heap.h"Heap heap;void program() { static int val = 123; int rn, p, q, r; if (heap.rootCnt == 0) { // call heap.allocateAtom(0,val++); p = 0; rn = 1; } else { rn = rand() % 100 + 1; p = rand() % heap.rootCnt+1; // possibly new root; q = rand() % heap.rootCnt; r = rand() % heap.rootCnt; } if (rn <= 20) heap.allocateAtom(p,val++); else if (rn <= 40) heap.allocateList(p,q,r); else if (rn <= 60) heap.updateHead(q,r); else if (rn <= 80) heap.updateTail(q,r); else heap.deallocate(p); cout << heap;}int main() { for (int i = 0; i < 50; i++) program(); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -