void OpenFileDlg::on_btnUp_clicked() { QModelIndex oldRoot(ui->fileList->rootIndex()); QModelIndex newRoot(model.parent(oldRoot)); if ( newRoot.isValid() ) { ui->fileList->setRootIndex( newRoot ); ui->fileList->setCurrentIndex( oldRoot ); onLayoutChanged(); } }
/* -----------------CharTest method documentation--------------------- This method will run through a series of tests using char values. It will call various methods and output to the standar I/O information useful in debugging and ensuring the accuracy of the above method. THIS METHOD IS NOT PART OF THE PROJECT, BUT CAN BE USED AS A GUIDELINE TO PROPER USE. @params none. */ void CharTest() { element root = NULL; char keyValue = 'j'; root = newRoot(root, &keyValue); int i; char array[] = { 'a', 't', 'z', 'b', 'o', 'd', 'e', 'o', 'w' }; int size = 9; printf("Root-->%X ... with key-->%c\n", root, *((char*)root->key)); for (i = 0; i < size; i++) { char valueTemp = array[i]; element z = NULL; insert(root, &valueTemp, sizeof(char), charCompare); } print(root, 'c'); element max = Max(root); element min = Min(root); printf("Current max = %c\n", *((char*)max->key)); printf("Current min = %c\n\n", *((char*)min->key)); element toRemove = Successor(root); printf("Deleting root succesor --> %c\n", *((char *)toRemove->key)); root = deleteElem( toRemove); print(root, 'c'); char toFind = 'y'; bool tempBool = search(root, &toFind, charCompare); printf("Searching for element --> %c\n", toFind); if (tempBool)printf("Found element\n\n"); else printf("Did not find element\n\n"); printf("In Order Walk...\n"); InOrderWalk(root, 'c'); printf("\n\n"); printf("Deleting root...\n"); root = deleteElem( root); print(root, 'c'); }
void rebalance (TreeNode <T>& node) { const std::function <void (const TreeNode <T>&, TreeNode <T>&)> go = [&go] (const auto& child, auto& rebalancedChild) { if (child.parent ()) { const auto& parent = *child.parent (); auto& rebalancedParent = rebalancedChild.emplaceChild (parent.data ()); parent.forEachConstChild ([&rebalancedParent, &child] (const auto& c) { if (&c != &child) { rebalancedParent.addChild (c); } }); go (parent, rebalancedParent); } }; TreeNode <T>& newRoot (node); go (node, newRoot); this->_root = std::move (newRoot); }
void BPlusSegment<K,V>::insertAndSplit(const K& key, const V& value){ SplitResult<K> result = insertAndSplit(key, value, root); //update root if root has split if (result.hasSplit){ //TODO: handle upper PageID newRootId = pageCount; BufferFrame& newRootFrame = bm.fixPage(segmentId, newRootId, true); pageCount++; BPlusPage<K, PageID> newRoot(newRootFrame.getData(), pageSize, cmp); newRoot.initialize(); newRoot.setLeaf(false); newRoot.insert(result.pageHighestKey, root); newRoot.insert(result.siblingHighestKey, result.siblingPageID); root = newRootId; bm.unfixPage(newRootFrame, true); } bm.unfixPage(result.pageFrame, true); scm.segmentResized(*this); }
EuclideanExpression HomogeneousExpression::toEuclideanExpression() const { boost::shared_ptr<EuclideanExpressionNode> newRoot( new EuclideanExpressionNodeFromHomogeneous(_root)); return EuclideanExpression(newRoot); }
/* -----------------IntegerTest method documentation--------------------- This method will run through a series of tests using integer values. It will call various methods and output to the standar I/O information useful in debugging and ensuring the accuracy of the above method. THIS METHOD IS NOT PART OF THE PROJECT, BUT CAN BE USED AS A GUIDELINE TO PROPER USE. @params none. */ void IntegerTest() { element root = NULL; int keyValue = -1; root = newRoot(root, &keyValue); int i; int array[] = { 16, 17, 15, -8, -10, 0, 15, 108, -108, 12, 99, -7, 101, 105, 104, 106, 90, 91 }; int size = 18; printf("Root-->%X ... with key-->%i\n\n\n", root, *((int*)root->key)); for (i = 0; i < size; i++) { int valueTemp = array[i]; element z = NULL; insert(root, &valueTemp, sizeof(int), IntegerCompare); } print(root, 'i'); element max = Max(root); element min = Min(root); printf("Current max = %i\n", *((int*)max->key)); printf("Current min = %i\n\n", *((int*)min->key)); element toRemove = NULL; int intToRemove = 12; toRemove = search(root, &intToRemove, IntegerCompare); printf("Deleting element --> %i\n", *((int *)toRemove->key)); root = deleteElem( toRemove); print(root, 'i'); intToRemove = 0; toRemove = search(root, &intToRemove, IntegerCompare); printf("Deleting element --> %i\n", *((int *)toRemove->key)); root = deleteElem( toRemove); print(root, 'i'); intToRemove = 108; toRemove = search(root, &intToRemove, IntegerCompare); printf("Deleting element --> %i\n", *((int *)toRemove->key)); root = deleteElem( toRemove); print(root, 'i'); intToRemove = -8; toRemove = search(root, &intToRemove, IntegerCompare); printf("Deleting element --> %i\n", *((int *)toRemove->key)); root = deleteElem( toRemove); print(root, 'i'); intToRemove = 99; toRemove = search(root, &intToRemove, IntegerCompare); printf("Deleting element --> %i\n", *((int *)toRemove->key)); root = deleteElem( toRemove); print(root, 'i'); intToRemove = 101; toRemove = search(root, &intToRemove, IntegerCompare); printf("Deleting element --> %i\n", *((int *)toRemove->key)); root = deleteElem( toRemove); print(root, 'i'); int toFind = 50; bool tempBool = search(root, &toFind, IntegerCompare); printf("Searching for element --> %i\n", toFind); if (tempBool)printf("Found element\n\n"); else printf("Did not find element\n\n"); toFind = 90; tempBool = search(root, &toFind, IntegerCompare); printf("Searching for element --> %i\n", toFind); if (tempBool)printf("Found element\n\n"); else printf("Did not find element\n\n"); toFind = 50; element NullElement = search(root, &toFind, IntegerCompare); if (NullElement == NULL) printf("Successful NULL return from search\n\n"); else printf("ERROR no NULL returned from search\n\n"); printf("In Order Walk...\n"); InOrderWalk(root, 'i'); printf("\n\n"); printf("Deleting root...\n"); root = deleteElem( root); print(root, 'i'); printf("Adding {-1, 150, 125, 15}\n"); int array2[] = { -1, 150, 125, 15 }; size = 4; for (i = 0; i < size; i++) { int valueTemp = array2[i]; element z = NULL; insert(root, &valueTemp, sizeof(int), IntegerCompare); } print(root, 'i'); while (root->left != NULL) deleteElem( Min(root)); while (root->right != NULL) deleteElem( Max(root)); free(root->key); free(root); }