Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct qtree {
- uint8_t height;
- union {
- #define ALIVE node.alive
- bool alive;
- #define QUADS node.quads /* 0: tl 1: tr */
- struct qtree** quads; /* 2: bl 3: br */
- } node;
- } __attribute__((__packed__));
- static qtree* init_qtree(int height, bool init_quads = true) {
- qtree* qt = new qtree;
- qt->height = (uint8_t) height;
- if (init_quads) {
- qt->QUADS = new qtree*[4];
- } else {
- qt->ALIVE = false;
- }
- }
- qtree* new_qt(int height) {
- if (height == 0) {
- return init_qtree(0, false);
- } else {
- qtree* qt = init_qtree(height);
- for (int i = 0; i < 4; ++i) {
- qt->QUADS[i] = new_qt(height - 1);
- }
- return qt;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment