unsigned int Query::Clone(const Query *other) { // TRACE << "Cloning " << other->ToString() << "\n"; for (restrictions_t::const_iterator i = other->m_restrictions.begin(); i != other->m_restrictions.end(); ++i) { if (i->is_string) Restrict(i->which, i->rt, i->sval); else Restrict(i->which, i->rt, i->ival); } for (relations_t::const_iterator i = other->m_relations.begin(); i != other->m_relations.end(); ++i) { if (i->anditive) And(Subexpression((int)i->a), Subexpression((int)i->b)); else Or(Subexpression((int)i->a), Subexpression((int)i->b)); } unsigned int rc = Where(Subexpression(other->m_root)); if (rc) return rc; for (orderby_t::const_iterator i = other->m_orderby.begin(); i != other->m_orderby.end(); ++i) { rc = OrderBy(*i); if (rc) return rc; } for (orderby_t::const_iterator i = other->m_collateby.begin(); i != other->m_collateby.end(); ++i) { rc = CollateBy(*i); if (rc) return rc; } // TRACE << "Cloned: " << ToString() << "\n"; return 0; }
REAL CubePBC::Dist2(Particle& p1, Particle& p2) { REAL dist2 = 0.0, temp; for(int i=0; i<DIM; ++i) { temp = Restrict(p1.x[i] - p2.x[i]); dist2 += temp * temp; } return dist2; }
void BattleOptionsTab::ReloadRestrictions() { if ( !m_battle ) return; m_allowed_list->Clear(); m_restrict_list->Clear(); if ( m_battle->GetHostModName() == wxEmptyString ) return; try { m_allowed_list->InsertItems( usync().GetUnitsList( m_battle->GetHostModName() ), 0 ); } catch ( ... ) {} std::map<wxString, int> units = m_battle->RestrictedUnits(); for ( std::map<wxString, int>::iterator itor = units.begin(); itor != units.end(); itor++ ) Restrict( itor->first, itor->second ); }
void BattleOptionsTab::ReloadRestrictions() { if ( !m_battle ) return; m_allowed_list->Clear(); m_restrict_list->Clear(); if ( m_battle->GetHostModName().empty() ) return; try { wxArrayString items = lslTowxArrayString(LSL::usync().GetUnitsList(m_battle->GetHostModName())); m_allowed_list->Append(items); } catch ( ... ) {} std::map<std::string, int> units = m_battle->RestrictedUnits(); for ( std::map<std::string, int>::const_iterator itor = units.begin(); itor != units.end(); ++itor ) Restrict( TowxString(itor->first), itor->second ); }
/* (Called recursively.) */ void Ufmg(float *soln, float *dx, float *dy, int w, int h, int numit, int mindim) { float *dx2=NULL, *dy2=NULL, *soln2=NULL; int w2 = w/2, h2 = h/2; if (!Coarsest(w, h, mindim)) { dx2 = Allocate(w2, h2, dx_type); dy2 = Allocate(w2, h2, dy_type); soln2 = Allocate(w2, h2, soln_type); Restrict(dx2, dy2, w2, h2, dx, dy, NULL, NULL, soln, w, h); Zero(soln2, w2, h2); Ufmg(soln2, dx2, dy2, w2, h2, numit, mindim); ProlongAndAccumulate(soln, w, h, soln2, w2, h2, NULL, NULL); } /* perform V-cycle multigrid on fine grid */ Umv(soln, dx, dy, w, h, numit, mindim); }
/* (Called recursively.) */ void Umv(float *soln, float *dx, float *dy, int w, int h, int numit, int mindim) { float *dx2=NULL, *dy2=NULL, *soln2=NULL; int w2 = w/2, h2 = h/2; if (!Coarsest(w, h, mindim)) { Relax(soln, dx, dy, NULL, NULL, w, h, numit); dx2 = Allocate(w2, h2, dx_type); dy2 = Allocate(w2, h2, dy_type); soln2 = Allocate(w2, h2, soln_type); Restrict(dx2, dy2, w2, h2, dx, dy, NULL, NULL, soln, w, h); Zero(soln2, w2, h2); Umv(soln2, dx2, dy2, w2, h2, numit, mindim); ProlongAndAccumulate(soln, w, h, soln2, w2, h2, NULL, NULL); Relax(soln, dx, dy, NULL, NULL, w, h, numit); } else { /* coarsest */ Relax(soln, dx, dy, NULL, NULL, w, h, 2*w*h); } }
/** \details Test the Restrict (0x14) operation This function: -# Opens the Inbox folder and creates some test content -# Checks that the content is OK -# Applies a filter -# Checks the results are as expected. -# Resets the table -# Checks the results are as expected. -# Cleans up \param mt pointer on the top-level mapitest structure \return true on success, otherwise false */ _PUBLIC_ bool mapitest_oxctable_Restrict(struct mapitest *mt) { mapi_object_t obj_htable; mapi_object_t obj_test_folder; struct mt_common_tf_ctx *context; uint32_t count = 0; uint32_t origcount = 0; uint32_t Numerator = 0; uint32_t Denominator = 0; struct mapi_SRestriction res; bool ret = true; /* Step 1. Logon */ if (! mapitest_common_setup(mt, &obj_htable, &count)) { return false; } /* Step 2. Get the test folder */ context = mt->priv; mapi_object_init(&(obj_test_folder)); GetContentsTable(&(context->obj_test_folder), &(obj_test_folder), 0, &origcount); if (GetLastError() != MAPI_E_SUCCESS) { mapitest_print_retval(mt, "GetContentsTable"); ret = false; goto cleanup; } if (origcount != 10) { mapitest_print(mt, "* %-35s: unexpected count (%i)\n", "GetContentsTable", count); /* This isn't a hard error for this test though, because it might be from a previous test failure. Clean up and try again */ } /* Apply a filter */ res.rt = RES_PROPERTY; res.res.resProperty.relop = RES_PROPERTY; res.res.resProperty.ulPropTag = PR_SUBJECT; res.res.resProperty.lpProp.ulPropTag = PR_SUBJECT; res.res.resProperty.lpProp.value.lpszA = MT_MAIL_SUBJECT; Restrict(&(obj_test_folder), &res, NULL); mapitest_print_retval(mt, "Restrict"); if (GetLastError() != MAPI_E_SUCCESS) { ret = false; goto cleanup; } /* Checks the results are as expected */ context = mt->priv; QueryPosition(&(obj_test_folder), &Numerator, &Denominator); if (GetLastError() != MAPI_E_SUCCESS) { mapitest_print_retval(mt, "QueryPosition"); ret = false; goto cleanup; } if (Denominator != origcount/2) { mapitest_print(mt, "* %-35s: unexpected filtered count (%i)\n", "QueryPosition", Denominator); ret = false; goto cleanup; } /* Resets the table */ Reset(&(obj_test_folder)); mapitest_print_retval(mt, "Reset"); if (GetLastError() != MAPI_E_SUCCESS) { ret = false; goto cleanup; } /* Checks the results are as expected */ context = mt->priv; QueryPosition(&(obj_test_folder), &Numerator, &Denominator); if (GetLastError() != MAPI_E_SUCCESS) { mapitest_print_retval(mt, "QueryPosition"); ret = false; goto cleanup; } if (Denominator != origcount) { mapitest_print(mt, "* %-35s: unexpected reset count (%i)\n", "QueryPosition", Denominator); ret = false; goto cleanup; } cleanup: /* Release */ mapi_object_release(&obj_htable); mapi_object_release(&(obj_test_folder)); mapitest_common_cleanup(mt); return ret; }
void BattleOptionsTab::Restrict( const wxString& name, int count ) { if ( !m_battle ) return; int i = GetAllowedUnitIndex( name ); Restrict( i, count ); }
REAL CubePBC::Dist(Particle& p1, Particle& p2, int k) { return Restrict(p1.x[k] - p2.x[k]); }