// data access void referenceData(long long int address){ long long int setNumber = getBits(address, nIndexBits, nBlockBits); long long int tag = getBits(address, 64 - nIndexBits - nBlockBits, nIndexBits + nBlockBits); LINE *foundPos = posIn(tag, sets[setNumber]); //foundPos is position of corresponding line in cache // if address in in the cache if (foundPos != NULL){ //hit hit++; long long int tempTag = foundPos->tag; removeLine(foundPos, sets[setNumber]); append(tempTag, sets[setNumber]); } else { // miss miss++; // if the cache is full then we need eviction by remove found line and append new address if (sets[setNumber]->numLines == nLines) { // eviction eviction++; removeLine(sets[setNumber]->firstLine, sets[setNumber]); append(tag, sets[setNumber]); } else { sets[setNumber]->numLines++; append(tag, sets[setNumber]); } } }
QPixmap GridRemoval::remove (const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const QImage &imageBefore) { LOG4CPP_INFO_S ((*mainCat)) << "GridRemoval::remove" << " transformationIsDefined=" << (transformation.transformIsDefined() ? "true" : "false") << " removeDefinedGridLines=" << (modelGridRemoval.removeDefinedGridLines() ? "true" : "false"); QImage image = imageBefore; // Make sure grid line removal is wanted, and possible. Otherwise all processing is skipped if (modelGridRemoval.removeDefinedGridLines() && transformation.transformIsDefined()) { double yGraphMin = modelGridRemoval.startY(); double yGraphMax = modelGridRemoval.stopY(); for (int i = 0; i < modelGridRemoval.countX(); i++) { double xGraph = modelGridRemoval.startX() + i * modelGridRemoval.stepX(); // Convert line between graph coordinates (xGraph,yGraphMin) and (xGraph,yGraphMax) to screen coordinates QPointF posScreenMin, posScreenMax; transformation.transformRawGraphToScreen (QPointF (xGraph, yGraphMin), posScreenMin); transformation.transformRawGraphToScreen (QPointF (xGraph, yGraphMax), posScreenMax); removeLine (posScreenMin, posScreenMax, image); } double xGraphMin = modelGridRemoval.startX(); double xGraphMax = modelGridRemoval.stopX(); for (int j = 0; j < modelGridRemoval.countY(); j++) { double yGraph = modelGridRemoval.startY() + j * modelGridRemoval.stepY(); // Convert line between graph coordinates (xGraphMin,yGraph) and (xGraphMax,yGraph) to screen coordinates QPointF posScreenMin, posScreenMax; transformation.transformRawGraphToScreen (QPointF (xGraphMin, yGraph), posScreenMin); transformation.transformRawGraphToScreen (QPointF (xGraphMax, yGraph), posScreenMax); removeLine (posScreenMin, posScreenMax, image); } } return QPixmap::fromImage (image); }
void Tank::removeCompleteLine(int& rowsLeft, int& score){ int lineStreak = 0; for (int row = m_height - 2; row >= 0; row--){ bool isCompleted = true; for (int col = 1; col < m_width - 1; col++){ if (m_tankData[row][col] == 0){ isCompleted = false; break; } } if (isCompleted){ removeLine(row); // This is crucial. if you vaporize one row, you need to update row again. row++; lineStreak++; } } if (lineStreak > 0){ score += myPow(2, lineStreak - 1) * 100; rowsLeft -= lineStreak; if (rowsLeft < 0) rowsLeft = 0; } }
void DatenPunkt::deleteLine()//löscht alle verbindungen { for(int i = 0 ; i < this->line.length();i++){ this->line[i]->hide(); } line.clear(); this->m_lineIsSet=false; emit removeLine(this->connectedItem); }
void Connection::startCon(OutputGiver* o) { out = o; //rem old, if it exist //out->remLine(); if(out->line!=NULL) removeLine(out->line); outpos = out->getPos(); outpos.x+=outpos.w/2; outpos.y+=outpos.h/2; give = true; }
int addLine(struct confModules *cf, char *line, int flags) { int x; if (flags & CM_REPLACE || flags & CM_COMMENT) removeLine(cf,line,flags); for (x=0;x<cf->numlines && cf->lines[x];x++); if (x!=cf->numlines) cf->lines[x]=line; else { cf->numlines++; cf->lines = realloc(cf->lines,(cf->numlines)*sizeof(char *)); cf->lines[cf->numlines-1] = strdup(line); } return 0; }
void Field::CheckLines() { std::set<int> linesToRemove; // We need to sort the lines so that they are removed from top to bottom std::map<int, int> blocksInLine; for (const auto& block : blocks_) { if (++blocksInLine[block.getY()] == width_) { linesToRemove.insert(block.getY()); } } linesCleared = linesToRemove.size(); score_ += linesCleared * linesCleared * (level_ + 1) * (level_ + 1); // Remove lines from top to bottom so that explosions will be placed correctly auto rend = linesToRemove.rend(); for (auto it = linesToRemove.rbegin(); it != rend; ++it) { removeLine(*it, static_cast<int>(linesToRemove.size())); } }
void MapViewer::updateViewer(bool isForward) { if ( isForward ) { if (actionData[currentRecord]){ addMarker(currentRecord); } currentRecord != 0 ? addLine(currentRecord) : removeAllLines(); } else { if (actionData[currentRecord]){ removeMarker(currentRecord); } currentRecord != recordCounter - 1 ? removeLine(currentRecord) : addAllLines(); } }
void Field::removeLine(const int y, const int numberOfLines) { auto end = blocks_.end(); for (auto it = blocks_.begin(); it != end; ++it) { if (it->getY() == y) { explosions_.push_back(Explosion(*it, numberOfLines)); blocks_.erase(it); return removeLine(y, numberOfLines); } } for (auto it = blocks_.begin(); it != end; ++it) { if (it->getY() > y) { it->setY(it->getY() - 1); it->setAnimationY(it->getAnimationY() + 1); } } ++lines_; --maxY_; }
void Connection::finishCon(InputTaker* i) { in=i; //must remove line already going into this input, IF it exist //in->remLine(); if(in->line!=NULL) removeLine(in->line); //make the actual Value** connection in->setInput(out); inpos = in->getPos(); inpos.x+=inpos.w/2; inpos.y+=inpos.h/2; LineData* line = saveLine(); //use this new line(when comps move they update line) in->setLine(line); out->setLine(line); reset(); }
bool KileScriptDocument::removeLine() { return removeLine( m_view->cursorPosition().line() ); }
void PRawRows::observeRemoveLine(size_t r, size_t ct) { emit removeLine(r, ct); }
//controll the program navigation void Soccer_league::start(string str) { while(!str.substr(0,1).compare(" ")) str=str.substr(1,str.length()); if (str.length()<1)return; //if there is a user file to read and he inserted before lunce the program //getting the next action/request fron the user inputerror: //getline(cin,str); //real input because i change it to lower case and without spaces string realInput = str; /*all the matches will be without spaces and with lower case*/ str.erase( std::remove(str.begin(),str.end(),' '), str.end() ); std::transform(str.begin(), str.end(), str.begin(), ::tolower); //check if str starts with '.' it should be a regex if (str.substr(0,1).compare(".")==0||str.substr(0,1).compare(",")==0||str.substr(0,1).compare("/")==0) { goto inputerror; } if (str.compare("help")==0) { } // statments if (str.compare("showleague")==0) { printLeagueTabel(_team); } //display the team names else if (str.compare("showteams")==0) { cout<<"Team Name"<<endl; cout<<"-----------"<<endl; for (int i=0 ; i< _team.size();i++) { cout<<_team[i]->get_teamName()<<endl; } } //display a specific game else if (str.substr(0,4).compare("show")==0 && (str.length()-4)>=2 && realInput.substr(0,5).compare("show ")==0 && realInput.substr(0,5).compare("Show ")==0) { //split the string into 2 parts each one of then is a team name str = str.substr(4,str.length()); int locationInLine=0; string splited,home,guest; for (int i=0 ; i < realInput.length(); i++) { string temp = realInput.substr(i,1); if (realInput.length()>(i+4) && realInput.at(i)==' ' && realInput.at(i+1)=='-' && realInput.at(i+2)==' ') { home=splited; locationInLine+=i+3; guest=realInput.substr(locationInLine,realInput.length()); splited.clear(); break; } splited.append(temp); } home = home.substr(5,home.length()-1); //search the requested game in reverse order to get the latest game for (int i=_game.size()-1; i >= 0 ; i--) { if (home.compare(_game[i]->get_home())==0 && guest.compare(_game[i]->get_guest().substr(0,(_game[i]->get_guest().length())))==0) { cout<<getGameDetails(i,_game)<<endl; break; } } } //check if we have date elements like . , / and it start with game namber else if (str.find("game")!= std::string::npos&&(str.find(".")!= std::string::npos || str.find(",")!= std::string::npos || str.find("/")!= std::string::npos)) { //delete the word 'game' from the input string and keep only the number int gameNumber=0; if(str.substr(5,6).compare(",") || str.substr(5,6).compare(".")) gameNumber = atoi(str.substr(4,5).c_str()); string strGame=str.substr(6,str.length()); //finally check if the input is date Date* date = (checkDate(strGame)); for (int i=0; i< _game.size(); i++) { Date* d = _game[i]->get_date(); if (*d==*date && _game[i]->get_round() == gameNumber) { //display the asks games cout<<getGameDetails(i,_game)<<endl; } } cout<<endl; } //access allow only if you are the manager if (str.substr(0,5).compare("admin")==0) { //remove the admin word from the beginning and keep the left string string strAdmin = str.substr(5,str.length()); if (strAdmin.substr(0,7).compare("addgame")==0) { //close the ream registeration if(_isOpen==1 ) { _dateBase->get_file()<<("START")<<endl; _dateBase->get_file()<<("END")<<endl; _isOpen=0; } int location= realInput.find("game"); string newGame = realInput.substr(location+4,realInput.length()); //check if the game is correct by names and game number and act. addGame(newGame,_dateBase->get_file(),_game); //_game.push_back(new Game(newGame)); //writeToFileinTheEnd(newGame); interpretGamesToTeamsStatus(_team,_game.at(_game.size()-1)); string output = "user add a new game "; output+=newGame; writeToOUTPUTfile(output,_dateBase->get_output()); } //register teams if (strAdmin.substr(0,13).compare("registerteams")==0) { if(_isOpen==1) { string newTeam;int check=1; vector<string> vec; //save my list in vector to comper with the input string for (int i=0;i<_team.size();i++) { vec.push_back(_team[i]->get_teamName()); } //cout<<"insert team names: "<<endl; //check is the inset team is not exist and exit when ; insert while (!newTeam.compare(";")==0) { getline (cin,newTeam); for (int i=0;i<vec.size();i++) { if(newTeam.compare(vec[i])==0) { cout<<"team "<<newTeam<< " is already registered"<<endl; check=0; } } if (check==1 && !newTeam.compare(";")==0) { writeToFileinTheEnd(newTeam,_dateBase->get_file()); string output = "user add a new team "; output+=newTeam; writeToOUTPUTfile(output,_dateBase->get_output()); _team.push_back(new Team(newTeam)); } check=1; } cout<< "Teams was added"<<endl; } else { cout<<"cannot add new teams because the league is already started"<<endl; } } //update team name if (strAdmin.substr(0,17).compare("correctionreplace")==0) { int location = realInput.find("replace"); realInput = realInput.substr(location+8,realInput.length()); //seperate the old team name and new team name int locationInLine=0; string splited,oldTeam,newTeam; string temp = realInput; oldTeam = temp.substr(0,realInput.find("by")-1); newTeam = temp.substr(realInput.find("by ")+3,temp.length()); /*for (int i=0 ; i < realInput.length(); i++) { string temp = realInput.substr(i,1); if (realInput.length()>(i+4) && realInput.at(i)==' ' && realInput.at(i+1)=='-' && realInput.at(i+2)==' ') { oldTeam=splited; locationInLine+=i+3; newTeam=realInput.substr(locationInLine,realInput.length()); splited.clear(); break; } splited.append(temp); }*/ //update team name into the data base replace_line_in_file(oldTeam , newTeam, _dateBase->get_file(), _team , _game); string output = "user replace team name "; output+= oldTeam; output+=" to "; output+=newTeam; writeToOUTPUTfile(output,_dateBase->get_output()); //cout<< "Team name updated"<<endl; } if (strAdmin.substr(0,14).compare("correctiongame")==0) { strAdmin = strAdmin.substr(strAdmin.find("game")+4,strAdmin.length()); string gameNumber = strAdmin.substr(0,1); string sdate = strAdmin.substr(2,strAdmin.length()); Date* date = checkDate(strAdmin.substr(2,strAdmin.length())); updateGame(gameNumber, sdate,_dateBase->get_file(),_team,_game); } if (strAdmin.substr(0,16).compare("correctiondelete")==0) { if(_isOpen) { int location = realInput.find("delete"); string teamToRemove = realInput.substr(location+7,realInput.length()); removeLine(teamToRemove,_dateBase->get_file()); for (int i=0; i<_team.size();i++) { if (_team[i]->get_teamName().compare(teamToRemove)==0) { _team.erase(_team.begin()+i); string output = "user delete team "; output+= teamToRemove; writeToOUTPUTfile(output,_dateBase->get_output()); break; } } } else cout<<"cannot delete team because the league is already started"<<endl; } if (strAdmin.substr(0,10).compare("correction")==0 && strAdmin.find('-') != std::string::npos ) { realInput = realInput.substr(realInput.find("correction")+11,realInput.length()); int locationInLine=0; string splited,home,guest; string temp = realInput; for (int i=0 ; i < realInput.length(); i++) { string temp = realInput.substr(i,1); if (realInput.length()>(i+4) && realInput.at(i)==' ' && realInput.at(i+1)=='-' && realInput.at(i+2)==' ') { home=splited; locationInLine+=i+3; guest=realInput.substr(locationInLine,realInput.length()); splited.clear(); break; } splited.append(temp); } string score; for (int i=0 ; i < guest.length(); i++) { string temp = guest.substr(i,1); try{ if (guest.length()>(i+4) && atoi(temp.c_str())>0) { score = guest; guest=splited.substr(0,splited.length()-1); locationInLine+=i; score=score.substr(guest.length()+1,score.length()); splited.clear(); break; } } catch(exception e){}; splited.append(temp); } updateGameDetails(home,guest,score,_dateBase->get_file(),_team,_game); interpretGamesToTeamsStatus(_team,_game.at(_game.size()-1)); } } if (str.compare("exit")==0) { _dateBase->get_file().close(); return; } }
void Controller::deleteSelectedLines(){ for(CT::identifier_t line_id : to_be_removed) { removeLine(line_id); } }
int main(){ int option; do{ printMenuOptions(); scanf("%d",&option); switch(option) { case 0://Exit break; case 1://formula değerlendirme { printf("\nLutfen tablonun degeri giriniz :\n"); printf("\t \"default\" de girdiribilirsiniz :\n>"); scanf("%s",girdi); if(strcmp(girdi,"default")==0) strcpy(girdi,"4,3,10,34,37,=A1+B1+C1,40,17,34,=A2+B2+C2,=A1+A2,=B1+B2,=C1+C2,=D1+D2"); createTableFromString(girdi); calculateAndPrint(); printf("\n\n\n"); break; } case 2://satir ekleme { if(Height==MAX_ROWS){ printf("\nDaha fazla bir satir eklenmez, bir tane satir silerek yeni bir satir ekleyebilirsiniz"); break; } int newLineIndex; do{ printf("\nLutfen ekleyeceksin satir hangi satirdan sonra giriniz (0-%d) arasinda> ",Height); scanf("%d",&newLineIndex); if(newLineIndex>Height){ printf("\nSu kadar satirlar zaten yok, lutfen %d dan daha az degerler giriniz",Height); } if(newLineIndex<0){ printf("\nSifir yada sifirdan daha buyuk bir sayi giriniz."); } }while((newLineIndex>Height) || (newLineIndex<0)); //Bir satır okuyoruz kullancıdan char newLine[MAX_COLUMNS][MAX_CHARS] ; getLineContent(newLine); //okuduğumuz satır matrise ekliyoruz insertLine(inputTable,newLineIndex,newLine); //Bizim boyutlarımız güncelliyoruz Height++; //Yeniden hesaplıyoruz ve ekrende yazıyoruz calculateAndPrint(); break; } case 3://satir silme { int lineToRemoveIndex; do{ printf("\nLutfen sileceksiniz satirin indexi giriniz (1-%d) arasinda>",Height); scanf("%d",&lineToRemoveIndex); //lineToRemoveIndex--;//Because 0-based index if((lineToRemoveIndex>Height) || (lineToRemoveIndex<=0)){ printf("\nDogru bir satir indexi giriniz lutfen.\n"); } }while((lineToRemoveIndex>Height) || (lineToRemoveIndex<=0)); //Bu satır siliyoruz removeLine(inputTable, lineToRemoveIndex-1);//Because 0-based index //Boyutlarımız güncelliyoruz Height--; //Yeniden hesaplıyoruz ve ekrende yazıyoruz calculateAndPrint(); break; } case 4://Hucre degeri degiştirme { int i,j; //doğru bir hücre okuyacağız kadar yeni bir hücre yeri okuyoruz do{ readCoordinates(&i,&j); if((i>Height) || (i<0) || (j>Width) || (j<0)){ printf("\nBoyle bir hucre bulunmadi. Lutfen yeniden giriniz."); } }while((i>Height) || (i<0) || (j>Width) || (j<0)); char cell[MAX_CHARS]; printf("\nLutfen hucrenin yeni degeri giriniz>"); //Bu hücrenin değeri okuyoruz scanf("%s",cell); //doğru yerinde koyuyoruz strcpy( (*(inputTable+i))+j,cell); //Yeniden hesaplıyoruz ve ekrende yazıyoruz calculateAndPrint(); break; } case 5://Filterleme { int filter; printf("\nHangi sayi'ye gore filterleyeceksiniz>"); scanf("%d",&filter); printFilteredArray(filter); break; } } }while(option!=0);//Kullancı çıkma seçenek seçecek kadar bu menü yazıyoruz ve soruyoruz return 0; }
/* antlarr: KDE 4: make it const QString & */ int KEdit::doReplace(QString s_pattern, bool case_sensitive, bool wildcard, bool forward, int line, int col, bool replace_all){ (void) wildcard; // reserved for possible extension to regex int line_counter, length; int pos = -1; QString string; QString stringnew; QString replacement; replacement = replace_dialog->getReplaceText(); line_counter = line; replace_all_col = col; if(forward){ int num_lines = numLines(); while (line_counter < num_lines){ string = textLine(line_counter); if (replace_all){ pos = string.find(s_pattern, replace_all_col, case_sensitive); } else{ pos = string.find(s_pattern, line_counter == line ? col : 0, case_sensitive); } if (pos == -1 ){ line_counter++; replace_all_col = 0; replace_all_line = line_counter; } if( pos != -1){ length = s_pattern.length(); if(replace_all){ // automatic stringnew = string.copy(); do { stringnew.replace(pos,length,replacement); replace_all_col = pos + replacement.length(); replace_all_line = line_counter; pos = stringnew.find(s_pattern, replace_all_col, case_sensitive); } while( pos != -1); removeLine(line_counter); insertLine(stringnew,line_counter); setModified(true); } else{ // interactive setCursorPosition( line_counter , pos, false ); for(int l = 0 ; l < length; l++){ cursorRight(true); } setCursorPosition( line_counter , pos + length, true ); pattern = s_pattern; last_replace = FORWARD; can_replace = true; return 1; } } } } else{ // searching backwards while(line_counter >= 0){ string = textLine(line_counter); int line_length = string.length(); if( replace_all ){ if (replace_all_col < 0) pos = -1; else pos = string.findRev(s_pattern, replace_all_col , case_sensitive); } else{ if ((line == line_counter) && (col < 0)) pos = -1; else pos = string.findRev(s_pattern, line == line_counter ? col : line_length , case_sensitive); } if (pos == -1 ){ line_counter--; replace_all_col = 0; if(line_counter >= 0){ string = textLine(line_counter); replace_all_col = string.length(); } replace_all_line = line_counter; } if (pos != -1){ length = s_pattern.length(); if(replace_all){ // automatic stringnew = string.copy(); stringnew.replace(pos,length,replacement); removeLine(line_counter); insertLine(stringnew,line_counter); replace_all_col = pos-length; replace_all_line = line_counter; if (replace_all_col < 0) { line_counter--; if(line_counter >= 0){ string = textLine(line_counter); replace_all_col = string.length(); } replace_all_line = line_counter; } setModified(true); } else{ // interactive // printf("line_counter %d pos %d col %d\n",line_counter, pos,col); if( ! (line == line_counter && pos > col ) ){ setCursorPosition(line_counter, pos + length ,false ); for(int l = 0 ; l < length; l++){ cursorLeft(true); } setCursorPosition(line_counter, pos ,true ); pattern = s_pattern; last_replace = BACKWARD; can_replace = true; return 1; } } } } } return 0; }