int main() { if (nge(INT_MIN, INT_MAX) != 0) abort(); if (nge(INT_MAX, INT_MIN) != -1) abort(); if (ngt(INT_MIN, INT_MAX) != 0) abort(); if (ngt(INT_MAX, INT_MIN) != -1) abort(); if (nle(INT_MIN, INT_MAX) != -1) abort(); if (nle(INT_MAX, INT_MIN) != 0) abort(); if (nlt(INT_MIN, INT_MAX) != -1) abort(); if (nlt(INT_MAX, INT_MIN) != 0) abort(); if (neq(INT_MIN, INT_MAX) != 0) abort(); if (neq(INT_MAX, INT_MIN) != 0) abort(); if (nne(INT_MIN, INT_MAX) != -1) abort(); if (nne(INT_MAX, INT_MIN) != -1) abort(); if (ngeu(0, ~0U) != 0) abort(); if (ngeu(~0U, 0) != -1) abort(); if (ngtu(0, ~0U) != 0) abort(); if (ngtu(~0U, 0) != -1) abort(); if (nleu(0, ~0U) != -1) abort(); if (nleu(~0U, 0) != 0) abort(); if (nltu(0, ~0U) != -1) abort(); if (nltu(~0U, 0) != 0) abort(); exit(0); }
// check if the circle and the line intersect (including touch) bool is_intersect_l2c(const circle& c, const point& l1, const point& l2){ point p = c.c; p.x += l1.y - l2.y; p.y += l2.x - l1.x; p = intersection_point_l2l(p, c.c, l1, l2); return nlt(c.r, distance_p2p(p, c.c)); }
/* usage : * 1. the sort strategy used here: sorted by y-axis and sorted by x-axis if the y-aixs is the same. e.g. bool operator<(const point& a, const point& b){ return a.y == b.y ? a.x < b.x : a.y < b.y; } 2. call grahams_scan(pnt, n, res); 3. function returns number of vertex in convex hull and store them in res[] in counterclockwise order. NOTE that you can change the comparison from 'nlt(>=)' to 'gt(>)' to obtain all the points on the boundary of convex hull including non-vertex points. */ int grahams_scan(point pnt[], int n, point res[]){ int i, len, top = 1; sort(pnt, pnt + n); if (n == 0) return 0; res[0] = pnt[0]; if (n == 1) return 1; res[1] = pnt[1]; if (n == 2) return 2; res[2] = pnt[2]; for (i = 2; i<n; ++i){ while (top && nlt(cross_product(pnt[i], res[top], res[top-1]), 0)) // use gt() to obtain all points on boundary top--; res[++top] = pnt[i]; } len = top; res[++top] = pnt[n - 2]; for (i = n - 3; i >= 0; i--) { while (top!=len && nlt(cross_product(pnt[i], res[top], res[top-1]), 0)) top--; // use gt() to obtain all points on boundary res[++top] = pnt[i]; } return top; // number of vertex of convex hull. }
ReadableStore* DfaDbReadonlySegment::buildDictZipStore(const Schema& schema, PathRef dir, StoreIterator& inputIter, const bm_uint_t* isDel, const febitvec* isPurged) const { std::unique_ptr<NestLoudsTrieStore> nlt(new NestLoudsTrieStore(schema)); auto fpath = dir / ("colgroup-" + schema.m_name + ".nlt"); nlt->build_by_iter(schema, fpath, inputIter, isDel, isPurged); return nlt.release(); }
ReadableStore* DfaDbReadonlySegment::buildStore(const Schema& schema, SortableStrVec& storeData) const { ReadableStore* store = ReadonlySegment::buildStore(schema, storeData); if (store) { return store; } std::unique_ptr<NestLoudsTrieStore> nlt(new NestLoudsTrieStore(schema)); if (storeData.m_index.size() == 0) { const size_t fixlen = schema.getFixedRowLen(); assert(fixlen > 0); patchStrVec(storeData, fixlen); } nlt->build(schema, storeData); return nlt.release(); }