int main() { int32_t N = 1<<10; int32_t M = 19; int32_t result = insertInto(M, N, 2, 6); printf("Result: %s\n", ulongToBin(result)); return 0; }
void insertInto() { int x=10; int countlist=0; int index; int countbefore=1; int countafter=0; struct node *temp; struct node *current; struct node *before; while(x<0||x>9) //accepts only the values between 0-9 { printf("Enter the number to be inserted: "); scanf("%d",&x); } current=head; while(current->next!=NULL) //count the number of list { current=current->next; countlist++; } index=countlist+1; while(index>countlist) //asks again if the inputted index is out of bounds { printf("Index: "); scanf("%d",&index); } temp=(struct node*)malloc(sizeof(struct node)); if(temp) { temp->data=x; temp->next=NULL; } else { printf("Failed to allocate a memory."); insertInto(); } before=head; while(countbefore<index) { before=before->next; countbefore++; } current=head; while(countafter<index) { current=current->next; countafter++; } before->next=temp; temp->next=current; }
LocationID *connectedLocations(GameView g, int *numLocations, LocationID from, PlayerID player, Round round, int road, int rail, int sea) { // Quick validity checks if (from < MIN_MAP_LOCATION || from > MAX_MAP_LOCATION) { return NULL; } if (player < 0 || player > 5) { return NULL; } if (player == PLAYER_DRACULA) { rail = 0; } // Create set to keep track of connected locations Set canVisit = newLocSet(); int railDistance = (round + player) % 4; /* Loop through each location connected to the starting place and add them to the canVisit list if the relevant transport type is legal */ VList currLoc = g->map->connections[from]; insertInto(canVisit, from); //insertInto(canVisit, currLoc->v); while(currLoc != NULL) { if (currLoc->type[ROAD-1] && road) { insertInto(canVisit, currLoc->v); } if (currLoc->type[RAIL-1] && rail && railDistance) { railTravel(g, railDistance, canVisit, currLoc->v); insertInto(canVisit, currLoc->v); } if (currLoc->type[BOAT-1] && sea) { insertInto(canVisit, currLoc->v); } currLoc = currLoc->next; } // Dracula can't visit the hospital if (player == PLAYER_DRACULA) { dropFrom(canVisit, ST_JOSEPH_AND_ST_MARYS); } showSet(canVisit); *numLocations = nElems(canVisit); return condensedSet(canVisit); }
virtual bool visit(UiObjectDefinition *ast) { if (didRewriting()) return false; if (ast->firstSourceLocation().offset == targetParentObjectLocation) insertInto(ast->initializer); return !didRewriting(); }
virtual bool visit(UiObjectBinding *ast) { if (didRewriting()) return false; if (ast->qualifiedTypeNameId->identifierToken.offset == targetParentObjectLocation) insertInto(ast->initializer); return !didRewriting(); }
unsigned int process_event_list(DataSet *terrain, GridPoint start, SweepEvent *event_list, size_t len, DataSet *vshed) { SweepEvent *eptr, *eend; RBTree *tree; TreeNode *node; TreeValue value; unsigned int count; double h0, h1; // retrieve height of start point gpHeight(terrain, start, h0); // initialiaze tree value.key = 0; value.gradient = SMALLEST_GRADIENT; tree = createTree(value); // process list count = 0; eptr = event_list; eend = event_list + len; while (eptr < eend) { if (eptr->event == ENTER_EVENT) { // set key to node distance value.key = eptr->dist; // calculate slope in z gpHeight(terrain, eptr->p, h1); value.gradient = (h1 - h0) / eptr->dist; // insert the node into the active list insertInto(tree, value); }else if (eptr->event == SIGHT_EVENT) { // check the active list if the current node is visible // query for the current node node = searchForNodeWithKey(tree, eptr->dist); assert(notNIL(node)); h1 = findMaxGradientWithinKey(tree, eptr->dist); if (vshed != NULL) dSet(vshed, eptr->p.r, eptr->p.c, (node->value.gradient >= h1)); count += (node->value.gradient >= h1); }else { // LEAVE_EVENT // remove the current node deleteFrom(tree, eptr->dist); } eptr++; } // garbage collect deleteTree(tree); return count; }
void savePixel(uint32_t threadNum, uint32_t x, uint32_t y, uint8_t red, uint8_t green, uint8_t blue) { if (fileMode) { writeToFile(threadNum, x, y, red, green, blue); } else { pixelListPtr pointPtr = createPixelElement(); pointPtr->x = x; pointPtr->y = y; pointPtr->red = red; pointPtr->green = green; pointPtr->blue = blue; insertInto(&pixelListHeads[threadNum], pointPtr); } }
// make a copy of all blocks and instructions in srcblocks // - map values to clones // - redirect srcTarget to continueWith // - set "funclet" attribute inside catch/cleanup pads // - inside funclets, replace "unreachable" with "branch cleanupret" void cloneBlocks(const std::vector<llvm::BasicBlock *> &srcblocks, std::vector<llvm::BasicBlock *> &blocks, llvm::BasicBlock *continueWith, llvm::BasicBlock *unwindTo, llvm::Value *funclet) { llvm::ValueToValueMapTy VMap; // map the terminal branch to the new target if (continueWith) if (auto term = srcblocks.back()->getTerminator()) if (auto succ = term->getSuccessor(0)) VMap[succ] = continueWith; for (auto bb : srcblocks) { llvm::Function *F = bb->getParent(); auto nbb = llvm::BasicBlock::Create(bb->getContext(), bb->getName()); // Loop over all instructions, and copy them over. for (auto &II : *bb) { llvm::Instruction *Inst = &II; llvm::Instruction *newInst = nullptr; if (funclet && !llvm::isa<llvm::DbgInfoIntrinsic>(Inst)) { // IntrinsicInst? if (auto IInst = llvm::dyn_cast<llvm::InvokeInst>(Inst)) { auto invoke = llvm::InvokeInst::Create( IInst, llvm::OperandBundleDef("funclet", funclet)); newInst = invoke; } else if (auto CInst = llvm::dyn_cast<llvm::CallInst>(Inst)) { auto call = llvm::CallInst::Create( CInst, llvm::OperandBundleDef("funclet", funclet)); newInst = call; } else if (funclet && llvm::isa<llvm::UnreachableInst>(Inst)) { newInst = llvm::BranchInst::Create(continueWith); // to cleanupret } } if (!newInst) newInst = Inst->clone(); nbb->getInstList().push_back(newInst); VMap[Inst] = newInst; // Add instruction map to value. if (unwindTo) if (auto dest = getUnwindDest(Inst)) VMap[dest] = unwindTo; } nbb->insertInto(F, continueWith); VMap[bb] = nbb; blocks.push_back(nbb); } remapBlocks(blocks, VMap); }
UEFITool::UEFITool(QWidget *parent) : QMainWindow(parent), ui(new Ui::UEFITool), version(tr("0.18.7")) { clipboard = QApplication::clipboard(); // Create UI ui->setupUi(this); searchDialog = new SearchDialog(this); ffsEngine = NULL; // Set window title this->setWindowTitle(tr("UEFITool %1").arg(version)); // Connect signals to slots connect(ui->actionOpenImageFile, SIGNAL(triggered()), this, SLOT(openImageFile())); connect(ui->actionSaveImageFile, SIGNAL(triggered()), this, SLOT(saveImageFile())); connect(ui->actionSearch, SIGNAL(triggered()), this, SLOT(search())); connect(ui->actionExtract, SIGNAL(triggered()), this, SLOT(extractAsIs())); connect(ui->actionExtractBody, SIGNAL(triggered()), this, SLOT(extractBody())); connect(ui->actionInsertInto, SIGNAL(triggered()), this, SLOT(insertInto())); connect(ui->actionInsertBefore, SIGNAL(triggered()), this, SLOT(insertBefore())); connect(ui->actionInsertAfter, SIGNAL(triggered()), this, SLOT(insertAfter())); connect(ui->actionReplace, SIGNAL(triggered()), this, SLOT(replaceAsIs())); connect(ui->actionReplaceBody, SIGNAL(triggered()), this, SLOT(replaceBody())); connect(ui->actionRemove, SIGNAL(triggered()), this, SLOT(remove())); connect(ui->actionRebuild, SIGNAL(triggered()), this, SLOT(rebuild())); connect(ui->actionMessagesCopy, SIGNAL(triggered()), this, SLOT(copyMessage())); connect(ui->actionMessagesCopyAll, SIGNAL(triggered()), this, SLOT(copyAllMessages())); connect(ui->actionMessagesClear, SIGNAL(triggered()), this, SLOT(clearMessages())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about())); connect(ui->actionAboutQt, SIGNAL(triggered()), this, SLOT(aboutQt())); connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(exit())); connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(writeSettings())); // Enable Drag-and-Drop actions this->setAcceptDrops(true); // Set current directory currentDir = "."; // Initialize non-persistent data init(); // Read stored settings readSettings(); }
// railTravel // Recursive/Depth first search algorithm to add rail connections within range // to the canVisit set... static void railTravel(GameView g, int dist, Set canVisit, LocationID city) { VList currLoc = g->map->connections[city]; if(dist <= 0) { return; } insertInto(canVisit, city); while(currLoc != NULL) { //showConnections(g->map, currLoc->v, RAIL-1); if(currLoc->type[RAIL-1]) { railTravel(g, dist-1, canVisit, currLoc->v); //currLoc = currLoc->next; } currLoc = currLoc->next; } }
int main(int argc, char **argv) { int N = (argc < 2) ? 20 : atoi(argv[1]); if (N < 20) N = 20; Set s; s = newSet(); int i; char x[50]; for (i = 0; i < N; i++) { randomString(x); insertInto(s,x); printf("Insert %s\n",x); showSet(s); } disposeSet(s); return 0; }
void askUser() { int num; int x=10; int i; char choices; system("cls"); printf("\n[1]-DISPLAY ARRAY\n[2]-INSERT REAR\n[3]-INSERT FRONT\n[4]-INSERT INTO\n[5]-DELETE FRONT\n[6]-DELETE REAR\n[7]-DELETE ITEM\n[8]-DELETE ALL ITEM\n[9]-MAKE UNIQUE\n"); choices=getch(); switch(choices) { case '1': displayArray(); getch(); askUser(); break; case '2': num=askNum(); for(i=0;i<num;i++) { while(x<0||x>9) { printf("Enter number: "); scanf("%d",&x); } insertRear(x); x=10; displayArray(); } getch(); askUser(); break; case '3': num=askNum(); for(i=0;i<num;i++) { while(x<0||x>9) { printf("Enter number: "); scanf("%d",&x); } insertFront(x); x=10; displayArray(); } getch(); askUser(); break; case '4': displayArray(); insertInto(); displayArray(); getch(); askUser(); break; case '5': deleteFront(); displayArray(); getch(); askUser(); break; case '6': deleteRear(); displayArray(); getch(); askUser(); break; case '7': displayArray(); deleteItem(); displayArray(); getch(); askUser(); break; case '8': displayArray(); deleteAllItem(); displayArray(); getch(); askUser(); break; case '9': displayArray(); makeUnique(); displayArray(); getch(); askUser(); break; default: getch(); break; } }
UEFITool::UEFITool(QWidget *parent) : QMainWindow(parent), ui(new Ui::UEFITool), version(tr("0.20.4")) { clipboard = QApplication::clipboard(); // Create UI ui->setupUi(this); searchDialog = new SearchDialog(this); ffsEngine = NULL; // Set window title this->setWindowTitle(tr("UEFITool %1").arg(version)); // Connect signals to slots connect(ui->actionOpenImageFile, SIGNAL(triggered()), this, SLOT(openImageFile())); connect(ui->actionSaveImageFile, SIGNAL(triggered()), this, SLOT(saveImageFile())); connect(ui->actionSearch, SIGNAL(triggered()), this, SLOT(search())); connect(ui->actionExtract, SIGNAL(triggered()), this, SLOT(extractAsIs())); connect(ui->actionExtractBody, SIGNAL(triggered()), this, SLOT(extractBody())); connect(ui->actionInsertInto, SIGNAL(triggered()), this, SLOT(insertInto())); connect(ui->actionInsertBefore, SIGNAL(triggered()), this, SLOT(insertBefore())); connect(ui->actionInsertAfter, SIGNAL(triggered()), this, SLOT(insertAfter())); connect(ui->actionReplace, SIGNAL(triggered()), this, SLOT(replaceAsIs())); connect(ui->actionReplaceBody, SIGNAL(triggered()), this, SLOT(replaceBody())); connect(ui->actionRemove, SIGNAL(triggered()), this, SLOT(remove())); connect(ui->actionRebuild, SIGNAL(triggered()), this, SLOT(rebuild())); connect(ui->actionMessagesCopy, SIGNAL(triggered()), this, SLOT(copyMessage())); connect(ui->actionMessagesCopyAll, SIGNAL(triggered()), this, SLOT(copyAllMessages())); connect(ui->actionMessagesClear, SIGNAL(triggered()), this, SLOT(clearMessages())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about())); connect(ui->actionAboutQt, SIGNAL(triggered()), this, SLOT(aboutQt())); connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(exit())); connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(writeSettings())); // Enable Drag-and-Drop actions this->setAcceptDrops(true); // Set current directory currentDir = "."; // Set monospace font for some controls QFont font("Courier New", 10); #if defined Q_OS_OSX font = QFont("Menlo", 10); #elif defined Q_OS_WIN font = QFont("Consolas", 9); #endif ui->infoEdit->setFont(font); ui->messageListWidget->setFont(font); ui->structureTreeView->setFont(font); searchDialog->ui->guidEdit->setFont(font); searchDialog->ui->hexEdit->setFont(font); // Initialize non-persistent data init(); // Read stored settings readSettings(); }