当前位置: 首页>>代码示例>>C++>>正文


C++ Span类代码示例

本文整理汇总了C++中Span的典型用法代码示例。如果您正苦于以下问题:C++ Span类的具体用法?C++ Span怎么用?C++ Span使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Span类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: tmps

/// Locate a span in the state.
/// \param s The span we are locating.
/// \return Those ItemTokens that the span comprises.
const ItemTokens State::locate_span(const Span& s) const {
	Span tmps(_frontier);
	assert(tmps.left() <= s.left());
	assert(tmps.right() >= s.right());

	ItemTokens is;
	ItemTokens::const_iterator i;
	for (i = _frontier.begin(); i != _frontier.end(); i++) {
		if ((*i)->span().left() == s.left())
			break;
		assert((*i)->span().left() < s.left());
	}
	assert((*i)->span().left() == s.left());

	for (; i != _frontier.end(); i++) {
		is.push_back(*i);
		if ((*i)->span().right() == s.right())
			break;
		assert((*i)->span().right() < s.right());
	}
	assert((*i)->span().right() == s.right());

	assert(!is.empty());
	return is;
}
开发者ID:arne-cl,项目名称:turian-parser,代码行数:28,代码来源:State.C

示例2: ArcArcIntof

	int ArcArcIntof(const Span& arc0, const Span& arc1, Point& pLeft, Point& pRight) {
		// Intof 2 arcs
		int numInts = Intof(Circle(arc0.pc, arc0.radius), Circle(arc1.pc, arc1.radius), pLeft, pRight);

		if(numInts == 0) {
			pLeft = arc0.p1;
			pLeft.ok = false;
			return 0;
		}
		int nLeft  = arc0.OnSpan(pLeft) && arc1.OnSpan(pLeft);
		int nRight = (numInts == 2)?arc0.OnSpan(pRight) && arc1.OnSpan(pRight) : 0;
		if(nLeft == 0 && nRight) pLeft = pRight;
		return nLeft + nRight;
	}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:14,代码来源:Finite.cpp

示例3: testRuntimeSpan

void testRuntimeSpan(Span sp)
{
    ASSERT_NOEXCEPT(std::as_bytes(sp));

    auto spBytes = std::as_bytes(sp);
    using SB = decltype(spBytes);
    ASSERT_SAME_TYPE(const std::byte, typename SB::element_type);

    if (sp.extent == std::dynamic_extent)
        assert(spBytes.extent == std::dynamic_extent);
    else
        assert(spBytes.extent == sizeof(typename Span::element_type) * sp.extent);

    assert((void *) spBytes.data() == (void *) sp.data());
    assert(spBytes.size() == sp.size_bytes());
}
开发者ID:ingowald,项目名称:llvm-project,代码行数:16,代码来源:as_bytes.pass.cpp

示例4: ParseFromStream

already_AddRefed<nsIDocument>
DOMParser::ParseFromBuffer(Span<const uint8_t> aBuf, SupportedType aType,
                           ErrorResult& aRv)
{
  // The new stream holds a reference to the buffer
  nsCOMPtr<nsIInputStream> stream;
  nsresult rv = NS_NewByteInputStream(getter_AddRefs(stream),
                                      reinterpret_cast<const char *>(aBuf.Elements()),
                                      aBuf.Length(), NS_ASSIGNMENT_DEPEND);
  if (NS_FAILED(rv)) {
    aRv.Throw(rv);
    return nullptr;
  }

  return ParseFromStream(stream, VoidString(), aBuf.Length(), aType, aRv);
}
开发者ID:artines1,项目名称:gecko-dev,代码行数:16,代码来源:DOMParser.cpp

示例5: SpanIntersections

void CArea::SpanIntersections(const Span& span, std::list<Point> &pts)const
{
	// this returns all the intersections of this area with the given span, ordered along the span

	// get all points where this area's curves intersect the span
	std::list<Point> pts2;
	for(std::list<CCurve>::const_iterator It = m_curves.begin(); It != m_curves.end(); It++)
	{
		const CCurve &c = *It;
		c.SpanIntersections(span, pts2);
	}

	// order them along the span
	std::multimap<double, Point> ordered_points;
	for(std::list<Point>::iterator It = pts2.begin(); It != pts2.end(); It++)
	{
		Point &p = *It;
		double t;
		if(span.On(p, &t))
		{
			ordered_points.insert(std::make_pair(t, p));
		}
	}

	// add them to the given list of points
	for(std::multimap<double, Point>::iterator It = ordered_points.begin(); It != ordered_points.end(); It++)
	{
		Point p = It->second;
		pts.push_back(p);
	}
}
开发者ID:gorilux,项目名称:libarea,代码行数:31,代码来源:Area.cpp

示例6: main

