/* * Clear around the box for fancy_bce_test(). */ static void fancy_bce_erases(BOX *box) { int i; int first; int limit; cup(box->top - 1, min_cols / 2); ed(1); /* clear from home to cursor */ cuf(1); el(0); /* clear from cursor to end of line */ cup(box->bottom + 1, min_cols / 2); ed(0); /* clear from cursor to end */ cub(1); el(1); /* clear to beginning of line */ for (i = box->top; i <= box->bottom; i++) { cup(i, box->left - 1); el(1); cup(i, box->right + 1); limit = min_cols - box->right; first = i + 1 - box->top; if (first > limit) first = limit; dch(first); limit -= first; if (limit > 0) ech(limit); } }
std::vector<ExtraDim> ExtraBytesIf::toExtraDims() { std::vector<ExtraDim> eds; if (m_type == Dimension::Type::None) { ExtraDim ed(m_name, Dimension::Type::None); ed.m_size = m_size; eds.push_back(ed); } else if (m_fieldCnt == 1) { ExtraDim ed(m_name, m_type, m_scale[0], m_offset[0]); eds.push_back(ed); } else { for (size_t i = 0; i < m_fieldCnt; ++i) { ExtraDim ed(m_name + std::to_string(i), m_type, m_scale[i], m_offset[i]); eds.push_back(ed); } } return eds; }
void eval_stress(double *x, double *coord, int *ndim, int *edim, int *nobs, int *samplesize,double *stress) { int i; double dab,simab; int a = 0; int b = 0; long double denom = 0.0; long double numer = 0.0; GetRNGstate(); for (i = 0; i < *samplesize; i++) { get_indices(*nobs, &a, &b); dab = ed(x,a,b,*edim,*nobs); simab = ed(coord,a,b,*ndim,*nobs); denom += simab; numer += (dab - simab) * (dab - simab) / simab; } *stress = (double) (numer/denom); PutRNGstate(); return; }
int main(){ scanf("%d%d",&N,&Q); for(int i=0;i<N;++i){ ll a,b,c; scanf("%lld%lld%lld",&a,&b,&c); a=rev(a),b=rev(b); evts.emplace_back(st(a)+1,st(b)+1,ed(b),c); evts.emplace_back(ed(a),st(b)+1,ed(b),-c); } std::sort(all(evts)); for(int i=0;i<Q;++i){ ll a,b; scanf("%lld%lld",&a,&b); qrys.emplace_back(rev(a),rev(b),i); } std::sort(all(qrys)); int i=0; for(qry &q:qrys){ while(i<evts.size()&&evts[i].x<=q.x){ ins(rt,new nd(evts[i].y1,evts[i].v)); ins(rt,new nd(evts[i].y2,-evts[i].v)); ++i; } nd *l=0,*r=0; spt(rt,l,r,q.y); ans[q.i]=sum(l); mrg(rt,l,r); } for(int i=0;i<Q;printf("%lld\n",ans[i++])); }
int ed(char * str1, char*str2) { return min (ed (str+1, str2)+1, ed(str1, str2+1)+1); }
static int test_altscrn_1049(MENU_ARGS) { vt_move(1,1); println(the_title); vt_move(3,1); println("Test private setmode 1049 (to/from alternate screen)"); vt_move(4,1); println("The next screen will be filled with E's down to the prompt."); vt_move(5,1); println("unless titeInhibit resource is set, or alternate-screen is disabled."); vt_move(7,5); decsc(); vt_move(max_lines-2,1); holdit(); /* cursor location will be one line down */ sm("?1049"); /* this saves the cursor location */ decaln(); /* fill the screen */ vt_move(max_lines-2,1); ed(0); holdit(); rm("?1049"); decrc(); check_rc(max_lines-1,1); vt_move(4,1); el(2); println("The original screen should be restored except for this line"); vt_move(max_lines-2,1); return MENU_HOLD; }
void ARCodeWidget::OnCodeEditPressed() { auto items = m_code_list->selectedItems(); if (items.empty()) return; const auto* selected = items[0]; auto& current_ar = m_ar_codes[m_code_list->row(selected)]; bool user_defined = current_ar.user_defined; ActionReplay::ARCode ar = current_ar; CheatCodeEditor ed(this); ed.SetARCode(user_defined ? ¤t_ar : &ar); ed.exec(); if (!user_defined) m_ar_codes.push_back(ar); SaveCodes(); UpdateList(); }
int triangular_distmatrix(double* coords, int natoms, int nframes, double co, long* out_mat) { int i = 0; int j = 0; int k = 0; // Initialize output matrix int out_mat_elemsn = natoms*(natoms-1)/2; //int* out_mat = (int*) malloc(out_mat_elemsn * sizeof(int)); for (i=0; i<out_mat_elemsn; i++) out_mat[i] = 0.0; int idx_j = 0; int idx_k = 0; for (i=0; i<nframes; i++) { for (j=0; j<natoms; j++) { idx_j = i*natoms*3 + j*3; for (k=0; k<j; k++) { idx_k = i*natoms*3 + k*3; //printf("%d %d: %.3f\n", j, k, ed(coords, coords, idx_j, idx_k)); if (ed(coords, coords, idx_j, idx_k) <= co) { out_mat[sqmI(natoms,j,k)] += 1; out_mat[sqmI(natoms,k,j)] += 1; } } } } return 1; }
int potential_distances(double* coords, int nsets, int set_size, int nframes, double* results) { int i = 0; int j = 0; int k = 0; int l = 0; int combinations[8] = {0, 2, 0, 3, 1, 2, 1, 3}; int natoms = nsets*set_size; int ncoords = natoms*3; int this_i = 0; int this_ij = 0; for (i=0; i<nframes; i++) { this_i = i*ncoords; for (j=0; j<nsets; j++) { this_ij = this_i + j*set_size*3; for (k=0; k<8; k+=2) { //printf ("%d %d -> %d\n", this_ij/3+combinations[k], this_ij/3+combinations[k+1], l); //printf ("%3f %3f %3f vs %3f %3f %3f\n", coords[this_ij+combinations[k]*3], coords[this_ij+combinations[k]*3+1], coords[this_ij+combinations[k]*3+2], coords[this_ij+combinations[k+1]*3], coords[this_ij+combinations[k+1]*3+1], coords[this_ij+combinations[k+1]*3+2]); //printf("%f\n", results[l]); results[l] = ed(coords, coords, this_ij+combinations[k]*3, this_ij+combinations[k+1]*3); l++; } } } return 1; }
void MainWindow::editMonth(QListWidgetItem * item) { int index = ui->monthList->row(item); qDebug(months[index].text().toLatin1()); EditMonth ed(months[index]); int result = ed.exec(); }
int main(object me, string file) { if (! SECURITY_D->valid_grant(me, "(apprentice)")) return 0; if (! file) return notify_fail("指令格式:edit <档名>\n"); if (in_edit(me)) return notify_fail("你已经在使用编辑器了。\n"); file = resolve_path(me->query("cwd"), file); foreach (object user in users()) if (file == in_edit(user)) return notify_fail(HIM "共享冲突:" + user->name(1) + HIM "(" + capitalize(user->query("id")) + ")" + HIM "正在编辑该文件(" + file + ")。\n" NOR); printf("编辑文件:%s\n", file); CHANNEL_D->do_channel(this_object(), "sys", sprintf("%s(%s)正在编辑文件(%s)。", me->name(1), capitalize(me->query("id")), file)); seteuid(geteuid(me)); me->set("cwf", file); SECURITY_D->backup_file(file); ed(file); log_file("static/edit", sprintf("%s %-9s edit %s from %s.\n", log_time(), geteuid(me), file, query_ip_name(me))); return 1; }
static int test_altscrn_47(MENU_ARGS) { vt_move(1,1); println(the_title); vt_move(3,1); println("Test private setmode 47 (to/from alternate screen)"); vt_move(4,1); println("The next screen will be filled with E's down to the prompt."); vt_move(7,5); decsc(); vt_move(max_lines-2,1); holdit(); sm("?47"); decaln(); /* fill the screen */ vt_move(15,7); decsc(); vt_move(max_lines-2,1); ed(0); holdit(); rm("?47"); decrc(); check_rc(7,5); vt_move(4,1); el(2); println("The original screen should be restored except for this line."); vt_move(max_lines-2,1); return MENU_HOLD; }
void NixonPowerCell::hit(const df::EventCollision *p_collision_event) { if ((p_collision_event->getObject1()->getType() == "PlayerGunShot") || (p_collision_event->getObject2()->getType() == "PlayerGunShot")) { if (!was_hit) { health--; was_hit = true; has_flashed = false; hit_countdown = hit_slowdown; } } // If PlayerCannonShot or Player, create explosion and delete rock if ((p_collision_event->getObject1()->getType() == "PlayerCannonShot") || (p_collision_event->getObject2()->getType() == "PlayerCannonShot") || health <= 0) { df::WorldManager &world_manager = df::WorldManager::getInstance(); // Create an explosion. SmallExplosion *p_explosion = new SmallExplosion(getPosition()); // Play "explode" sound //Send Points for deletion df::EventView ev(SCORE_STRING, NIXONPOWERCELL_POINTS, true); world_manager.onEvent(&ev); //Send death event EventFootSoldierDeath ed(this); world_manager.onEvent(&ed); //Delete this object df::WorldManager::getInstance().markForDelete(this); } }
double rexp(double mean, boost::mt19937& rng) { double lambda = 1.0 / mean; boost::exponential_distribution<> ed(lambda); boost::variate_generator<boost::mt19937&, boost::exponential_distribution<> > var_exp(rng, ed); double val = var_exp(); return val; }
void Bindable::DelayedCheckManager::CompleteDelayedObsoleteChecks() { CDoubleListForwardIter<DelayedObsoleteCheckInfo> DelayedObsoleteChecks(&m_ListOfDelayedObsoleteChecks); while (DelayedObsoleteCheckInfo *DelayedCheck = DelayedObsoleteChecks.Next()) { bool performObsoleteCheck = true; if (DelayedCheck->m_ContextOfSymbolUsage !=NULL) { performObsoleteCheck = !ObsoleteChecker::IsObsoleteOrHasObsoleteContainer(DelayedCheck->m_ContextOfSymbolUsage, true); } if (performObsoleteCheck) { ObsoleteChecker::CheckObsoleteAfterEnsuringAttributesAre----ed( DelayedCheck->m_PossibleObsoleteSymbol, &DelayedCheck->m_LocationOfSymbolUsage, m_ContainerContext, DelayedCheck->m_ErrorLogToReportObsoleteError); } } }
void RS_ActionDrawEllipseFociPoint::trigger() { RS_PreviewActionInterface::trigger(); RS_EllipseData ed(center, major*d, sqrt(d*d-c*c)/d, 0., 0.,false); RS_Ellipse* ellipse = new RS_Ellipse(container, ed); ellipse->setLayerToActive(); ellipse->setPenToActive(); container->addEntity(ellipse); // upd. undo list: if (document!=NULL) { document->startUndoCycle(); document->addUndoable(ellipse); document->endUndoCycle(); } // RS_Vector rz = graphicView->getRelativeZero(); graphicView->moveRelativeZero(ellipse->getCenter()); graphicView->redraw(RS2::RedrawDrawing); drawSnapper(); setStatus(SetFocus1); RS_DEBUG->print("RS_ActionDrawEllipseFociPoint::trigger():" " entity added: %d", ellipse->getId()); }
void RS_ActionDrawEllipseFociPoint::mouseMoveEvent(QMouseEvent* e) { RS_DEBUG->print("RS_ActionDrawEllipseFociPoint::mouseMoveEvent begin"); RS_Vector mouse = snapPoint(e); switch (getStatus()) { case SetPoint: point=mouse; d=0.5*(focus1.distanceTo(point)+focus2.distanceTo(point)); if (d > c+ RS_TOLERANCE) { deletePreview(); RS_EllipseData ed(center, major*d, sqrt(d*d-c*c)/d, 0., 0.,false); preview->addEntity(new RS_Ellipse(preview.get(), ed)); drawPreview(); } break; default: break; } RS_DEBUG->print("RS_ActionDrawEllipseFociPoint::mouseMoveEvent end"); }
int main(){ row::create_map(); cout << "Start: " << endl; vector<row> v; for (int i = 0; i < 8; i++){ string str; cin >> str; v.push_back(row(str)); } state st(v); cout << "End: " << endl; v.clear(); for (int i = 0; i < 8; i++){ string str; cin >> str; v.push_back(row(str)); } state ed(v); auto ans = solve(st, ed); string ans_str = "LRDU"; for (direction d : ans) cout << ans_str[(int)d]; }
int square_distmatrix(double* coords1, double* coords2, int natoms1, int natoms2, int nframes, double co, long* out_mat) { // Initialize output matrix int out_mat_elemsn = natoms1 * natoms2; int i = 0; int j = 0; int k = 0; //int* out_mat = (int*) malloc(out_mat_elemsn * sizeof(int)); for (i=0; i<out_mat_elemsn; i++) out_mat[i] = 0.0; int idx_j = 0; int idx_k = 0; for (i=0; i<nframes; i++) { for (j=0; j<natoms1; j++) { for (k=0; k<natoms2; k++) { idx_j = i*natoms1 + j*3; idx_k = i*natoms2 + k*3; if (ed(coords1, coords2, idx_j, idx_k) <= co) { out_mat[sqmI(natoms1,j,k)] += 1; } } } } return 1; }
/** * search a meeting by username, time interval (user as sponsor or participator) * @param uesrName the user's userName * @param startDate time interval's start date * @param endDate time interval's end date * @return a meeting list result */ std::list<Meeting> AgendaService::meetingQuery(const std::string userName, const std::string startDate, const std::string endDate) const { std::list<Meeting> related_meetinglist; Date sd(startDate); Date ed(endDate); if(Date::isValid(sd) && Date::isValid(ed) && (sd<=ed)) { related_meetinglist = m_storage->queryMeeting([&](const Meeting& r_meeting)-> bool { if( r_meeting.getEndDate() >= sd && r_meeting.getStartDate() <= ed) { if(userName == r_meeting.getSponsor()) { return true; } if(r_meeting.isParticipator(userName)) { return true; } } return false; }); } return related_meetinglist; }
void Graph::Print() const { std::cout << "-----------------------------" << std::endl; std::cout << "vertices (" << m_nV << ")" << std::endl; for (size_t v = 0; v < m_vertices.size(); ++v) { const GraphVertex & currentVertex = m_vertices[v]; if (!m_vertices[v].m_deleted) { std::cout << currentVertex.m_name << "\t"; std::set<long>::const_iterator ed(currentVertex.m_edges.begin()); std::set<long>::const_iterator itEnd(currentVertex.m_edges.end()); for(; ed != itEnd; ++ed) { std::cout << "(" << m_edges[*ed].m_v1 << "," << m_edges[*ed].m_v2 << ") "; } std::cout << std::endl; } } std::cout << "vertices (" << m_nE << ")" << std::endl; for (size_t e = 0; e < m_edges.size(); ++e) { const GraphEdge & currentEdge = m_edges[e]; if (!m_edges[e].m_deleted) { std::cout << currentEdge.m_name << "\t(" << m_edges[e].m_v1 << "," << m_edges[e].m_v2 << ") "<< std::endl; } } }
void nsFormFillController::RemoveWindowListeners(nsIDOMWindow *aWindow) { if (!aWindow) return; StopControllingInput(); nsCOMPtr<nsIDOMDocument> domDoc; aWindow->GetDocument(getter_AddRefs(domDoc)); nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc); PwmgrInputsEnumData ed(this, doc); mPwmgrInputs.Enumerate(RemoveForDocumentEnumerator, &ed); nsCOMPtr<nsPIDOMWindow> privateDOMWindow(do_QueryInterface(aWindow)); nsIDOMEventTarget* target = nullptr; if (privateDOMWindow) target = privateDOMWindow->GetChromeEventHandler(); if (!target) return; target->RemoveEventListener(NS_LITERAL_STRING("focus"), this, true); target->RemoveEventListener(NS_LITERAL_STRING("blur"), this, true); target->RemoveEventListener(NS_LITERAL_STRING("pagehide"), this, true); target->RemoveEventListener(NS_LITERAL_STRING("mousedown"), this, true); target->RemoveEventListener(NS_LITERAL_STRING("input"), this, true); target->RemoveEventListener(NS_LITERAL_STRING("compositionstart"), this, true); target->RemoveEventListener(NS_LITERAL_STRING("compositionend"), this, true); target->RemoveEventListener(NS_LITERAL_STRING("contextmenu"), this, true); }
void QuenchFrame::OnCloseWindow(wxCloseEvent& event) { NButtonChoiceDialog ed(this, "Exiting Quench...","\n\nDo you want to save state information?\n","Save","Don't Save","Cancel"); bool bSaveDecisionMade = false; while (!bSaveDecisionMade) { int result = ed.ShowModal(); switch(result) { case BUTTON_CHOICE_1: // Save if(!DoSaveStateDialog()) continue; bSaveDecisionMade = true; remove(TEMP_QST_FILE_NAME); Destroy(); break; case BUTTON_CHOICE_2: // Don't Save bSaveDecisionMade = true; Destroy(); break; case BUTTON_CHOICE_3: // Cancel bSaveDecisionMade = true; event.Veto(); break; } } }
/* * This is our ray / bolt collision routine for now. * Basically, this is called on a ship unit to see if any ray or bolt given by some simple vectors collide with it * We should probably first check against shields and then against the colTree to see if we hit the shields first * Not sure yet if that would work though... more importantly, we might have to modify end in here in order * to tell calling code that the bolt should stop at a given point. */ Unit* Unit::rayCollide( const QVector &start, const QVector &end, Vector &norm, float &distance) { Unit *tmp; float rad = this->rSize(); if ( ( !SubUnits.empty() ) && graphicOptions.RecurseIntoSubUnitsOnCollision ) if ( ( tmp = *SubUnits.fastIterator() ) ) rad += tmp->rSize(); if ( !globQuerySphere( start, end, cumulative_transformation_matrix.p, rad ) ) return NULL; if (graphicOptions.RecurseIntoSubUnitsOnCollision) { if ( !SubUnits.empty() ) { un_fiter i( SubUnits.fastIterator() ); for (Unit *un; (un = *i); ++i) if ( ( tmp = un->rayCollide( start, end, norm, distance) ) != 0 ) return tmp; } } QVector st( InvTransform( cumulative_transformation_matrix, start ) ); QVector ed( InvTransform( cumulative_transformation_matrix, end ) ); static bool sphere_test = XMLSupport::parse_bool( vs_config->getVariable( "physics", "sphere_collision", "true" ) ); distance = querySphereNoRecurse( start, end ); if (distance > 0.0f || (this->colTrees&&this->colTrees->colTree( this, this->GetWarpVelocity() )&&!sphere_test)) { Vector coord; /* Set up points and ray to send to ray collider. */ Opcode::Point rayOrigin(st.i,st.j,st.k); Opcode::Point rayDirection(ed.i,ed.j,ed.k); Opcode::Ray boltbeam(rayOrigin,rayDirection); if(this->colTrees){ // Retrieve the correct scale'd collider from the unit's collide tree. csOPCODECollider *tmpCol = this->colTrees->colTree( this, this->GetWarpVelocity() ); QVector del(end-start); //Normalize(del); norm = ((start+del*distance)-Position()).Cast(); Normalize(norm); //RAY COLLIDE does not yet set normal, use that of the sphere center to current loc if (tmpCol==NULL) { return this; } if(tmpCol->rayCollide(boltbeam,norm,distance)){ // compute real distance distance = (end-start).Magnitude() * distance; // NOTE: Here is where we need to retrieve the point on the ray that we collided with the mesh, and set it to end, create the normal and set distance VSFileSystem::vs_dprintf(3,"Beam collide with %p, distance %f\n",this,distance); return(this); } } else {//no col trees = a sphere // compute real distance distance = (end-start).Magnitude() * distance; VSFileSystem::vs_dprintf(3,"Beam collide with %p, distance %f\n",this,distance); return(this); } } else { return (NULL); } return(NULL); }
void GameStatePlay::handleCritterRemovalFromWave() { std::map<int, Critter*> critters = current_wave->getContainerOfCritters(); for (int i = 0; i < int(critters.size()); ++i) { //tick and apply effects int tempHealth = critters[i]->getHitPoints(); if(critters[i]->isActive){ critters[i]->inflictEffects(); if(tempHealth != critters[i]->getHitPoints()){ std::pair<float, float> cpos = critters[i]->getPosition(); sf::Text ed(std::to_string(critters[i]->getHitPoints()), font, 12); if(critters[i]->getMovementDirection() == Critter::MovementDirection::LEFT || critters[i]->getMovementDirection() == Critter::MovementDirection::RIGHT) ed.setPosition(cpos.first, cpos.second - 32); else if(critters[i]->getMovementDirection() == Critter::MovementDirection::UP || critters[i]->getMovementDirection() == Critter::MovementDirection::DOWN) ed.setPosition(cpos.first + 24, cpos.second); ed.setColor(sf::Color::Blue); effectDamage[critters[i]->getId()] = ed; sf::Clock c; effectDamageClock[critters[i]->getId()] = c; } } //Check if critters are at end tile critters[i]->isAtEndTile = checkIfAtEndTile(critters[i]); if (critters[i]->isAtEndTile && critters[i]->isActive) { //handle removal of dead critters if(critters[i]->isActive && critters[i]->getHitPoints() <= 0){ std::cout << red << "Cat " << critters[i]->getId() << " fled away!" << std::endl; Game::player.earnCash(critters[i]->getPlayerReward() * 2); Game::player.gainPoints(critters[i]->getPlayerReward() * 3); current_wave->decrementCrittersRemaining(); critters[i]->isActive = false; } //handle removal of critters at end tile else if (critters[i]->isActive && critters[i]->isAtEndTile) { //Take a life from the player this->game->player.loseLives(1); //Remove points from player this->game->player.losePoints(critters[i]->getStealPointsStrength()); } if (critters[i]->isAtEndTile || critters[i]->getHitPoints() <= 0) { current_wave->findCritter(i)->isActive = false; current_wave->decrementCrittersRemaining(); critters[i]->isActive = false; } } } }
void FormatWidget::exportData(FormatElement *formatelement) { ExportDialog ed(this->_hexedit, this); ed.setFixedRange(formatelement->offset(), formatelement->endOffset()); int res = ed.exec(); if((res == ExportDialog::Accepted) && ed.selectedExporter()) ed.selectedExporter()->callDump(this->_hexedit->data(), ed.fileName(), ed.startOffset(), ed.endOffset()); }
int logon(int flag) { enable_telnet(0); set_prompt(""); if(active) ed("/dummy","ed_ends"); return 1; }
//--------------------------------------------------------------------------- bool TSettingBundleFrame::doEdit( TObject */*Sender*/ ) { std::auto_ptr <TSettingsEditDlg> ed ( new TSettingsEditDlg( this, bundle ) ); if ( ed->ShowModal() == mrOk ) { initialise(); return true; } return false; }
/* Scrolling test (used also in color-testing) */ void do_scrolling(void) { int soft, first, last, down, i, pass; ed(2); decom(TRUE); /* Origin mode (relative) */ for (soft = -1; soft <= 0; soft++) { if (soft) decsclm(TRUE); else decsclm(FALSE); for (pass = 0; pass < 2; ++pass) { if (pass == 0) { first = max_lines / 2; last = first + 1; } else { first = 1; last = max_lines; } decstbm(first, last); ed(2); for (down = 0; down >= -1; down--) { if (down) cuu(max_lines); else cud(max_lines); for (i = 1; i <= max_lines + 5; i++) { printf("%s scroll %s region [%d..%d] size %d Line %d\n", soft ? "Soft" : "Jump", down ? "down" : "up", first, last, last - first + 1, i); if (down) { ri(); ri(); } else if (soft) extra_padding(10); } } holdit(); } } }
int main(object me, string file) { if( !file ) return notify_fail("指令格式:edit <档名>\n"); if( in_edit(me) ) return notify_fail("你已经在使用编辑器了。\n"); seteuid(geteuid(me)); ed(resolve_path(me->query("cwd"), file)); return 1; }