///Connect Signals and Slots only relevant for the graphical interface void gui_connections(Graphical_UI* gui, GraphManager* graph_mgr, OpenNIListener* listener) { QObject::connect(listener, SIGNAL(newVisualImage(QImage)), gui, SLOT(setVisualImage(QImage))); QObject::connect(listener, SIGNAL(newFeatureFlowImage(QImage)), gui, SLOT(setFeatureFlowImage(QImage))); QObject::connect(listener, SIGNAL(newDepthImage(QImage)), gui, SLOT(setDepthImage(QImage))); QObject::connect(graph_mgr, SIGNAL(sendFinished()), gui, SLOT(sendFinished())); QObject::connect(graph_mgr, SIGNAL(iamBusy(int, const char*, int)), gui, SLOT(showBusy(int, const char*, int))); QObject::connect(graph_mgr, SIGNAL(progress(int, const char*, int)), gui, SLOT(setBusy(int, const char*, int))); QObject::connect(graph_mgr, SIGNAL(setGUIInfo(QString)), gui, SLOT(setInfo(QString))); QObject::connect(graph_mgr, SIGNAL(setGUIStatus(QString)), gui, SLOT(setStatus(QString))); QObject::connect(gui, SIGNAL(printEdgeErrors(QString)), graph_mgr, SLOT(printEdgeErrors(QString))); QObject::connect(gui, SIGNAL(pruneEdgesWithErrorAbove(float)), graph_mgr, SLOT(pruneEdgesWithErrorAbove(float))); QObject::connect(gui, SIGNAL(clearClouds()), graph_mgr, SLOT(clearPointClouds())); if (ParameterServer::instance()->get<bool>("use_glwidget") && gui->getGLViewer() != NULL) { GLViewer* glv = gui->getGLViewer(); QObject::connect(graph_mgr, SIGNAL(setPointCloud(pointcloud_type *, QMatrix4x4)), glv, SLOT(addPointCloud(pointcloud_type *, QMatrix4x4)), Qt::BlockingQueuedConnection ); //Needs to block, otherwise the opengl list compilation makes the app unresponsive. This effectively throttles the processing rate though typedef const std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> >* cnst_ft_vectors; QObject::connect(graph_mgr, SIGNAL(setFeatures(const std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> >*)), glv, SLOT(addFeatures(const std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> >*))); //, Qt::DirectConnection); QObject::connect(graph_mgr, SIGNAL(setGraphEdges(const QList<QPair<int, int> >*)), glv, SLOT(setEdges(const QList<QPair<int, int> >*))); QObject::connect(graph_mgr, SIGNAL(updateTransforms(QList<QMatrix4x4>*)), glv, SLOT(updateTransforms(QList<QMatrix4x4>*))); QObject::connect(graph_mgr, SIGNAL(deleteLastNode()), glv, SLOT(deleteLastNode())); QObject::connect(graph_mgr, SIGNAL(resetGLViewer()), glv, SLOT(reset())); if(!ParameterServer::instance()->get<bool>("store_pointclouds")) { QObject::connect(glv, SIGNAL(cloudRendered(pointcloud_type const *)), graph_mgr, SLOT(clearPointCloud(pointcloud_type const *))); // } else if(ParameterServer::instance()->get<double>("voxelfilter_size") > 0.0) { QObject::connect(glv, SIGNAL(cloudRendered(pointcloud_type const *)), graph_mgr, SLOT(reducePointCloud(pointcloud_type const *))); // } } QObject::connect(listener, SIGNAL(setGUIInfo(QString)), gui, SLOT(setInfo(QString))); QObject::connect(listener, SIGNAL(setGUIStatus(QString)), gui, SLOT(setStatus(QString))); QObject::connect(graph_mgr, SIGNAL(setGUIInfo2(QString)), gui, SLOT(setInfo2(QString))); }
//fUNCTION TO DELETE AT SPECIFIC PISTION void deleteAtPosition(int position) { //First check if the position exsists //countNodes() returns the total number of nodes if(position>countNodes()) printf("Enter valid Position"); else { //delete the first node if(position==1) deleteFirstNode(); //delete last node else if(position==countNodes()) deleteLastNode(); else { struct node *temp,*curr=head,*prev=curr; /*traverse to the position and delete the node prev contains all the elements before the delete position curr conatins all the position after the delete position */ for(int i=1;i<position;i++) { prev = curr; curr = curr->next; } prev->next = NULL; prev->next = curr->next; } } }
void GraphManager::deleteLastFrame(){ if(graph_.size() <= 1) { ROS_INFO("Resetting, as the only node is to be deleted"); reset_request_ = true; Q_EMIT deleteLastNode(); return; } deleteCameraFrame(graph_.size()-1); Q_EMIT deleteLastNode(); optimizeGraph();//s.t. the effect of the removed edge transforms are removed to ROS_INFO("Removed most recent node"); Q_EMIT setGUIInfo("Removed most recent node"); //Q_EMIT setGraphEdges(getGraphEdges()); //updateTransforms needs to be last, as it triggers a redraw //Q_EMIT updateTransforms(getAllPosesAsMatrixList()); }
//Using linked list to implement undo. void undo(Hole board[], int *gameNum) { if (len(lHead) == 1) { printf("Sorry, you cannot undo past the beginning of the game. Please retry move.\n"); return; } deleteLastNode(&lHead); State* n = getTail(lHead); copyBoard(board, n->data); displayBoard(board); *gameNum -= 1; }
int main(void) { //linkedList pointer define start linkedList *L = (linkedList *)malloc(sizeof(linkedList)); L->cur = NULL; L->head = NULL; L->tail = NULL; //linkedList pointer define end createNode(L, 1); createNode(L, 2); createNode(L, 3); deleteLastNode(L); createNode(L, 4); createNode(L, 5); createNode(L, 6); deleteLastNode(L); deleteLastNode(L); createNode(L, 7); printNodes(L); return 0; }
main() { int n; printf("Chose from the options:\n"); while(1) { printf("\n1.Add elements to the Linked List \n"); printf("2.Delete Node At Beginning \n"); printf("3.Delete Node At End \n"); printf("4.Delete Node At Any position \n"); printf("5.Display \n"); printf("6.exit \n"); scanf("%d",&n); switch(n) { case 1:{ add_Element(getvalue()); break; } case 2:{ deleteFirstNode(); break; } case 3:{ deleteLastNode(); break; } case 4:{ int pos; printf("Enter the position to delete:\n"); scanf("%d",&pos); deleteAtPosition(pos); break; } case 5:{ display_Traversing(); break; } case 6: exit(1); default: printf("Wrong Input!!!\n"); } printf("\n\n"); } }
main() { TestStruct* root = NULL; int number, i = 0; printf("Please enter the list of number!\n"); while(1){ printf("Number #%d\n", ++i); scanf("%d", &number); while(getchar() != '\n'); if(number == 0) break; insertTop(&root, number); } printf("Before deleting\n"); printLinkList(root); deleteLastNode(&root); printf("After deleting\n"); printLinkList(root); }
int main(void) { setvbuf(stdout, NULL, _IONBF, 0); Header head; head.head = NULL; head.tail = NULL; head.nodeCount = 0; int menu = 0, list = 0; do { do { system("cls"); printf("\n Manipular qual lista.\n"); printf("1 - Encadeada.\n"); printf("2 - Sequencial.\n"); scanf("%d", &list); system("cls"); } while (list != 1 && list != 2); system("cls"); printf("\n Digite o numero da opcao desejada.\n"); printf("1 - Inserir elemento no final da lista.\n"); printf("2 - Inserir elemento no inicio da lista.\n"); printf("3 - Remover elemento a partir de um valor.\n"); printf("4 - Imprimir a lista.\n"); printf("5 - Inserir na posicao N.\n"); printf("6 - Remover ultimo da lista.\n"); printf("7 - Remover primeiro da lista.\n"); printf("8 - Remover elemento na posicao N.\n"); printf("9 - Carregar lista do arquivo.\n"); printf("10 - Salvar lista atual em arquivo.\n"); printf("11 - Inserction.\n"); printf("12 - Selection.\n"); printf("13 - Bubble.\n"); printf("14 - Shell.\n"); printf("15 - Quick.\n"); printf("16 - Merge.\n"); printf("17 - Busca Binaria.\n"); printf("18 - Busca Seq.\n"); printf("20 - Sair.\n"); scanf("%d", &menu); system("cls"); switch (menu) { case 1: if (list == 1) { insertNodeAtTheEnd(&head, getValue(), 1); reference(&head); } else { insertSeqAtTheEnd(getValue(), 1); } break; case 2: if (list == 1) { insertNodeAtStart(&head, getValue(), 1); reference(&head); } else { insertSeqAtStart(getValue(), 1); } break; case 3: if (list == 1) { deleteNodeByValue(&head); reference(&head); } else { deleteSeqByValue(); } break; case 4: if (list == 1) { printList(&head); } else { printSeq(); } break; case 5: if (list == 1) { insertAtN(&head, getValue(), getPosIns(&head)); reference(&head); } else { insertSeqAtN(getValue(), getPosSeqIns()); } break; case 6: if (list == 1) { deleteLastNode(&head, 1); reference(&head); } else { deleteLastSeq(1); } break; case 7: if (list == 1) { deleteFirstNode(&head, 1); reference(&head); } else { deleteFirstSeq(1); } break; case 8: if (list == 1) { deleteNodeAtN(&head, getPosDel(&head)); reference(&head); } else { deleteSeqAtN(getPosSeqDel(), 1); } break; case 9: listOptions(&head, list); break; case 10: if (list == 1) { writeLinkedList(&head); } else { writeSequentialList(); } break; case 11: if (list == 1) { linkedInserctionSort(&head); } else { inserctionSort(); } break; case 12: if (list == 1) { linkedSelectionSort(&head); } else { selectionSort(); } ; break; case 13: if (list == 1) { linkedBubbleSort(&head); } else { bubbleSort(); } break; case 14: if (list == 1) { linkedShellSort(&head); } else { shellSort(); } break; case 15: if (list == 1) { linkedCallQuickSort(&head); } else { callQuickSort(); } break; case 16: if (list == 1) { linkedCallMergeSort(head.nodeCount); } else { callMergeSort(); } break; case 17: if (list == 1) { linkedCallBynarySearch(&head); } else { callBynarySearch(); } break; case 18: if (list == 1) { searchNodeByValue(&head); } else { searchByValue(); } break; } } while (menu != 20); wipeList(&head); return EXIT_SUCCESS; }