int main()
{
    std::srand(time(0));
    Span sp = Span(10000);
    try
    {
        while (1)
            sp.addNumber(rand());
    }
    catch(std::exception &e)
    {
        std::cout	<< e.what() << std::endl;
    }
    std::cout << sp.shortestSpan() << std::endl;
    std::cout << sp.longestSpan() << std::endl;
}
开发者ID:MickaelBlet,项目名称:42_Piscine_CPP,代码行数:16,代码来源:main.cpp

示例7: testRuntimeSpan

void testRuntimeSpan(Span sp)
{
    LIBCPP_ASSERT((noexcept(sp.template first<Count>())));
    LIBCPP_ASSERT((noexcept(sp.first(Count))));
    auto s1 = sp.template first<Count>();
    auto s2 = sp.first(Count);
    using S1 = decltype(s1);
    using S2 = decltype(s2);
    ASSERT_SAME_TYPE(typename Span::value_type, typename S1::value_type);
    ASSERT_SAME_TYPE(typename Span::value_type, typename S2::value_type);
    static_assert(S1::extent == Count, "");
    static_assert(S2::extent == std::dynamic_extent, "");
    assert(s1.data() == s2.data());
    assert(s1.size() == s2.size());
    assert(std::equal(s1.begin(), s1.end(), sp.begin()));
}
开发者ID:ingowald,项目名称:llvm-project,代码行数:16,代码来源:first.pass.cpp

示例8: NearestPointToSpan

