void evaluate_beagle_instances_proposal (proposal_fmt * proposal, node * mother, node * newdaughter, long newdaughter_id, long newdaughter_bid, MYREAL v) { node *nn = NULL, *d1 = NULL, *d2 = NULL, *oldnn = NULL; if (mother->type != 'r') { children (mother, &d1, &d2); if (d1 == newdaughter) { d1 = d2; } long id0, id1, id2; long bid1, bid2; double v1, v2; id0 = mother->id; id1 = new_id(newdaughter_id, proposal->world->sumtips); bid1 = newdaughter_bid; v1 = v; id2 = d1->id; bid2 = d1->bid; v2 = d1->v; prepare_beagle_instances_proposal(proposal, id0, id1, bid1, v1, id2, bid2, v2, proposal->world->beagle); oldnn = mother; nn = showtop (crawlback (mother)); while (nn->type != 'r') { children (nn, &d1, &d2); if (d1 == oldnn) { d1 = d2; d2 = oldnn; } if(d2->id != oldnn->id) { warning("One of the children is not what it should be\n"); } id0 = nn->id; id1 = new_id(d2->id,proposal->world->sumtips);; bid1 = d2->bid; v1 = d2->v; id2 = d1->id; bid2 = d1->bid; v2 = d1->v; prepare_beagle_instances_proposal(proposal, id0, id1, bid1, v1, id2, bid2, v2, proposal->world->beagle); oldnn = nn; nn = showtop (crawlback (nn)); } } }
void set_beagle_dirty(node *origin, node *target, node *mrca) { node *nn = origin; while((nn=showtop(crawlback(nn)))!=mrca) { set_dirty(nn); } nn = target; while((nn=showtop(crawlback(nn)))!=mrca) { set_dirty(nn); } }
int main(int argc, char *argv[]) { int r, c, s = 0, orig; init(&r); while((c=getopt(argc, argv, "s:")) != EOF) { switch(c) { case 's': s = atoi(optarg); break; default: fprintf(stderr, "Usage: %s [-s<secdelay>]\n", argv[0]); return 1; } } if(s < 1) s = 2; /* Catch window size changes so display is updated properly right away. */ signal(SIGWINCH, sigwinch); while(1) { fd_set fds; int ns; struct timeval tv; showtop(r); tv.tv_sec = s; tv.tv_usec = 0; FD_ZERO(&fds); FD_SET(STDIN_FILENO, &fds); if((ns=select(STDIN_FILENO+1, &fds, NULL, NULL, &tv)) < 0 && errno != EINTR) { perror("select"); sleep(1); } if(ns > 0 && FD_ISSET(STDIN_FILENO, &fds)) { char c; if(read(STDIN_FILENO, &c, 1) == 1) { switch(c) { case 'q': return 0; break; } } } } return 0; }
int main() { top=NULL; int f=0; /*Flag to return process status*/ int c,d,v; printf("Options ::\n1.Push\n2.Pop\n3.View top element\n4.Display Stack\n"); do { label: printf("Enter choice : "); scanf("%d",&c); switch(c) { case 1 : printf("Enter element : "); scanf("%d",&v); push(v,&f); if(!f) printf("Overflow !!\n"); break; case 2 : v=pop(&f); if(f) printf("Deleted Element: %d\n",v); else printf("Underflow !!\n"); break; case 3 : v=showtop(&f); if(f) printf("Top Element : %d\n",v); else printf("Empty stack !!\n"); break; case 4 : display(); break; default: printf("\nInvalid Entry..Please try again..\n\n"); goto label; }; printf("\n"); printf("Do you want to again perform any of the tasks, if yes press '1' else press any other key : "); scanf("%d",&d); }while(d==1); getch(); }
int detailset::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: showtop((*reinterpret_cast< int(*)>(_a[1]))); break; case 1: showcpu((*reinterpret_cast< int(*)>(_a[1]))); break; case 2: showmem((*reinterpret_cast< int(*)>(_a[1]))); break; case 3: slotshowtop((*reinterpret_cast< int(*)>(_a[1]))); break; case 4: slotshowcpu((*reinterpret_cast< int(*)>(_a[1]))); break; case 5: slotshowmem((*reinterpret_cast< int(*)>(_a[1]))); break; case 6: slotOK(); break; case 7: slotAbout(); break; case 8: slotQuit(); break; default: ; } _id -= 9; } return _id; }
int main(int argc, char *argv[]) { int r, c, s = 0; int cputimemode = 1; /* bitmap. */ if (chdir(_PATH_PROC) != 0) { perror("chdir to " _PATH_PROC); return 1; } system_hz = (u32_t) sysconf(_SC_CLK_TCK); getkinfo(); init(&r); while((c=getopt(argc, argv, "s:B")) != EOF) { switch(c) { case 's': s = atoi(optarg); break; case 'B': blockedverbose = 1; break; default: fprintf(stderr, "Usage: %s [-s<secdelay>] [-B]\n", argv[0]); return 1; } } if(s < 1) s = 2; /* Catch window size changes so display is updated properly * right away. */ signal(SIGWINCH, sigwinch); while(1) { fd_set fds; int ns; struct timeval tv; showtop(cputimemode, r); tv.tv_sec = s; tv.tv_usec = 0; FD_ZERO(&fds); FD_SET(STDIN_FILENO, &fds); if((ns=select(STDIN_FILENO+1, &fds, NULL, NULL, &tv)) < 0 && errno != EINTR) { perror("select"); sleep(1); } if(ns > 0 && FD_ISSET(STDIN_FILENO, &fds)) { char c; if(read(STDIN_FILENO, &c, 1) == 1) { switch(c) { case 'q': putchar('\r'); return 0; break; case 'o': order++; if(order > ORDER_HIGHEST) order = 0; break; case TIMECYCLEKEY: cputimemode++; if(cputimemode >= (1L << CPUTIMENAMES)) cputimemode = 1; break; } } } } return 0; }