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


C++ IStack::pop方法代码示例

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


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

示例1: stackCheck

void stackCheck(IStack<int> &stack){
	cout << "Testing stack interface:" << endl;

	for (int i = 0; i < 3; i++){
		cout << " pushing value: " << i << endl;
		stack.push(i);
	}

	while(stack.size()){
		cout << " popped value: " << stack.pop() << endl;
	}
}
开发者ID:sillypog,项目名称:opendatastructures,代码行数:12,代码来源:stack_check.cpp

示例2: calculate

int CalcStack::calculate(string const &inputString)
{
	IStack<int> *stack = new LinkedStack<int>();
	vector<string> tokens = separate(inputString);

    for(const string &token : tokens)
    {
		if (isOperator(token))
        {
			int second = stack->pop();
			int first = stack->pop();
			stack->push(doOperation(token[0], first, second));
        }
        else if (isNumber(token))
        {
			stack->push(stoi(token));
        }
    }
    int result = stack->top();
    delete stack;
    return result;
}
开发者ID:gkirgizov,项目名称:Qt,代码行数:22,代码来源:calcstack.cpp

示例3: All_Intersections

bool IsoSurface::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThreadData *Thread)
{
    int Side1 = 0, Side2 = 0, itrace = 0;
    DBL Depth1 = 0.0, Depth2 = 0.0;
    BasicRay New_Ray;
    Vector3d IPoint;
    Vector3d Plocal, Dlocal;
    DBL tmax = 0.0, tmin = 0.0, tmp = 0.0;
    DBL maxg = max_gradient;
    int i = 0 ; /* count of intervals in stack - 1      */
    int IFound = false;
    int begin = 0, end = 0;
    bool in_shadow_test = false;
    Vector3d VTmp;

    Thread->Stats()[Ray_IsoSurface_Bound_Tests]++;

    if(container->Intersect(ray, Trans, Depth1, Depth2, Side1, Side2)) /* IsoSurface_Bound_Tests */
    {
        Thread->Stats()[Ray_IsoSurface_Bound_Tests_Succeeded]++;

        in_shadow_test = ray.IsShadowTestRay();

        if(Depth1 < 0.0)
            Depth1 = 0.0;

        if(Trans != NULL)
        {
            MInvTransPoint(Plocal, ray.Origin, Trans);
            MInvTransDirection(Dlocal, ray.Direction, Trans);
        }
        else
        {
            Plocal = ray.Origin;
            Dlocal = ray.Direction;
        }

        Thread->isosurfaceData->Inv3 = 1;

        if(closed != false)
        {
            VTmp = Plocal + Depth1 * Dlocal;
            tmp = Vector_Function(Thread->functionContext, VTmp);
            if(Depth1 > accuracy)
            {
                if(tmp < 0.0)                   /* The ray hits the bounding shape */
                {
                    IPoint = ray.Evaluate(Depth1);
                    if(Clip.empty() || Point_In_Clip(IPoint, Clip, Thread))
                    {
                        Depth_Stack->push(Intersection(Depth1, IPoint, this, 1, Side1));
                        IFound = true;
                        itrace++;
                        Thread->isosurfaceData->Inv3 *= -1;
                    }
                }
            }
            else
            {
                if(tmp < (maxg * accuracy * 4.0))
                {
                    Depth1 = accuracy * 5.0;
                    VTmp = Plocal + Depth1 * Dlocal;
                    if(Vector_Function(Thread->functionContext, VTmp) < 0)
                        Thread->isosurfaceData->Inv3 = -1;
                    /* Change the sign of the function (IPoint is in the bounding shpae.)*/
                }
                VTmp = Plocal + Depth2 * Dlocal;
                if(Vector_Function(Thread->functionContext, VTmp) < 0.0)
                {
                    IPoint = ray.Evaluate(Depth2);
                    if(Clip.empty() || Point_In_Clip(IPoint, Clip, Thread))
                    {
                        Depth_Stack->push(Intersection(Depth2, IPoint, this, 1, Side2));
                        IFound = true;
                    }
                }
            }
        }

        /*  METHOD 2   by R. Suzuki */
        tmax = Depth2 = min(Depth2, BOUND_HUGE);
        tmin = Depth1 = min(Depth2, Depth1);
        if((tmax - tmin) < accuracy)
        {
            if (IFound)
                Depth_Stack->pop(); // we added an intersection already, so we need to undo that
            return (false);
        }
        Thread->Stats()[Ray_IsoSurface_Tests]++;
        if((Depth1 < accuracy) && (Thread->isosurfaceData->Inv3 == 1))
        {
            /* IPoint is on the isosurface */
            VTmp = Plocal + tmin * Dlocal;
            if(fabs(Vector_Function(Thread->functionContext, VTmp)) < (maxg * accuracy * 4.0))
            {
                tmin = accuracy * 5.0;
                VTmp = Plocal + tmin * Dlocal;
                if(Vector_Function(Thread->functionContext, VTmp) < 0)
                    Thread->isosurfaceData->Inv3 = -1;
//.........这里部分代码省略.........
开发者ID:quickfur,项目名称:povray,代码行数:101,代码来源:isosurface.cpp


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