Point Span::NearestPointToSpan(const Span& p, double &d)const
{
	Point midpoint = MidParam(0.5);
	Point np = p.NearestPoint(m_p);
	Point best_point = m_p;
	double dist = np.dist(m_p);
	if(p.m_start_span)dist -= (CArea::m_accuracy * 2); // give start of curve most priority
	Point npm = p.NearestPoint(midpoint);
	double dm = npm.dist(midpoint) - CArea::m_accuracy; // lie about midpoint distance to give midpoints priority
	if(dm < dist){dist = dm; best_point = midpoint;}
	Point np2 = p.NearestPoint(m_v.m_p);
	double dp2 = np2.dist(m_v.m_p);
	if(dp2 < dist){dist = dp2; best_point = m_v.m_p;}
	d = dist;
	return best_point;
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例9: DoesIntersInterfere

	static bool DoesIntersInterfere(const Point& pInt, const Kurve& k, double offset)  {
		// check that intersections don't interfere with the original kurve 
		Span sp;
		Point dummy;
		int kCheckVertex = 0;
		k.Get(kCheckVertex++, sp.p0, sp.pc);

		offset = fabs(offset) - geoff_geometry::TOLERANCE;
		while(kCheckVertex <= k.nSpans()) {
			sp.dir = k.Get(kCheckVertex++, sp.p1, sp.pc);
			sp.SetProperties(true);
			// check for interference 
			if(Dist(sp, pInt, dummy) < offset) return true;
			sp.p0 = sp.p1;
		}
		return false;	// intersection is ok
	}
开发者ID:Heeks,项目名称:libarea-old,代码行数:17,代码来源:offset.cpp

示例10: testConstexprSpan

constexpr bool testConstexprSpan(Span sp)
{
    LIBCPP_ASSERT((noexcept(sp.template subspan<Offset>())));
    LIBCPP_ASSERT((noexcept(sp.subspan(Offset))));
    auto s1 = sp.template subspan<Offset>();
    auto s2 = sp.subspan(Offset);
    using S1 = decltype(s1);
    using S2 = decltype(s2);
    ASSERT_SAME_TYPE(typename Span::value_type, typename S1::value_type);
    ASSERT_SAME_TYPE(typename Span::value_type, typename S2::value_type);
    static_assert(S1::extent == (Span::extent == std::dynamic_extent ? std::dynamic_extent : Span::extent - Offset), "");
    static_assert(S2::extent == std::dynamic_extent, "");
    return
        s1.data() == s2.data()
     && s1.size() == s2.size()
     && std::equal(s1.begin(), s1.end(), sp.begin() + Offset, sp.end());
}
开发者ID:lichray,项目名称:libcxx,代码行数:17,代码来源:subspan.pass.cpp

示例11: main

int main()
{
	Span sp = Span(5);
	Span sp1 = Span(10000);
	Span sp2 = Span(10000);
	Span sp3 = Span(10);
	Span sp4 = Span(1);

	srand(time(NULL));
	sp.addNumber(5);
	sp.addNumber(3);
	sp.addNumber(17);
	sp.addNumber(9);
	sp.addNumber(11);
	std::cout << sp.shortestSpan() << std::endl;
	std::cout << sp.longestSpan() << std::endl;

	sp1.RandInterval(9000);
	std::cout << sp1.shortestSpan() << std::endl;
	std::cout << sp1.longestSpan() << std::endl;

	sp2.Interval(42, 9000);
	std::cout << sp2.shortestSpan() << std::endl;
	std::cout << sp2.longestSpan() << std::endl;

	sp3.RandInterval(9000);
	std::cout << sp3.shortestSpan() << std::endl;
	std::cout << sp3.longestSpan() << std::endl;

	sp4.addNumber(5);
	sp4.addNumber(6);
	std::cout << sp4.shortestSpan() << std::endl;
	std::cout << sp4.longestSpan() << std::endl;
	return (0);
}
开发者ID:vklaouse,项目名称:Piscine-CPP,代码行数:35,代码来源:main.cpp

示例12: main

int main()
{
	srand(std::time(0));
	try
	{
		Span sp = Span(5);
		sp.addNumber(5);
		sp.addNumber(3);
		sp.addNumber(17);
		sp.addNumber(9);
		sp.addNumber(11);
		std::cout << sp.shortestSpan() << std::endl;
		std::cout << sp.longestSpan() << std::endl;

		Span big(10000);
		big.initAll(randNumber);
		std::cout << big.shortestSpan() << std::endl;
		std::cout << big.longestSpan() << std::endl;

		Span sp2(1);
		std::cout << sp2.shortestSpan() << std::endl;
	}
	catch (std::exception & e)
	{
		std::cout << e.what() << std::endl;
	}
}
开发者ID:Strade288,项目名称:42,代码行数:27,代码来源:main.cpp

示例13: set_uri

void URI::set_uri(
    uri_identifier_code_t id,
    const Span<const uint8_t> &uri_field
)
{
    delete[] _uri;

    if (uri_field.empty()) {
        _uri = NULL;
        _uri_size = 0;
        return;
    }

    _uri = new uint8_t[uri_id_code_size + uri_field.size()];
    _uri_size = uri_id_code_size + uri_field.size();
    _uri[uri_id_index] = id;
    memcpy(_uri + uri_field_index, uri_field.data(), uri_field.size());
}
开发者ID:MarceloSalazar,项目名称:mbed-os,代码行数:18,代码来源:URI.cpp

示例14: parseVar

static void parseVar (Lexer& lex, SigPtr sig)
{
	std::string name;
	TyPtr ty;
	Span sp;

	parseVar(lex, name, ty, sp);

	for (auto& a : sig->args)
		if (a.first == name)
		{
			std::ostringstream ss;
			ss << "variable '" << name << "' already declared in signature";
			throw sp.die(ss.str());
		}

	sig->args.push_back(Sig::Arg { name, ty });
	sig->span = sig->span + sp;
}
开发者ID:iitalics,项目名称:Jupiter,代码行数:19,代码来源:Parser.cpp

示例15: getNextPixCenter

void TriRasterizer::drawSpansBetweenEdges(const Edge &longEdge, const Edge &shortEdge)
{
    if(shortEdge.m_V1.m_Y == shortEdge.m_V2.m_Y) return; // horizontal edge, return

    // snap current y-axis val to next pixel center
    // using short edge as the reference top
    float currY = getNextPixCenter(shortEdge.m_V1.m_Y);
    float topY  = shortEdge.m_V2.m_Y;

    // get current colors
    Color currLongColor;
    Color currShortColor;

    // get inverse slopes
    float shortInvSlope = (shortEdge.m_V2.m_X == shortEdge.m_V1.m_X) ? 0.f :
        (shortEdge.m_V2.m_X-shortEdge.m_V1.m_X)/(shortEdge.m_V2.m_Y-shortEdge.m_V1.m_Y);
    float longInvSlope  = (longEdge.m_V2.m_X == longEdge.m_V1.m_X) ? 0.f :
        (longEdge.m_V2.m_X-longEdge.m_V1.m_X)/(longEdge.m_V2.m_Y-longEdge.m_V1.m_Y);

        // get current x-axis vals
    float currLongX  = longEdge.m_V1.m_X + (currY-longEdge.m_V1.m_Y) * longInvSlope;
    float currShortX = shortEdge.m_V1.m_X + (currY-shortEdge.m_V1.m_Y) * shortInvSlope;

    // move along edges
    Span span;
    while (currY < topY)
    {
        // TODO: only calc interpolatants once
        interpolateColor(currY, shortEdge.m_V1.m_Y, shortEdge.m_V2.m_Y,
            shortEdge.m_V1.m_Color, shortEdge.m_V2.m_Color, currShortColor);
        interpolateColor(currY, longEdge.m_V1.m_Y, longEdge.m_V2.m_Y,
            longEdge.m_V1.m_Color, longEdge.m_V2.m_Color, currLongColor);

        // set & draw span
        span.setSpan(currShortColor, currLongColor, currShortX, currLongX, currY);
        drawSpan(span);

        currY += 1.f;
        currShortX += shortInvSlope;
        currLongX += longInvSlope;
    }
}
开发者ID:rapatel,项目名称:SoftRast,代码行数:42,代码来源:main.cpp


注:本文中的Span类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。