这篇教程C++ within函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中within函数的典型用法代码示例。如果您正苦于以下问题:C++ within函数的具体用法?C++ within怎么用?C++ within使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了within函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mainint main (){ srandom ((unsigned) time (NULL)); zmq::context_t context(1); zmq::socket_t server(context, ZMQ_REP); server.bind("tcp://*:5555"); int cycles = 0; while (1) { std::string request = s_recv (server); cycles++; // Simulate various problems, after a few cycles if (cycles > 3 && within (3) == 0) { printf ("I: simulating a crash/n"); break; } else if (cycles > 3 && within (3) == 0) { printf ("I: simulating CPU overload/n"); sleep (5); } printf ("I: normal request (%s)/n", request.c_str()); sleep (1); // Do some heavy work s_send (server, request); } return 0;}
开发者ID:tzuryby,项目名称:zguide,代码行数:29,
示例2: compare // TODO: shortcut number of comparisons Interval::IntervalComparison Interval::compare(const Interval& other) const { // // Intersect cases // // TODO: rewrite this to be member functions so semantics are clearer. if (intersects(*this, other)) { if (exact(*this, other)) { return INTERVAL_EQUALS; } if (within(*this, other)) { return INTERVAL_WITHIN; } if (within(other, *this)) { return INTERVAL_CONTAINS; } if (precedes(*this, other)) { return INTERVAL_OVERLAPS_BEFORE; } return INTERVAL_OVERLAPS_AFTER; } // // Non-intersect cases // if (precedes(*this, other)) { if (0 == end.woCompare(other.start, false)) { return INTERVAL_PRECEDES_COULD_UNION; } return INTERVAL_PRECEDES; } return INTERVAL_SUCCEEDS; }
开发者ID:ChrisKozak,项目名称:mongo,代码行数:36,
示例3: compare // TODO: shortcut number of comparisons Interval::IntervalComparison Interval::compare(const Interval& other) const { // // Intersect cases // if (intersects(*this, other)) { if (exact(*this, other)) { return INTERVAL_EQUALS; } if (within(*this, other)) { return INTERVAL_WITHIN; } if (within(other, *this)) { return INTERVAL_CONTAINS; } if (precedes(*this, other)) { return INTERVAL_OVERLAPS_BEFORE; } return INTERVAL_OVERLAPS_AFTER; } // // Non-intersect cases // if (precedes(*this, other)) { return INTERVAL_PRECEDES; } return INTERVAL_SUCCEDS; }
开发者ID:Cassie90,项目名称:mongo,代码行数:32,
示例4: toIntvoid AmplitudeWidget::mousePressEvent(QMouseEvent *e){ View *view = gdata->view; int timeX = toInt(view->viewOffset() / view->zoomX()); //int pixelAtCurrentNoiseThresholdY = toInt(gdata->noiseThresholdDB() / gdata->dBFloor() / range() * double(height())); int pixelAtCurrentNoiseThresholdY; dragMode = DragNone; //Check if user clicked on center bar, to drag it if(within(4, e->x(), timeX)) { dragMode = DragTimeBar; mouseX = e->x(); return; } //Check if user clicked on a threshold bar for(int j=0; j<2; j++) { pixelAtCurrentNoiseThresholdY = height() - 1 - toInt((getCurrentThreshold(j) - offsetInv()) / range() * double(height())); if(within(4, e->y(), pixelAtCurrentNoiseThresholdY)) { dragMode = DragNoiseThreshold; thresholdIndex = j; //remember which thresholdIndex the user clicked mouseY = e->y(); return; } } //Otherwise user has clicked on background { mouseX = e->x(); mouseY = e->y(); dragMode = DragBackground; downTime = view->currentTime(); downOffset = offset(); }}
开发者ID:Guildenstern,项目名称:Tartini,代码行数:33,
示例5: mainint main () { // Prepare our context and publisher zmq::context_t context (1); zmq::socket_t publisher (context, ZMQ_PUB); publisher.bind("tcp://*:5556");// publisher.bind("ipc://weather.ipc"); // Initialize random number generator srandom ((unsigned) time (NULL)); while (1) { int zipcode, temperature, relhumidity; // Get values that will fool the boss zipcode = within (100000); temperature = within (215) - 80; relhumidity = within (50) + 10; // Send message to all subscribers zmq::message_t message(20); snprintf ((char *) message.data(), 20 , "%05d %d %d", zipcode, temperature, relhumidity); publisher.send(message); } return 0;}
开发者ID:tempbottle,项目名称:PurePaxos,代码行数:28,
示例6: distancedouble distance(struct position a, struct position b, const region_map_t* regs) { // find a region that fits a. bool a_in_reg = false; bool b_in_reg = false; int r; for (r=0; r<SIZE(*regs); ++r) { if (within(a, GET(*regs,r))) { a_in_reg = true; } if (within(b, GET(*regs,r))) { b_in_reg = true; } if (within(a, GET(*regs,r)) && within(b, GET(*regs,r))) { return rawDistance(a,b); } } /* if (!a_in_reg) { iprintf ("%7d WARNING(a): (%4.1f, %4.1f, %4.1f) is not in any region./n", warn_count, a.x, a.y, a.z); warn_count++; } if (!b_in_reg) { iprintf ("%7d WARNING(b): (%4.1f, %4.1f, %4.1f) is not in any region./n", warn_count, b.x, b.y, b.z); warn_count++; } */ return INFINITY;}
开发者ID:lally,项目名称:ioquake,代码行数:30,
示例7: s_set_id// Set simple random printable identity on socket//static voids_set_id (zmq::socket_t & socket){ char identity [10]; sprintf (identity, "%04X-%04X", within (0x10000), within (0x10000)); socket.setsockopt(ZMQ_IDENTITY, identity, strlen (identity));}
开发者ID:bosoxbill,项目名称:zguide,代码行数:9,
示例8: mainint main (){ srand ((unsigned) time (NULL)); zmq::context_t context(1); zmq::socket_t server(context, ZMQ_REP); server.bind("tcp://*:5555"); int cycles = 0; while (1) { std::string request = s_recv (server); cycles++; // Simulate various problems, after a few cycles if (cycles > 3 && within (3) == 0) { std::cout << "I: simulating a crash" << std::endl; break; } else if (cycles > 3 && within (3) == 0) { std::cout << "I: simulating CPU overload" << std::endl; s_sleep (2000); } std::cout << "I: normal request (" << request << ")" << std::endl; s_sleep (1000); // Do some heavy work s_send (server, request); } return 0;}
开发者ID:tarasko,项目名称:zmq.build,代码行数:29,
示例9: s_set_id// Set simple random printable identity on socket//inline std::strings_set_id (zmq::socket_t & socket){ std::stringstream ss; ss << std::hex << std::uppercase << std::setw(4) << std::setfill('0') << within (0x10000) << "-" << std::setw(4) << std::setfill('0') << within (0x10000); socket.setsockopt(ZMQ_IDENTITY, ss.str().c_str(), ss.str().length()); return ss.str();}
开发者ID:rymurr,项目名称:yocto_meteo_reader,代码行数:12,
示例10: return// return true if the current cell (i, j) is used by the current stage of calibrationbool TouchTracker::Calibrator::isWithinCalibrateArea(int i, int j){ if(mCollectingNormalizeMap) { return(within(i, 1, mWidth - 1) && within(j, 0, mHeight)); } else { return(within(i, 2, mWidth - 2) && within(j, 0, mHeight)); }}
开发者ID:ICST-AHMI,项目名称:Soundplane_code,代码行数:12,
示例11: RvaToHdr// Returns a pointer to the header of a relative virtual addressstatic PIMAGE_SECTION_HEADER RvaToHdr(LPVOID base, DWORD rva, PIMAGE_NT_HEADERS nt, LPVOID end){ PIMAGE_SECTION_HEADER sect = IMAGE_FIRST_SECTION(nt); unsigned i; for ( i=0; (i < nt->FileHeader.NumberOfSections) && within(base,sect,end); i++, sect++ ) { if ( (rva>=sect->VirtualAddress) && (rva<(sect->VirtualAddress+sect->Misc.VirtualSize))) { return within(base,sect,end)?sect:NULL; } } return NULL;}
开发者ID:gahr,项目名称:fxite,代码行数:12,
示例12: edu_check_rangestatic void edu_check_range(uint32_t addr, uint32_t size1, uint32_t start, uint32_t size2){ uint32_t end1 = addr + size1; uint32_t end2 = start + size2; if (within(addr, start, end2) && end1 > addr && within(end1, start, end2)) { return; } hw_error("EDU: DMA range 0x%.8x-0x%.8x out of bounds (0x%.8x-0x%.8x)!", addr, end1 - 1, start, end2 - 1);}
开发者ID:32bitmicro,项目名称:riscv-qemu,代码行数:14,
示例13: subVector /* --- Produce the vector end points produced by the overlap of two other vectors --- */static void subVector(int *v1, int *v2, int t1, int t2, int o1, int o2){ *v1 = *v2 = -1; if (within(o1, t1, t2)) { *v1 = o1; if (within(o2, t1, t2)) *v2 = o2; else *v2 = t2; } else if (within(o2, t1, t2)) { *v2 = o2; if (within(o1, t1, t2)) *v1 = o1; else *v1 = t1; } else if (within(t1, o1, o2)) { *v1 = t1; if (within(t2, o1, o2)) *v2 = t2; else *v2 = o2; } else if (within(t2, o1, o2)) { *v2 = t2; if (within(t1, o1, o2)) *v1 = t1; else *v1 = o1; }}
开发者ID:NoSuchProcess,项目名称:OrangeC,代码行数:35,
示例14: Terrain_SelectAreaPointsvoid Terrain_SelectAreaPoints( void ) { brush_t *pb; terrainMesh_t *p; int x; int y; vec3_t vec; g_qeglobals.d_numterrapoints = 0; g_nPatchClickedView = -1; for( pb = selected_brushes.next; pb != &selected_brushes; pb = pb->next ) { if ( pb->terrainBrush ) { p = pb->pTerrain; for( x = 0; x < p->width; x++ ) { for( y = 0; y < p->height; y++ ) { Terrain_CalcVertPos( p, x, y, vec ); if ( within( vec, g_qeglobals.d_vAreaTL, g_qeglobals.d_vAreaBR ) ) { if ( g_qeglobals.d_numterrapoints < MAX_TERRA_POINTS ) { g_qeglobals.d_terrapoints[ g_qeglobals.d_numterrapoints++ ] = &p->heightmap[ x + y * p->width ]; } } } } } }}
开发者ID:AeonGames,项目名称:AeonQuakeEngine,代码行数:26,
示例15: gcov_module_notifierstatic int gcov_module_notifier(struct notifier_block *nb, unsigned long event, void *data){ struct module *mod = data; struct gcov_info *info; struct gcov_info *prev; if (event != MODULE_STATE_GOING) return NOTIFY_OK; mutex_lock(&gcov_lock); prev = NULL; /* */ for (info = gcov_info_head; info; info = info->next) { if (within(info, mod->module_core, mod->core_size)) { if (prev) prev->next = info->next; else gcov_info_head = info->next; if (gcov_events_enabled) gcov_event(GCOV_REMOVE, info); } else prev = info; } mutex_unlock(&gcov_lock); return NOTIFY_OK;}
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:27,
示例16: discard_clusters static inline void discard_clusters(Turns& turns, Clusters const& clusters, Geometry0 const& geometry0, Geometry1 const& geometry1) { for (typename Clusters::const_iterator cit = clusters.begin(); cit != clusters.end(); ++cit) { signed_size_type cluster_id = cit->first; // If there are only self-turns in the cluster, the cluster should // be located within the other geometry, for intersection if (is_self_cluster(cluster_id, turns, clusters)) { cluster_info const& cinfo = cit->second; if (! within(turns[*cinfo.turn_indices.begin()], geometry0, geometry1)) { // Discard all turns in cluster for (std::set<signed_size_type>::const_iterator sit = cinfo.turn_indices.begin(); sit != cinfo.turn_indices.end(); ++sit) { turns[*sit].discarded = true; } } } } }
开发者ID:PopcornTimeTV,项目名称:PopcornTorrent,代码行数:26,
示例17: worker_threadstatic void *worker_thread (void *arg) { zmq::context_t * context = (zmq::context_t *)arg; zmq::socket_t worker (*context, ZMQ_REQ); // We use a string identity for ease here s_set_id (worker); worker.connect("ipc://routing.ipc"); int total = 0; while (1) { // Tell the router we're ready for work s_send (worker, "ready"); // Get workload from router, until finished std::string workload = s_recv (worker); int finished = (workload.compare("END") == 0); if (finished) { std::cout << "Processed: " << total << " tasks" << std::endl; break; } total++; // Do some random work s_sleep(within (100) + 1); } return (NULL);}
开发者ID:Lothiraldan,项目名称:zguide,代码行数:30,
示例18: worker_threadstatic void *worker_thread (void *context) { void *worker = zmq_socket (context, ZMQ_REQ); // We use a string identity for ease here s_set_id (worker); zmq_connect (worker, "ipc://routing.ipc"); int total = 0; while (1) { // Tell the router we're ready for work s_send (worker, "ready"); // Get workload from router, until finished char *workload = s_recv (worker); int finished = (strcmp (workload, "END") == 0); free (workload); if (finished) { printf ("Processed: %d tasks/n", total); break; } total++; // Do some random work struct timespec t; t.tv_sec = 0; t.tv_nsec = within (100000000) + 1; nanosleep (&t, NULL); } return (NULL);}
开发者ID:bosoxbill,项目名称:zguide,代码行数:31,
示例19: returnOcTree *OcTree::findParent(sceneobj_t *sc) { OcTree *p=NULL; int i=4, max=8; if(sc->userdata) return (OcTree*)sc->userdata; if(within(sc)) { p = this; if(children[0]) { //we are garaunteed all 8 if(sc->pos[AXIS_UP] < pos[AXIS_UP]) { i=0;max=OCTREE_MAX_CHILDREN/2; } for(;i<max;i++) { OcTree *q = children[i]->findParent(sc); if(q) { p = q; break; } } } } sc->userdata = p; return p;}
开发者ID:newerthcom,项目名称:savagerebirth,代码行数:28,
示例20: inside bool inside(vec3f pos, float fudge) { mat3f rot; //if(ctr == nullptr) { btTransform trans; rigid_body->getMotionState()->getWorldTransform(trans); btVector3 bpos = trans.getOrigin(); btQuaternion bq = trans.getRotation(); quaternion q = {{bq.x(), bq.y(), bq.z(), bq.w()}}; rot = q.get_rotation_matrix(); vec3f v = {bpos.x(), bpos.y(), bpos.z()}; vec3f rel = pos - v; return within(b, rot.transp() * rel, fudge); } /*rot = ctr->rot_quat.get_rotation_matrix(); vec3f my_pos = xyz_to_vec(ctr->pos); return within(b, rot.transp() * (pos - my_pos));*/ }
开发者ID:20k,项目名称:leap-motion-bullet-physics-test,代码行数:30,
示例21: except_errvoid SuBlock::persist() { if (persisted) return; if (frame->fn != fn) except_err("orphaned block!"); // won't need to copy locals if another block persist has already done so if (within(tls().proc->stack, frame->local)) { // save locals on heap - only done once per call/frame Value* old_locals = frame->local; int n = frame->fn->nlocals * sizeof (Value); frame->local = (Value*) memcpy(new char[n], frame->local, n); // update any other active frames pointing to the same locals // i.e. nested blocks within one parent frame for (Frame* f = tls().proc->fp; f > tls().proc->frames; --f) if (f->local == old_locals) f->local = frame->local; } // save frame on heap frame = (Frame*) memcpy(new Frame, frame, sizeof (Frame)); persisted = true; }
开发者ID:leeeqian,项目名称:csuneido,代码行数:28,
示例22: AccelerateGamevoid TRexGame::AccelerateGame(double delta_v){ double accelerated = game_speed_ + delta_v; if (within(accelerated, kGameMinSpeed, kGameMaxSpeed)) { game_speed_ = accelerated; }}
开发者ID:tim-ytw,项目名称:T-Rex-Runner,代码行数:8,
示例23: mainvoid main(int argc, string argv[]){ initparam(argv, defv); if (within(getdparam("val"), getparam("range"), getdparam("fuzz"))) printf("within returns TRUE/n"); else printf("within returns FALSE/n");}
开发者ID:jasminegrosso,项目名称:zeno,代码行数:8,
示例24: nemo_mainvoid nemo_main(){ stream instr, outstr; string times, ctypei, ctypeo; real tsnap; int i, nbody, bits, mode; Body *btab = NULL, *bp; proc transform, trans2; times = getparam("times"); ctypei = getparam("ctypei"); ctypeo = getparam("ctypeo"); if (streq(ctypei,"cart") && streq(ctypeo,"sph")) transform = cartesian_spherical; else if (streq(ctypei,"sph") && streq(ctypeo,"cart")) transform = spherical_cartesian; else if (streq(ctypei,"cart") && streq(ctypeo,"cyl")) transform = cartesian_cylindrical; else if (streq(ctypei,"cyl") && streq(ctypeo,"cart")) transform = cylindrical_cartesian; else error("Unimplemented ctype i/o : %s -> %s",ctypei,ctypeo); dprintf(0,"converting from %s to %s/n",ctypei,ctypeo); instr = stropen(getparam("in"), "r"); outstr = stropen(getparam("out"), "w"); get_history(instr); put_history(outstr); for (;;) { get_history(instr); /* skip over stuff we can forget */ if (!get_tag_ok(instr, SnapShotTag)) break; /* done with work in loop */ get_snap(instr, &btab, &nbody, &tsnap, &bits); if ((bits & MassBit) == 0 && (bits & PhaseSpaceBit) == 0) { continue; /* just skip it's probably a diagnostics */ } if ((bits & TimeBit) == 0) tsnap = 0.0; else if (!streq(times,"all") && !within(tsnap, times, TIMEFUZZ)) continue; dprintf (1,"Transforming snapshot at time= %f bits=0x%x/n",tsnap,bits);#if 0 Qmass = MassBit & bits; Qphase = PhaseSpaceBit & bits; Qacc = AccelerationBit & bits; Qaux = AuxBit & bits; Qkey = KeyBit & bits;#endif for (bp = btab; bp < btab+nbody; bp++) { (transform)(Pos(bp),Vel(bp),Acc(bp)); } put_snap(outstr, &btab, &nbody, &tsnap, &bits); }}
开发者ID:Milkyway-at-home,项目名称:nemo,代码行数:57,
示例25: withinu16 I2cSoft::waitAck() { _sda.init(GPIO_Mode_IN_FLOATING); _scl.set(Bit_SET); vu16 t; within(_FLAG_TIMEOUT, _sda.getInput() == Bit_SET); _scl.set(Bit_RESET); return t;}
开发者ID:aguegu,项目名称:stm32libs,代码行数:10,
示例26: setStateFromMIDIProgramvoid MLPluginProcessor::setStateFromMIDIProgram (const int idx){ if(within(idx, 0, kMLPluginMIDIPrograms)) { if(mMIDIProgramFiles[idx].exists()) { loadStateFromFile(mMIDIProgramFiles[idx]); } }}
开发者ID:afofo,项目名称:madronalib,代码行数:10,
示例27: fprintfvoid testing_$RAND_expand(bool verbose){ if (verbose) { fprintf( stdout, "/n----- testing_$RAND_expand ----/n/n"); } // regressions REQUIRE( within(expand("$RANDOM_INTEGER(-30,30,1)"), -30, 30) ); REQUIRE( within(expand("$RANDOM_INTEGER(2,2,1)"), 2, 2) ); REQUIRE( within(expand("$RANDOM_INTEGER(-10,0,2)"), -10, 0) ); REQUIRE( within(expand("$RANDOM_INTEGER(-1000,-99,3)"), -1000, -99) ); REQUIRE( within(expand("$RANDOM_INTEGER(3,9,3)"), 3, 9) ); REQUIRE( within(expand("$RANDOM_INTEGER(0,9,3)"), 0, 9) ); REQUIRE( within(expand("$RANDOM_CHOICE(1,2,2,1)"), 1, 2) ); REQUIRE( within(expand("$RANDOM_CHOICE(aa,bb,cc)"), "aa", "cc") ); REQUIRE( within(expand("$RANDOM_CHOICE(List6c)"), "aa", "ff") ); REQUIRE( within(expand_as("MASTER", "$RANDOM_CHOICE(List6c)"), "JMK", "ZKM") ); REQUIRE( expand("$RANDOM_CHOICE(1)") == "1" ); REQUIRE( expand("$RANDOM_CHOICE(aa bb cc)") == "aa bb cc" );}
开发者ID:AlainRoy,项目名称:htcondor,代码行数:21,
示例28: mainint main(int argc, char *argv[]){ int opt; printf("multiply 1 by 2 a number of times/n"); for(opt=0; opt<=1; ++opt) { printf(" (optimize:%d) result=%d/n", opt, multiply(opt, 24)); } printf("check if abstract value N within threshold T/n"); for(opt=0; opt<=1; ++opt) { printf(" (optimize:%d) result=%d/n", opt, within(opt, -3, 3)); printf(" (optimize:%d) result=%d/n", opt, within(opt, 3, 3)); printf(" (optimize:%d) result=%d/n", opt, within(opt, -4, 3)); printf(" (optimize:%d) result=%d/n", opt, within(opt, 4, 3)); } return 0;}
开发者ID:makotow,项目名称:CodeIQ,代码行数:21,
示例29: apply static inline void apply(Turns& turns, Clusters const& clusters, Geometry0 const& geometry0, Geometry1 const& geometry1) { discard_clusters(turns, clusters, geometry0, geometry1); typedef typename boost::range_value<Turns>::type turn_type; for (typename boost::range_iterator<Turns>::type it = boost::begin(turns); it != boost::end(turns); ++it) { turn_type& turn = *it; if (turn.discarded || ! is_self_turn<overlay_intersection>(turn)) { continue; } segment_identifier const& id0 = turn.operations[0].seg_id; segment_identifier const& id1 = turn.operations[1].seg_id; if (id0.multi_index != id1.multi_index || (id0.ring_index == -1 && id1.ring_index == -1) || (id0.ring_index >= 0 && id1.ring_index >= 0)) { // Not an ii ring (int/ext) on same ring continue; } if (turn.is_clustered() && turn.has_colocated_both) { // Don't delete a self-ii-turn colocated with another ii-turn // (for example #case_recursive_boxes_70) // But for some cases (#case_58_iet) they should be deleted, // there are many self-turns there and also blocked turns there if (! any_blocked(turn.cluster_id, turns, clusters)) { continue; } } // It is a ii self-turn // Check if it is within the other geometry // If not, it can be ignored if (! within(turn, geometry0, geometry1)) { // It is not within another geometry, discard the turn turn.discarded = true; } } }
开发者ID:PopcornTimeTV,项目名称:PopcornTorrent,代码行数:52,
注:本文中的within函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ withinHTMLDateLimits函数代码示例 C++ withWriteLock函数代码示例 |