static ut64 getRefPtr(RCoreObjc *objc, ut64 classMethodsVA, bool *res) { ut64 namePtr = readQword (objc, classMethodsVA); int i, cnt = 0; ut64 res_at = 0LL; const char *k = addr_key (namePtr); *res = false; for (i = 0; ; i++) { ut64 at = sdb_array_get_num (objc->db, k, i, NULL); if (!at) { break; } if (inBetween (objc->_selrefs, at)) { *res = false; res_at = at; } else if (inBetween (objc->_msgrefs, at)) { *res = true; res_at = at; } else if (inBetween (objc->_const, at)) { cnt++; } } if (cnt > 1) { return 0LL; } return res_at; }
void set_num_threads(int threads) { if (threads == -1) num_threads = ParallelPrimeSieve::getMaxThreads(); else num_threads = inBetween(1, threads, ParallelPrimeSieve::getMaxThreads()); }
/* intersect: * Returns true if the segment [c,d] blocks a and b from seeing each other. * More specifically, returns true iff c or d lies on (a,b) or the two * segments intersect as open sets. */ int intersect(Ppoint_t a,Ppoint_t b,Ppoint_t c,Ppoint_t d) { int a_abc; int a_abd; int a_cda; int a_cdb; a_abc = wind(a,b,c); if ((a_abc == 0) && inBetween (a,b,c)) { return 1; } a_abd = wind(a,b,d); if ((a_abd == 0) && inBetween (a,b,d)) { return 1; } a_cda = wind(c,d,a); a_cdb = wind(c,d,b); /* True if c and d are on opposite sides of ab, * and a and b are on opposite sides of cd. */ return (((a_abc * a_abd) < 0) && ((a_cda * a_cdb) < 0)); }
// Returns true iff the point c lies on the closed segment ab. // bool pointOnLine(const Point& a, const Point& b, const Point& c, const double tolerance) { // Do this a bit more optimally for orthogonal AB line segments. if (a.x == b.x) { return (a.x == c.x) && (((a.y < c.y) && (c.y < b.y)) || ((b.y < c.y) && (c.y < a.y))); } else if (a.y == b.y) { return (a.y == c.y) && (((a.x < c.x) && (c.x < b.x)) || ((b.x < c.x) && (c.x < a.x))); } // Or use the general case. return (vecDir(a, b, c, tolerance) == 0) && inBetween(a, b, c); }
/* intersect1: * Returns true if the polygon segment [q,n) blocks a and b from seeing * each other. * More specifically, returns true iff the two segments intersect as open * sets, or if q lies on (a,b) and either n and p lie on * different sides of (a,b), i.e., wind(a,b,n)*wind(a,b,p) < 0, or the polygon * makes a left turn at q, i.e., wind(p,q,n) > 0. * * We are assuming the p,q,n are three consecutive vertices of a barrier * polygon with the polygon interior to the right of p-q-n. * * Note that given the constraints of our problem, we could probably * simplify this code even more. For example, if abq are collinear, but * q is not in (a,b), we could return false since n will not be in (a,b) * nor will the (a,b) intersect (q,n). * * Also note that we are computing w_abq twice in a tour of a polygon, * once for each edge of which it is a vertex. */ static int intersect1(Ppoint_t a,Ppoint_t b,Ppoint_t q,Ppoint_t n, Ppoint_t p) { int w_abq; int w_abn; int w_qna; int w_qnb; w_abq = wind(a,b,q); w_abn = wind(a,b,n); /* If q lies on (a,b),... */ if ((w_abq == 0) && inBetween (a,b,q)) { return ((w_abn * wind(a,b,p) < 0) || (wind(p,q,n) > 0)); } else { w_qna = wind(q,n,a); w_qnb = wind(q,n,b); /* True if q and n are on opposite sides of ab, * and a and b are on opposite sides of qn. */ return (((w_abq * w_abn) < 0) && ((w_qna * w_qnb) < 0)); } }
// Returns true iff the point c lies on the closed segment ab. // bool pointOnLine(const Point& a, const Point& b, const Point& c, const double tolerance) { return (vecDir(a, b, c, tolerance) == 0) && inBetween(a, b, c); }
void set_sieve_size(int kilobytes) { sieve_size = inBetween(1, kilobytes, 2048); }