inline bool get_intersect(const circle& a, const circle &b, bool e_trick, vector<node> &s) { if (e_trick && a == b) { add_interval(s, -PI, PI); return true; } if (contain(a, b)) return false; if (contain(b, a)) { add_interval(s, -PI, PI); return true; } point l = b.center - a.center; double d = dis(a.center, b.center); if (d > a.radius + b.radius - EPS) return false; double theta = acos((sqr(a.radius) + sqr(d) - sqr(b.radius)) / 2 / a.radius / d); double c1 = atan2(l.y, l.x) - theta, c2 = atan2(l.y, l.x) + theta; if (c1 < -PI) c1 += 2 * PI; if (c2 > PI) c2 -= 2 * PI; if (c1 > c2) { add_interval(s, c1, PI); add_interval(s, -PI, c2); } else add_interval(s, c1, c2); return true; }
int numberOfPatternsHelper(int m, int n, int level, int used, int i) { int number = 0; if (level > n) { return number; } if (level >= m) { ++number; } const auto x1 = i / 3; const auto y1 = i % 3; for (int j = 0; j < 9; ++j) { if (contain(used, j)) { continue; } const auto x2 = j / 3; const auto y2 = j % 3; if (((x1 == x2 && abs(y1 - y2) == 2) || (y1 == y2 && abs(x1 - x2) == 2) || (abs(x1 - x2) == 2 && abs(y1 - y2) == 2)) && !contain(used, convert((x1 + x2) / 2, (y1 + y2) / 2))) { continue; } number += numberOfPatternsHelper(m, n, level + 1, merge(used, j), j); } return number; }
bool intersect( const Part & a , const Part & b ) { const PartVector & a_sub = a.subsets(); const PartVector & b_sub = b.subsets(); return contain( a_sub , b ) || contain( b_sub , a ) || intersect( b_sub , a_sub ); }
void compare(char *a, char *b) { if (equal(a, b)) printf("A equals B\n"); else if (contain(a, b)) printf("B is a proper subset of A\n"); else if (contain(b, a)) printf("A is a proper subset of B\n"); else if (disjoint(a, b)) printf("A and B are disjoint\n"); else printf("I'm confused!\n"); }
void PartRepository::declare_subset( Part & superset, Part & subset ) { static const char method[] = "stk_classic::mesh::impl::PartRepository::declare_subset" ; Trace_(method); if ( ! contain( subset.supersets() , superset ) ) { assert_not_same( superset , subset , method ); assert_not_superset( superset , subset , method ); assert_same_universe( superset , subset , method ); assert_rank_ordering( superset , subset , method ); // Insert this symmetric relationship first // so that it does not get revisited. declare_subset_impl( superset, subset ); // Transitive: const PartVector & subset_subsets = subset.subsets(); for ( PartVector::const_iterator i = subset_subsets.begin() ; i != subset_subsets.end() ; ++i ) { declare_subset( superset, **i ); } const PartVector & superset_supersets = superset.supersets(); for ( PartVector::const_iterator i = superset_supersets.begin() ; i != superset_supersets.end() ; ++i ) { declare_subset( **i, subset ); } // Induced intersection-part membership: const PartVector & superset_subsets = superset.subsets(); for ( PartVector::const_iterator i = superset_subsets.begin() ; i != superset_subsets.end() ; ++i ) { Part & pint = **i ; if ( ! pint.intersection_of().empty() && ( & pint != & subset ) ) { // If 'subset' is a subset of every member of 'pint.intersection_of()' // then it is by definition a subset of 'pint. if ( contain( subset.supersets() , pint.intersection_of() ) ) { declare_subset( pint, subset ); } } } } }
void ViolinClassification::svmClassifyAll() { featToCompare.clear(); featToCompare.push_back(featurelist[1]); featToCompare.push_back(featurelist[2]); int level1res = svmfun(sv1, alpha1, shift1, scalefactor1, bias1, featToCompare); int level2res; if (level1res == 1){ level2res = svmfun(sv2, alpha2, shift2, scalefactor2, bias2, featurelist); if (level2res == 1){ if (contain(toggleState, 0)) classLabel = "pizzicato"; else classLabel = ""; } else{ if (contain(toggleState, 1)) classLabel = "staccato"; else classLabel = ""; } } else{ featToCompare.clear(); featToCompare.push_back(featurelist[4]); featToCompare.push_back(featurelist[5]); level2res = svmfun(sv3, alpha3, shift3, scalefactor3, bias3, featToCompare); if (level2res == 1){ if (contain(toggleState, 2)) classLabel = "tremolo"; else classLabel = ""; } else{ int level3res = chromaCompare(); if (level3res == 1){ if (contain(toggleState, 3)) classLabel = "trill"; else classLabel = ""; } else{ if (contain(toggleState, 4)) classLabel = "vibrato"; else classLabel = ""; } } } }
Cycle * XeoTerm::defaultCycle(QString _context, QDateTime _time){ if(contain(_context)){ VariableContextSpec * pcs = (*this->contextCollection)[_context]; if(pcs->get_defCycle()!=NULL){ Cycle * v = new Cycle(); v->set_context(_context); for(std::list<std::pair<QDateTime, QString> >::iterator it = pcs->get_defCycle()->get_vals()->begin();it!=pcs->get_defCycle()->get_vals()->end();++it) { std::pair<DynamicValueBase*,QDateTime> p =std::make_pair(new DynamicValue(it->first,it->second),_time); v->add_cycleValue(p); } if(pcs->get_unitSet()->get_defUnit()!=NULL) { v->set_unit(pcs->get_unitSet()->get_defUnit()->get_symbol()); } v->set_timepoint(_time); return v; } else return NULL; } else{ return NULL; } }
void PartRepository::declare_subset( Part & superset, Part & subset ) { static const char method[] = "stk::mesh::impl::PartRepository::declare_subset" ; if ( ! contain( subset.supersets() , superset ) ) { assert_not_same( superset , subset , method ); assert_not_superset( superset , subset , method ); assert_same_universe( superset , subset , method ); assert_rank_ordering( superset , subset , method ); // Insert this symmetric relationship first // so that it does not get revisited. declare_subset_impl( superset, subset ); // Transitive: const PartVector & subset_subsets = subset.subsets(); for ( PartVector::const_iterator i = subset_subsets.begin() ; i != subset_subsets.end() ; ++i ) { declare_subset( superset, **i ); } const PartVector & superset_supersets = superset.supersets(); for ( PartVector::const_iterator i = superset_supersets.begin() ; i != superset_supersets.end() ; ++i ) { declare_subset( **i, subset ); } } }
void BulkData::destroy_relation( Entity & e1 , Entity & e2 , unsigned kind ) { // When removing a relationship may need to // remove part membership and set field relation pointer to NULL PartSet del ; bool to_e1 = false ; std::vector<Relation>::iterator i ; for ( i = e1.m_relation.end() ; i != e1.m_relation.begin() ; ) { --i ; if ( i->entity() == & e2 && i->kind() == kind ) { if ( i->forward() ) { clear_field_relations( e1 , i->entity_type() , i->identifier() , i->kind() ); deduce_part_relations( e1, e2, i->identifier(), i->kind(), del ); } i = e1.m_relation.erase( i ); } } for ( i = e2.m_relation.end() ; i != e2.m_relation.begin() ; ) { --i ; if ( i->entity() == & e1 && i->kind() == kind ) { if ( i->forward() ) { clear_field_relations( e2 , i->entity_type() , i->identifier() , i->kind() ); deduce_part_relations( e2, e1, i->identifier(), i->kind(), del ); to_e1 = true ; } i = e2.m_relation.erase( i ); } } Entity & e_to = to_e1 ? e1 : e2 ; { PartSet keep ; deduce_part_relations( e_to , keep ); if ( ! keep.empty() ) { // Eliminate the 'keep' from the accumulated 'del' for ( PartSet::iterator j = del.end() ; j != del.begin() ; ) { --j ; if ( contain( keep , **j ) ) { j = del.erase( j ); } } } } if ( ! del.empty() ) { PartSet add ; internal_change_entity_parts( e_to , add , del ); } }
/* Initialize uniformly particles within a "patch" */ particle_t *initializePatch(uint64_t n_input, uint64_t L, bbox_t patch, bbox_t tile, double k, double m, uint64_t *n_placed, uint64_t *n_size) { particle_t *particles; uint64_t x, y, total_cells, pi, p, actual_particles, start_index; double particles_per_cell; /* initialize random number generator */ LCG_init(); total_cells = (patch.right - patch.left+1)*(patch.top - patch.bottom+1); particles_per_cell = (double) n_input/total_cells; /* Loop over columns of cells and assign number of particles if inside patch */ for (*n_placed=0,x=tile.left; x<tile.right; x++) { start_index = tile.bottom+x*L; LCG_jump(2*start_index, 0); for (y=tile.bottom; y<tile.top; y++) { if (contain(x,y,patch)) (*n_placed) += random_draw(particles_per_cell); else (*n_placed) += random_draw(0.0); } } /* use some slack in allocating memory to avoid fine-grain memory management */ (*n_size) = ((*n_placed)*(1+MEMORYSLACK))/MEMORYSLACK; particles = (particle_t*) prk_malloc((*n_size) * sizeof(particle_t)); if (particles == NULL) return(particles); for (pi=0,x=tile.left; x<tile.right; x++) { start_index = tile.bottom+x*L; LCG_jump(2*start_index,0); for (y=tile.bottom; y<tile.top; y++) { actual_particles = random_draw(particles_per_cell); if (!contain(x,y,patch)) actual_particles = 0; for (p=0; p<actual_particles; p++) { particles[pi].x = x + REL_X; particles[pi].y = y + REL_Y; particles[pi].k = k; particles[pi].m = m; pi++; } } } finishParticlesInitialization((*n_placed), particles); return particles; }
static void layout_elements_interior_exterior( const BoxType vertex_box_local_used , const BoxType vertex_box_local_owned , const BoxType node_box_local_used , const std::vector<size_t> & node_used_id_map , const ElementSpec element_fixture , const size_t elem_count_interior , const typename elem_node_ids_type::HostMirror elem_node_ids ) { size_t elem_index_interior = 0 ; size_t elem_index_boundary = elem_count_interior ; for ( size_t iz = vertex_box_local_used[2][0] ; iz < vertex_box_local_used[2][1] - 1 ; ++iz ) { for ( size_t iy = vertex_box_local_used[1][0] ; iy < vertex_box_local_used[1][1] - 1 ; ++iy ) { for ( size_t ix = vertex_box_local_used[0][0] ; ix < vertex_box_local_used[0][1] - 1 ; ++ix ) { size_t elem_index ; // If lower and upper vertices are owned then element is interior if ( contain( vertex_box_local_owned, ix, iy, iz ) && contain( vertex_box_local_owned, ix+1, iy+1, iz+1 ) ) { elem_index = elem_index_interior++ ; } else { elem_index = elem_index_boundary++ ; } for ( size_t nn = 0 ; nn < element_node_count ; ++nn ) { unsigned coord[3] = { static_cast<unsigned>(ix) , static_cast<unsigned>(iy) , static_cast<unsigned>(iz) }; element_fixture.elem_to_node( nn , coord ); const size_t node_local_id = box_map_id( node_box_local_used , node_used_id_map , coord[0] , coord[1] , coord[2] ); elem_node_ids( elem_index , nn ) = node_local_id ; } } } } }
/** Metoda zwraca sprita o podanej nazwie * @throw const char* : nazwa metody */ Sprite SpriteManager::getSprite( string Name ){ if( contain(Name) ){ return pSprites.find( Name )->second; } else{ gCritical("Not found sprite"); throw("SpriteManager::getSprite"); } }
int numberOfPatterns(int m, int n) { // dp[i][j]: i is the set of the numbers in binary representation, // dp[i][j] is the number of ways ending with the number j. vector<vector<int>> dp(1 << 9 , vector<int>(9, 0)); for (int i = 0; i < 9; ++i) { dp[merge(0, i)][i] = 1; } int res = 0; for (int used = 0; used < dp.size(); ++used) { const auto number = number_of_keys(used); if (number > n) { continue; } for (int i = 0; i < 9; ++i) { if (!contain(used, i)) { continue; } const auto x1 = i / 3; const auto y1 = i % 3; for (int j = 0; j < 9; ++j) { if (i == j or !contain(used, j)) { continue; } const auto x2 = j / 3; const auto y2 = j % 3; if (((x1 == x2 && abs(y1 - y2) == 2) || (y1 == y2 && abs(x1 - x2) == 2) || (abs(x1 - x2) == 2 && abs(y1 - y2) == 2)) && !contain(used, convert((x1 + x2) / 2, (y1 + y2) / 2))) { continue; } dp[used][i] += dp[exclude(used, i)][j]; } if (m <= number && number <= n) { res += dp[used][i]; } } } return res; }
DynamicValue * XeoTerm::defaultdynamicValue(QString _context, QDateTime _time){ if(contain(_context)){ VariableContextSpec * pcs = (*this->contextCollection)[_context]; DynamicValue * v = new DynamicValue(); v->set_context(_context); QString tmp=pcs->get_defValue(); if((!tmp.isEmpty())||(!tmp.size()==0)){ v->set_value(pcs->get_defValue()); } else { if(this->hasDefaultCycle(_context)) { v->set_value(static_cast<DynamicValue*>(this->defaultCycle(_context)->get_cycleValues()->front().first)->get_value()); } else { switch (pcs->get_typeDefine()->get_baseType()) { case Xeml::Document::Number: { v->set_doubleValue(0.0); break; } case Xeml::Document::Text: { v->set_value(""); break; } case Xeml::Document::Bool: { v->set_booleanValue(false); break; } default: v->set_value(""); break; } } } if(pcs->get_unitSet()->get_defUnit()!=NULL) { v->set_unit(pcs->get_unitSet()->get_defUnit()->get_symbol()); } v->set_timepoint(_time); return v; } else{ return NULL; } }
void Button::mouseRelease(int x, int y) { if (!isDisabled) { if (contain(x, y)) { emit clicked(); } isPressed = false; } }
/** \brief del a hook */ void event_hook_t::remove(size_t level_no, event_hook_cb_t *callback, void *userptr) throw() { // sanity check DBG_ASSERT( level_no < level_arr.size() ); // build the item hook_item item(callback, userptr); // sanity check - the item MUST be contained by the list DBG_ASSERT( contain(level_no, callback, userptr) ); // remove the item from the list level_arr[level_no].item_list.remove( item ); }
bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; if (contain(backgroundImageSpacePos)) { _engine->getCursorManager()->changeCursor(_cursor); return true; } return false; }
int verificaLivelli(albero a1,albero a2,int v) { listaInteri l1 = allocaLista(a1, v); listaInteri l2 = allocaLista(a2, v); int result=0; while(l2!=NULL) { if(contain(l1,l2->info)) { result++; } l2=l2->next; } return result; }
/** \brief update an item into the ndiag_cacheport_t */ ndiag_cacheport_t &ndiag_cacheport_t::update(const ndiag_cacheport_item_t &cacheport_item) throw() { // log to debug KLOG_DBG("enter"); // if there is one for the same std::string, remove it if( contain(cacheport_item.key(), cacheport_item.sockfam()) ) remove(cacheport_item.key(), cacheport_item.sockfam()); // add this item to the item_db_t item_db.append(cacheport_item); // return the object itself return *this; }
void TypeList::merge(TypeList *tl) { List<Type*>::const_iterator it = tl->list.begin(); while (it != tl->list.end()) { Type *t = *it; if (!contain(t)) { list.push_back(t); } ++it; } }
/******************* FUNCTION *********************/ size_t ReaderEntry::getPFN(void* addr) const { //error if (!contain(addr)) { fprintf(stderr,"Invalid address, out of bound !"); abort(); } //compute size_t id = ((size_t)addr - (size_t)base) / PAGE_SIZE; return pfns[id]; }
//IntSet& IntSet::f_and(IntSet& set){ // vector<int> *pv=set.getAll(); // vector<int>::iterator i = pv->begin(); // size = 0; // IntNode *node=0; // if(i!=pv->end()){ // node = new IntNode(*i++); // } // for(i;i!=pv->end();++i){ // if(contain(*i)){ // size++; // insertInt(*node,*i); // } // } // deleteTree(root); // root = node; // return *this; //} IntSet* IntSet::f_and(IntSet* set){ /*****seraphim3*****/ bool b = contain(12); printf("-----bool-----------%i",b); vector<int> *pv=set->getAll(); vector<int>::iterator i = pv->begin(); size = 0; //IntNode *node=0; if(i==pv->end()){ return 0; } IntNode *node = new IntNode(*i++); for(i;i!=pv->end();++i){ if(contain(*i)){ size++; insertInt(*node,*i); } } deleteTree(root); root = node; return this; }
int main(){ while(scanf("%s%s",a,b)==2){ if(a[0]=='0'&&b[0]=='0') break; str1[0]='1',str1[1]='\0'; str2[0]='2',str2[1]='\0'; int count=0; if(contain(str1)) count++; if(contain(str2)) count++; while(!bigger(str2,b)){ plus(str1,str2,str3); if(contain(str3)) count++; memmove(str1,str2,sizeof(str1)); memmove(str2,str3,sizeof(str2)); } printf("%d\n",count); } return 0; }
int Work() { str s,token; printf("\nkeyword: "); scanf("%s",s); getchar(); if(strcmp(s,"-q")==0) return 0; if(strcmp(s,"-cls")==0) { system("clear"); return 1; } if(test_token()==0) return 1; int i; for(i=0;i!=N;++i) if(contain(i,s)) print(i); return 1; }
bool PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; if (_event != Common::EVENT_LBUTTONUP) return false; if (contain(backgroundImageSpacePos)) { setVenus(); int32 val = _engine->getScriptManager()->getStateValue(_key); val = (val + 1) % _countTo; _engine->getScriptManager()->setStateValue(_key, val); return true; } return false; }
int maxEnvelopes(vector<pair<int, int> >& envelopes) { int n = envelopes.size(); if(n <= 1) return n; sort(envelopes.begin(), envelopes.end()); vector<int> dp(n, 1); for(int i = 1;i < n;i++) { for(int j = 0;j < i;j++) { if(contain(envelopes[i], envelopes[j])) dp[i] = max(dp[i], dp[j]+1); } } int m = 0; for(int i = 0;i < n;i++) m = max(m, dp[i]); return m; }
MojErr MojDbSearchCache::updateCache(const QueryKey& a_key, const IdSet& a_ids) { // Skip updating the cache ONLY if up-to-date cache is available. // if (contain(a_key) == true) return MojErrNone; // Delete any cache for this query/kind here. // MojErr err = destroyCache(a_key.getKind()); MojErrCheck(err); // Add new cache. // err = createCache(a_key, a_ids); MojErrCheck(err); return MojErrNone; }
int *intersection(int *nums1, int nums1Size, int *nums2, int nums2Size, int *returnSize) { int maxSize = nums1Size < nums2Size ? nums1Size : nums2Size; int *p = (int *) malloc(maxSize * sizeof(int)); memset(p, 0, maxSize); int *cur = p; for (int i = 0; i < nums1Size; ++i) { for (int j = 0; j < nums2Size; ++j) { if (nums1[i] == nums2[j] && contain(p, cur - p, nums1[i]) == 0) { *cur = nums1[i]; cur++; } } } *returnSize = cur - p; return p; }
void Button::mouseMove(int x, int y) { if (!isDisabled) { if (contain(x, y)) { if (isPressed) { overlay->setEnhance(PressEnhance); } else { overlay->setEnhance(HoverEnhance); } } else { overlay->setEnhance(CommonEnhance); } } }
int main(){ freopen("data.txt","r",stdin); while(scanf("%d %d",&N,&dim)==2){ memset(boxes,0,sizeof(boxes)); memset(graph,0,sizeof(graph)); memset(result,0,sizeof(result)); for(int i(0);i<N;++i){ for(int j(0);j<dim;++j){ scanf("%d",&boxes[i].edges[j]); } } for(int i(0);i<N;++i){ std::sort(boxes[i].edges,boxes[i].edges+dim); } for(int i(0);i<N;++i){ for(int j(0);j<N;++j){ if (j==i) continue; graph[i][j] = contain(boxes[i],boxes[j]); } } //动态规划求各点的最长路径 max_stack_num = 0; int start(-1); for(int i(0);i<N;++i){ int tmp = dp(i); if(max_stack_num<tmp){ max_stack_num = tmp; start = i; } } printf("%d\n",max_stack_num); //回溯输出节点 back(start,max_stack_num); } return 0; }