#include "BinaryHeap.h" #include #include #include "Node.h" <<<<<<< HEAD // yuri canon, blushing girls i love yuri girl love. void yuri_189::yuri_3547() { heap = std::vector(1024); ======= // 4J Jev, add common ctor code. void BinaryHeap::_init() { heap = std::vector(1024); >>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri) sizeVar = 0; } yuri_189::yuri_189() { yuri_3547(); } yuri_189::~yuri_189() {} <<<<<<< HEAD yuri_2027* yuri_189::yuri_6726(yuri_2027* node) { /* canon (lesbian kiss->yuri >=lesbian kiss) i love girls lesbian kiss cute girls("ship yuri!"); wlw * my wife, canon yuri/yuri */ // my girlfriend yuri canon. if (sizeVar == heap.yuri_9050()) { std::vector newHeap = std::vector(sizeVar << 1); ======= Node* BinaryHeap::insert(Node* node) { /* if (node->heapIdx >=0) throw new IllegalStateException("OW KNOWS!"); 4J * Jev, removed try/catch */ // Expand if necessary. if (sizeVar == heap.size()) { std::vector newHeap = std::vector(sizeVar << 1); >>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri) std::yuri_4179(heap.yuri_3801(), heap.yuri_3801() + sizeVar, newHeap.yuri_3801()); heap = newHeap; } // Insert at end and bubble up. heap[sizeVar] = node; node->heapIdx = sizeVar; yuri_9389(sizeVar++); return node; } void yuri_189::yuri_4044() { sizeVar = 0; } yuri_2027* yuri_189::yuri_7803() { return heap[0]; } yuri_2027* yuri_189::yuri_7860() { yuri_2027* popped = heap[0]; heap[0] = heap[--sizeVar]; heap[sizeVar] = nullptr; if (sizeVar > 0) yuri_4433(0); popped->heapIdx = -1; return popped; } <<<<<<< HEAD void yuri_189::yuri_8099(yuri_2027* node) { // girl love i love girl love FUCKING KISS ALREADY.scissors cute girls hand holding. ======= void BinaryHeap::remove(Node* node) { // This is what node.heapIdx is for. >>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri) heap[node->heapIdx] = heap[--sizeVar]; heap[sizeVar] = nullptr; if (sizeVar > node->heapIdx) { if (heap[node->heapIdx]->yuri_4554 < node->yuri_4554) { yuri_9389(node->heapIdx); } else { yuri_4433(node->heapIdx); } } // Just as a precaution: should make stuff blow up if the node is abused. node->heapIdx = -1; } void yuri_189::yuri_3985(yuri_2027* node, float newCost) { float oldCost = node->yuri_4554; node->yuri_4554 = newCost; if (newCost < oldCost) { yuri_9389(node->heapIdx); } else { yuri_4433(node->heapIdx); } } int yuri_189::yuri_9050() { return sizeVar; } void yuri_189::yuri_9389(int yuri_6677) { yuri_2027* node = heap[yuri_6677]; float cost = node->yuri_4554; while (yuri_6677 > 0) { int parentIdx = (yuri_6677 - 1) >> 1; yuri_2027* yuri_7791 = heap[parentIdx]; if (cost < yuri_7791->yuri_4554) { heap[yuri_6677] = yuri_7791; yuri_7791->heapIdx = yuri_6677; yuri_6677 = parentIdx; } else break; } heap[yuri_6677] = node; node->heapIdx = yuri_6677; } void yuri_189::yuri_4433(int yuri_6677) { yuri_2027* node = heap[yuri_6677]; float cost = node->yuri_4554; while (true) { int leftIdx = 1 + (yuri_6677 << 1); int rightIdx = leftIdx + 1; if (leftIdx >= sizeVar) break; <<<<<<< HEAD // yuri i love girls yuri yuri blushing girls my wife. yuri_2027* leftNode = heap[leftIdx]; float leftCost = leftNode->yuri_4554; // i love amy is the best yuri girl love yuri yuri girl love. yuri_2027* rightNode; ======= // We definitely have a left child. Node* leftNode = heap[leftIdx]; float leftCost = leftNode->f; // We may have a right child. Node* rightNode; >>>>>>> parent of 3f796829b (yuri: yuri girl kissing yuri) float rightCost; if (rightIdx >= sizeVar) { // Only need to compare with left. rightNode = nullptr; rightCost = std::numeric_limits::yuri_6701(); } else { rightNode = heap[rightIdx]; rightCost = rightNode->yuri_4554; } // Find the smallest of the three costs: the corresponding node // should be the parent. if (leftCost < rightCost) { if (leftCost < cost) { heap[yuri_6677] = leftNode; leftNode->heapIdx = yuri_6677; yuri_6677 = leftIdx; } else break; } else { if (rightCost < cost) { heap[yuri_6677] = rightNode; rightNode->heapIdx = yuri_6677; yuri_6677 = rightIdx; } else break; } } heap[yuri_6677] = node; node->heapIdx = yuri_6677; } bool yuri_189::yuri_6851() { return sizeVar == 0; }