예제 #1
0
struct MyTime Max (struct MyTime t1, struct MyTime t2)
{
  if (LessThan (t1, t2))
    return t2;
  else
    return t1;
}
예제 #2
0
파일: Fsanity.c 프로젝트: 8l/csolve
int
SanityCheck1(Heap * h, Item * i)
{
  Heap * h1;

  if(h == NULL_HEAP)
  {
     return(TRUE);
  }

  h1 = h;
  do
  {
    if(LessThan(ITEM(h1), i))
    {
      return(FALSE);
    }
    if(!SanityCheck1(CHILD(h1), ITEM(h1)))
    {
      return(FALSE);
    }

    h1 = FORWARD(h1);
  }
  while(h1 != h);

  return(TRUE);
}
static void Stopper()
{
	TestAgent aTestAgent(9003);
	ORWELL_LOG_INFO("create subscriber");
	zmq::context_t aContext(1);
	orwell::com::Receiver aSubscriber("tcp://127.0.0.1:9001", ZMQ_SUB, orwell::com::ConnectionMode::CONNECT, aContext);
	aTestAgent.sendCommand("ping", std::string("pong"));
	aTestAgent.sendCommand("add team TEAM");
	aTestAgent.sendCommand("add robot toto TEAM");
	aTestAgent.sendCommand("set robot toto video_url fake");
	aTestAgent.sendCommand("register robot toto");
	ExpectGameTime(Equals(2), aTestAgent);
	aTestAgent.sendCommand("start game");
	usleep(100 * 1000);
	bool aIsRunning = boost::lexical_cast< bool >(
			aTestAgent.sendCommand("get game running", boost::none));
	ORWELL_ASSERT_TRUE(aIsRunning, "Game should be running.");
	usleep(1000 * 1000);
	ExpectGameTime(MoreThan(0), aTestAgent);
	ExpectGameTime(LessThan(2), aTestAgent);
	usleep(1000 * 1000);
	aIsRunning = boost::lexical_cast< bool >(
			aTestAgent.sendCommand("get game running", boost::none));
	ORWELL_ASSERT_TRUE((!aIsRunning), "Game should not be running any more.");
	aTestAgent.sendCommand("stop application");
}
예제 #4
0
void JitArm::fcmpu(UGeckoInstruction inst)
{
	INSTRUCTION_START
	JITDISABLE(bJITFloatingPointOff)
	u32 a = inst.FA, b = inst.FB;
	int cr = inst.CRFD;

	ARMReg vA = fpr.R0(a);
	ARMReg vB = fpr.R0(b);
	ARMReg fpscrReg = gpr.GetReg();
	ARMReg crReg = gpr.GetReg();
	Operand2 FPRFMask(0x1F, 0xA); // 0x1F000
	Operand2 LessThan(0x8, 0xA); // 0x8000
	Operand2 GreaterThan(0x4, 0xA); // 0x4000
	Operand2 EqualTo(0x2, 0xA); // 0x2000
	Operand2 NANRes(0x1, 0xA); // 0x1000
	FixupBranch Done1, Done2, Done3;
	LDR(fpscrReg, R9, PPCSTATE_OFF(fpscr));
	BIC(fpscrReg, fpscrReg, FPRFMask);

	VCMPE(vA, vB);
	VMRS(_PC);
	SetCC(CC_LT);
		ORR(fpscrReg, fpscrReg, LessThan);
		MOV(crReg,  8);
		Done1 = B();
	SetCC(CC_GT);
		ORR(fpscrReg, fpscrReg, GreaterThan);
		MOV(crReg,  4);
		Done2 = B();
	SetCC(CC_EQ);
		ORR(fpscrReg, fpscrReg, EqualTo);
		MOV(crReg,  2);
		Done3 = B();
	SetCC();

	ORR(fpscrReg, fpscrReg, NANRes);
	MOV(crReg,  1);

	VCMPE(vA, vA);
	VMRS(_PC);
	FixupBranch NanA = B_CC(CC_NEQ);
	VCMPE(vB, vB);
	VMRS(_PC);
	FixupBranch NanB = B_CC(CC_NEQ);
	FixupBranch Done4 = B();

	SetJumpTarget(NanA);
	SetJumpTarget(NanB);

	SetFPException(fpscrReg, FPSCR_VXSNAN);

	SetJumpTarget(Done1);
	SetJumpTarget(Done2);
	SetJumpTarget(Done3);
	SetJumpTarget(Done4);
	STRB(crReg, R9, PPCSTATE_OFF(cr_fast) + cr);
	STR(fpscrReg, R9, PPCSTATE_OFF(fpscr));
	gpr.Unlock(fpscrReg, crReg);
}
예제 #5
0
bool VectorBase<scalar,index,SizeAtCompileTime>::operator>(const scalar s)const
{
	for ( index i = 0 ; i < this->size() ; ++ i )
	{
		if(LessThan(this->operator[](i),s))
			return false;
	}
	return true;
}
예제 #6
0
bool AsyncTaskBase::LessThanGroupLevelNoString(const AsyncTaskBase* l, const AsyncTaskBase* r)
{
	// Only one task can be running at a time at the group level;
	if(l->IsRunning()) return false;
	if(r->IsRunning()) return true;

	// if dependencies aren't an issue, compare based upon other criteria
	return LessThan(l, r);
}
예제 #7
0
파일: Script.c 프로젝트: Fulgen301/SGGP
func Damage()
{
  if(SEqual(GetAction(),"An")) if(LessThan(50,GetDamage()))
  {
    SetAction("FlackerAn");
    if(!Local(0)) ObjectSetAction(Local(0)=CreateObject(LJ3V,-20,16),"Neon");
  }
  return(1);
}
예제 #8
0
bool VectorBase<scalar,index,SizeAtCompileTime>::operator>(const VectorBase<scalar,index,S> &vec)const
{
	if (this->size() != vec.size() )
		return false;
	for ( index i = 0 ; i < this->size() ; ++ i ){
		if(LessThan(this->operator[](i),vec[i]))
			return false;
	}
	return true;
}
        //return how many of the sums less than `val`
        //  -  `sum` is the new sums which hasn't been inserted
        //  -  `val` is the `lower` or `upper+1`
        int LessThan(Node* root, long long sum, int val, int res) {

            if (!root) return res;

            if ( sum - root->val < val) {
                //if (sum[j, i] < val), which means all of the right branch must be less than `val`
                //so we add the amounts of sums in right branch, and keep going the left branch.
                res += (root->cnt - (root->left ? root->left->cnt : 0) );
                return LessThan(root->left, sum, val, res);
            }else if ( sum - root->val > val) {
                //if (sum[j, i] > val), which means all of left brach must be greater than `val`
                //so we just keep going the right branch.
                return LessThan(root->right, sum, val, res);
            }else {
                //if (sum[j,i] == val), which means we find the correct place,
                //so we just return the the amounts of right branch.]
                return res + (root->right ? root->right->cnt : 0);
            }
        }
예제 #10
0
파일: Map.hpp 프로젝트: xyuan/coolfluid3
void Map<KEY,DATA>::sort_keys()
{
  if (!m_sorted)
  {
    std::sort(begin(), end(), LessThan());
    m_sorted = true;

    cf3_assert_desc ("multiple keys in the map are detected. Not allowed in this map" , 
      std::unique (begin(), end(), unique_key ) - begin() == (int) size() );  
  }
}
예제 #11
0
// process_Lt2
static bool process_Lt2(
    ValuesInsn* pArgs,
    Ty*         out_truety,
    Ty*         out_falsety )
{
    Ty ty1 = pArgs->GetSx()->GetTy();
    Ty ty2 = pArgs->GetSy()->GetTy();

    TyInteger oTy1 = TyInteger::Parse(ty1);
        if (! oTy1.IsValid()) return false;

    TyInteger oTy2 = TyInteger::Parse(ty2);
        if (! oTy2.IsValid()) return false;

    *out_truety  = LessThan(oTy1, oTy2).Unparse();
    *out_falsety = GreaterThanOrEqual(oTy1, oTy2).Unparse();

    return true;
} // process_Lt2
예제 #12
0
int PointInAABB(Point p, AABB a)
{
	return GreaterThan(p,a.min) & LessThan(p,a.max);
}
예제 #13
0
value_t RelationFromDouble( double rel )
{
	if (rel < 0) return LessThan();
	if (rel > 0) return GreaterThan();
	return EqualTo();
}
예제 #14
0
파일: dec.cpp 프로젝트: AEonZR/GtkRadiant
//=================================================================
void MapOut(int NumNodes,int NumTris, NODE *Node, TRI *Tri)
{
	extern	double backface;
	extern	double xmin, xmax, ymin, ymax, zmin, zmax;
	BRUSH	brush;
	char	hint[32], skip[32];
	int		i, j;
	int		face;
        /*
	ghCursorCurrent = LoadCursor(NULL,IDC_WAIT);
	SetCursor(ghCursorCurrent);
        */
	UseDetail = 1; // this is temporary
	MakeBrushes(NumTris,Node,Tri,TRUE,0,Texture[Game][0],Texture[Game][1],Texture[Game][2]);

	if(AddHints || GimpHints)
	{
		switch(Game)
		{
		case SIN:
			strcpy(hint,"generic/misc/hint");
			strcpy(skip,"generic/misc/skip");
			break;
		case HALFLIFE:
			strcpy(hint,"HINT");
			strcpy(skip,"HINT");
			break;
		case HERETIC2:
			strcpy(hint,"general/hint");
			strcpy(skip,"general/skip");
			break;
		case KINGPIN:
			strcpy(hint,"common/0_hint");
			strcpy(skip,"common/0_skip");
			break;
		case QUAKE3:
			strcpy(hint,"common/hint");
			strcpy(skip,"common/skip");
			break;
		default:
			strcpy(hint,"e1u1/hint");
			strcpy(skip,"e1u1/skip");
		}
	}

	if( GimpHints )
		MakeBrushes(NumTris,Node,Tri,FALSE,HINT_OFFSET,hint,hint,hint);

	if( AddHints==1 )
	{
		int   j0, j1, j2, k, k0, k1;
		int   q[4];
		int   w,h,h0,h1,t,OK;
		float s[3];
		double front;
		int   MaxHints; // We don't want a whole slew of hint brushes, which we'd get
		                // with low decimation values and our current placement scheme.
		                // Limit number of hint brushes to number of undecimated grid
		                // squares.

		switch(Plane)
		{
		case PLANE_XY1:
			front  = LessThan(zmin,32.);
			break;
		case PLANE_XZ0:
			front  = MoreThan(ymax,32.);
			break;
		case PLANE_XZ1:
			front  = LessThan(ymin,32.);
			break;
		case PLANE_YZ0:
			front  = MoreThan(xmax,32.);
			break;
		case PLANE_YZ1:
			front  = LessThan(xmin,32.);
			break;
		default:
			front  = MoreThan(zmax,32.);
		}

		for(i=0; i<NumTris; i++)
			Tri[i].flag = 0;

		switch(Plane)
		{
		case PLANE_XZ0:
		case PLANE_XZ1:
			j0 = 1;
			j1 = 0;
			j2 = 2;
			break;
		case PLANE_YZ0:
		case PLANE_YZ1:
			j0 = 0;
			j1 = 1;
			j2 = 2;
			break;
		default:
			j0 = 2;
			j1 = 0;
			j2 = 1;
		}

		brush.Number = 0;
		brush.NumFaces = 6;
		MaxHints = NH*NV-1;
		for(w=1; w<min(16,NH) && brush.Number < MaxHints; w++)
		{
			for(h=max(1,w/2); h<min(16,NV) && brush.Number < MaxHints; h++)
			{
				for(i=0; i<=NH-w && brush.Number < MaxHints; i++)
				{
					for(j=0; j<=NV-h && brush.Number < MaxHints; j++)
					{
						q[0] = i*NVP1+j;
						q[2] = q[0] + w*NVP1 + h;
						switch(Plane)
						{
						case PLANE_XY1:
						case PLANE_XZ0:
						case PLANE_YZ1:
							q[1] = q[0] + h;
							q[3] = q[2] - h;
							break;
						default:
							q[1] = q[2] - h;
							q[3] = q[0] + h;
						}
						for(k=0, OK=1; k<NumTris && OK; k++)
						{
							if(Tri[k].min[j1] >= max(Node[q[0]].p[j1],Node[q[2]].p[j1])) continue;
							if(Tri[k].min[j2] >= max(Node[q[0]].p[j2],Node[q[2]].p[j2])) continue;
							if(Tri[k].max[j1] <= min(Node[q[0]].p[j1],Node[q[2]].p[j1])) continue;
							if(Tri[k].max[j2] <= min(Node[q[0]].p[j2],Node[q[2]].p[j2])) continue;

							for(h0=0; h0<4 && OK; h0++)
							{
								h1 = (h0+1)%4;
								for(t=0; t<3 && OK; t++)
								{
									s[t] = side(Node[q[h0]].p[j1],Node[q[h0]].p[j2],
										Node[q[h1]].p[j1],Node[q[h1]].p[j2],
										Node[Tri[k].v[t]].p[j1],Node[Tri[k].v[t]].p[j2]);
								}
								if((s[1] > 0 || s[2] > 0) && s[0] < 0) OK=0;
								if((s[2] > 0 || s[0] > 0) && s[1] < 0) OK=0;
								if((s[0] > 0 || s[1] > 0) && s[2] < 0) OK=0;
							}
						}
						if(!OK) continue;
						switch(Plane)
						{
						case PLANE_XZ0:
						case PLANE_XZ1:
							// front
							brush.face[0].v[0][0] = Node[q[2]].p[0];
							brush.face[0].v[0][1] = (float)front;
							brush.face[0].v[0][2] = Node[q[2]].p[2];

							brush.face[0].v[1][0] = Node[q[1]].p[0];
							brush.face[0].v[1][1] = (float)front;
							brush.face[0].v[1][2] = Node[q[1]].p[2];

							brush.face[0].v[2][0] = Node[q[0]].p[0];
							brush.face[0].v[2][1] = (float)front;
							brush.face[0].v[2][2] = Node[q[0]].p[2];

							// back
							brush.face[1].v[0][0] = Node[q[0]].p[0];
							brush.face[1].v[0][1] = (float)backface;
							brush.face[1].v[0][2] = Node[q[0]].p[2];

							brush.face[1].v[1][0] = Node[q[1]].p[0];
							brush.face[1].v[1][1] = (float)backface;
							brush.face[1].v[1][2] = Node[q[1]].p[2];

							brush.face[1].v[2][0] = Node[q[2]].p[0];
							brush.face[1].v[2][1] = (float)backface;
							brush.face[1].v[2][2] = Node[q[2]].p[2];

							for(k0=0; k0<brush.NumFaces-2; k0++)
							{
								k =k0+2;
								k1=(k0+1) % (brush.NumFaces-2);

								brush.face[k].v[0][0] = Node[q[k0]].p[0];
								brush.face[k].v[0][1] = (float)front;
								brush.face[k].v[0][2] = Node[q[k0]].p[2];

								brush.face[k].v[1][0] = Node[q[k1]].p[0];
								brush.face[k].v[1][1] = (float)front;
								brush.face[k].v[1][2] = Node[q[k1]].p[2];

								brush.face[k].v[2][0] = Node[q[k1]].p[0];
								brush.face[k].v[2][1] = (float)backface;
								brush.face[k].v[2][2] = Node[q[k1]].p[2];
							}
							break;
						case PLANE_YZ0:
						case PLANE_YZ1:
							// front
							brush.face[0].v[0][0] = (float)front;
							brush.face[0].v[0][1] = Node[q[2]].p[1];
							brush.face[0].v[0][2] = Node[q[2]].p[2];

							brush.face[0].v[1][0] = (float)front;
							brush.face[0].v[1][1] = Node[q[1]].p[1];
							brush.face[0].v[1][2] = Node[q[1]].p[2];

							brush.face[0].v[2][0] = (float)front;
							brush.face[0].v[2][1] = Node[q[0]].p[1];
							brush.face[0].v[2][2] = Node[q[0]].p[2];

							// back
							brush.face[1].v[0][0] = (float)backface;
							brush.face[1].v[0][1] = Node[q[0]].p[1];
							brush.face[1].v[0][2] = Node[q[0]].p[2];

							brush.face[1].v[1][0] = (float)backface;
							brush.face[1].v[1][1] = Node[q[1]].p[1];
							brush.face[1].v[1][2] = Node[q[1]].p[2];

							brush.face[1].v[2][0] = (float)backface;
							brush.face[1].v[2][1] = Node[q[2]].p[1];
							brush.face[1].v[2][2] = Node[q[2]].p[2];

							for(k0=0; k0<brush.NumFaces-2; k0++)
							{
								k =k0+2;
								k1=(k0+1) % (brush.NumFaces-2);

								brush.face[k].v[0][0] = (float)front;
								brush.face[k].v[0][1] = Node[q[k0]].p[1];
								brush.face[k].v[0][2] = Node[q[k0]].p[2];

								brush.face[k].v[1][0] = (float)front;
								brush.face[k].v[1][1] = Node[q[k1]].p[1];
								brush.face[k].v[1][2] = Node[q[k1]].p[2];

								brush.face[k].v[2][0] = (float)backface;
								brush.face[k].v[2][1] = Node[q[k1]].p[1];
								brush.face[k].v[2][2] = Node[q[k1]].p[2];
							}
							break;
						default:
							// front
							brush.face[0].v[0][0] = Node[q[2]].p[0];
							brush.face[0].v[0][1] = Node[q[2]].p[1];
							brush.face[0].v[0][2] = (float)front;

							brush.face[0].v[1][0] = Node[q[1]].p[0];
							brush.face[0].v[1][1] = Node[q[1]].p[1];
							brush.face[0].v[1][2] = (float)front;

							brush.face[0].v[2][0] = Node[q[0]].p[0];
							brush.face[0].v[2][1] = Node[q[0]].p[1];
							brush.face[0].v[2][2] = (float)front;

							// back
							brush.face[1].v[0][0] = Node[q[0]].p[0];
							brush.face[1].v[0][1] = Node[q[0]].p[1];
							brush.face[1].v[0][2] = (float)backface;

							brush.face[1].v[1][0] = Node[q[1]].p[0];
							brush.face[1].v[1][1] = Node[q[1]].p[1];
							brush.face[1].v[1][2] = (float)backface;

							brush.face[1].v[2][0] = Node[q[2]].p[0];
							brush.face[1].v[2][1] = Node[q[2]].p[1];
							brush.face[1].v[2][2] = (float)backface;

							for(k0=0; k0<brush.NumFaces-2; k0++)
							{
								k =k0+2;
								k1=(k0+1) % (brush.NumFaces-2);

								brush.face[k].v[0][0] = Node[q[k0]].p[0];
								brush.face[k].v[0][1] = Node[q[k0]].p[1];
								brush.face[k].v[0][2] = (float)front;

								brush.face[k].v[1][0] = Node[q[k1]].p[0];
								brush.face[k].v[1][1] = Node[q[k1]].p[1];
								brush.face[k].v[1][2] = (float)front;

								brush.face[k].v[2][0] = Node[q[k1]].p[0];
								brush.face[k].v[2][1] = Node[q[k1]].p[1];
								brush.face[k].v[2][2] = (float)backface;
							}
							break;
						} // switch (Plane)
						for(face=0; face<6; face++)
						{
							strcpy(brush.face[face].texture,(face<=1 ? skip : hint));
							brush.face[face].Shift[0] = 0;
							brush.face[face].Shift[1] = 0;
							brush.face[face].Rotate   = 0.;
							brush.face[face].Scale[0] = 1;
							brush.face[face].Scale[1] = 1;
							brush.face[face].Contents = CONTENTS_DETAIL;
							brush.face[face].Surface  = (face<=1 ? SURF_SKIP : SURF_HINT);
							brush.face[face].Value    = 0;
						}
						if(!brush.Number) OpenFuncGroup();
						MakeBrush(&brush);
						brush.Number++;
					} // for(j=
				}     // for(i=
			}         // for(h=
		}             // for(w=
		if(brush.Number) CloseFuncGroup();
	}
        /*
	ghCursorCurrent = ghCursorDefault;
	SetCursor(ghCursorCurrent);
        */
}
예제 #15
0
value_t InvertRelation( zone_t zone, value_t relation )
{
	return CALL_3( relation, GreaterThan(), EqualTo(), LessThan() );
}
 int LessThan(long long sum, int val) {
     return LessThan(root, sum, val, 0);
 }
예제 #17
0
value_t RelationFromInt( int rel )
{
	if (rel < 0) return LessThan();
	if (rel > 0) return GreaterThan();
	return EqualTo();
}
예제 #18
0
파일: ptr_lib.c 프로젝트: 8l/rose
bool LessOrEqual(struct IntStruct ptr,struct IntStruct other_ptr) {
	return LessThan(ptr, other_ptr) || Equality(ptr, other_ptr);
}
예제 #19
0
   int operatorTest(void)
   {
      gpstk::TestUtil testFramework("TimeSystem", "== Operator", __FILE__, __LINE__);
      std::string testMesg;

      gpstk::TimeSystem Compare(4);
      gpstk::TimeSystem Equivalent(4);
      gpstk::TimeSystem LessThan(3);
      gpstk::TimeSystem GreaterThan(5);

         //---------------------------------------------------------------------------
         //Does the == operator function correctly?
         //---------------------------------------------------------------------------
      testMesg = "Equivalent objects were not marked equivalent by ==";
      testFramework.assert(Compare == Equivalent, testMesg, __LINE__);
      testMesg = "Equivalent objects were marked not equivalent by ==";
      testFramework.assert(!(Compare == LessThan), testMesg, __LINE__);

      testFramework.changeSourceMethod("!= Operator");
         //---------------------------------------------------------------------------
         //Does the != operator function correctly?
         //---------------------------------------------------------------------------		
      testMesg = "Non-equivalent objects were marked equivalent by !=";
      testFramework.assert(Compare != LessThan, testMesg, __LINE__);
      testMesg = "Equivalent objects were marked equivalent by !=";
      testFramework.assert(!(Compare != Equivalent), testMesg, __LINE__);

      testFramework.changeSourceMethod("> Operator");
         //---------------------------------------------------------------------------
         //Does the > operator function correctly?
         //---------------------------------------------------------------------------
      testMesg = "Less-than object was not marked as lesser by the > operator";
      testFramework.assert(Compare > LessThan, testMesg, __LINE__);
      testMesg = "Less-than object was marked as greater by the > operator";
      testFramework.assert(!(LessThan > Compare), testMesg, __LINE__);
      testMesg = "Equivalent objects were marked as non-equivalent by the > operator";
      testFramework.assert(!(Compare > Equivalent), testMesg, __LINE__);

      testFramework.changeSourceMethod("< Operator");
         //---------------------------------------------------------------------------
         //Does the < operator function correctly?
         //---------------------------------------------------------------------------
      testMesg = "Greater-than object was not marked as greater by the < operator";
      testFramework.assert(Compare < GreaterThan, testMesg, __LINE__);
      testMesg = "Greater-than object was marked as lesser by the < operator";
      testFramework.assert(!(GreaterThan < Compare), testMesg, __LINE__);
      testMesg = "Equivalent objects were marked as non-equivalent by the < operator";
      testFramework.assert(!(Compare < Equivalent), testMesg, __LINE__);

      testFramework.changeSourceMethod(">= Operator");
         //---------------------------------------------------------------------------
         //Does the >= operator function correctly?
         //---------------------------------------------------------------------------
      testMesg = "Less-than object was not marked as lesser by the >= operator";		
      testFramework.assert(Compare >= LessThan, testMesg, __LINE__);
      testMesg = "Less-than object was marked as greater by the >= operator";
      testFramework.assert(!(LessThan >= Compare), testMesg, __LINE__);
      testMesg = "Equivalent objects were marked as non-equivalent by the >= operator";
      testFramework.assert(Compare >= Equivalent, testMesg, __LINE__);

      testFramework.changeSourceMethod("<= Operator");
         //---------------------------------------------------------------------------
         //Does the <= operator function correctly?
         //---------------------------------------------------------------------------
      testMesg = "Greater-than object was not marked as greater by the < operator";
      testFramework.assert(Compare <= GreaterThan, testMesg, __LINE__);
      testMesg = "Greater-than object was marked as lesser by the < operator";
      testFramework.assert(!(GreaterThan <= Compare), testMesg, __LINE__);
      testMesg = "Equivalent objects were marked as non-equivalent by the < operator";
      testFramework.assert(Compare <= Equivalent, testMesg, __LINE__);

      testFramework.changeSourceMethod("<< Operator");
         //---------------------------------------------------------------------------
         //Does the << operator function correctly?
         //---------------------------------------------------------------------------
      std::string outputString, compareString;
      std::stringstream outputStream;
      outputStream << Compare;
      outputString = outputStream.str();
      compareString = "GAL";
      testMesg = "The << operator did not function correctly";
      testFramework.assert(compareString == outputString, testMesg, __LINE__);

      return testFramework.countFails();
   }
예제 #20
0
void process_vocab( vector<textwords, allocator>*pvec )
{
	if ( !pvec ) 
	     // issue warning message
		return;

	vector< string, allocator > texts; 

	vector<textwords, allocator>::iterator iter = pvec->begin();
	for ( ; iter != pvec->end(); ++iter )
      		copy( (*iter).begin(), (*iter).end(), back_inserter( texts ));

	// sort the elements of texts
	sort( texts.begin(), texts.end() );
	for_each( texts.begin(), texts.end(), PrintElem() );

	cout << endl << endl;

	// delete all duplicate elements 
	vector<string, allocator>::iterator it;
	it = unique( texts.begin(), texts.end() );
	texts.erase( it, texts.end() );
	for_each( texts.begin(), texts.end(), PrintElem() );

	cout << endl << endl;

	stable_sort( texts.begin(), texts.end(), LessThan() );
	for_each( texts.begin(), texts.end(), PrintElem() );

	cout << endl << endl;

	// count number of strings greater than length 6
	int cnt = 0;

	// obsolete form of count -- standard changes this
	count_if( texts.begin(), texts.end(), GreaterThan(), cnt );

	cout << "Number of words greater than length six are "
     		<< cnt << endl;
	// ...

	static string rw[] = { "and", "if", "or", "but", "the" };
	vector<string,allocator> remove_words( rw, rw+5 );

	vector<string, allocator>::iterator it2 = remove_words.begin();
	for ( ; it2 != remove_words.end(); ++it2 ) {
		int cnt = 0;
		// obsolete form of count -- standard changes this
        	count( texts.begin(), texts.end(), *it2, cnt );
	
		cout << cnt << " instances removed:  " 
	     		<< (*it2) << endl;
	
	    	texts.erase(
	    		remove(texts.begin(),texts.end(),*it2),
	    		texts.end()
	   	);
   	}

	cout << endl << endl;
	for_each( texts.begin(), texts.end(), PrintElem() );
}
예제 #21
0
bool
InliningRecursiveFibonacciMethod::buildIL()
   {
   TR::IlBuilder *baseCase=NULL, *recursiveCase=NULL;
   IfThenElse(&baseCase, &recursiveCase,
      LessThan(
         Load("n"),
         ConstInt32(2)));

   DefineLocal("result", Int32);

   baseCase->Store("result",
   baseCase->   Load("n"));

   TR::IlValue *nMinusOne =
   recursiveCase->         Sub(
   recursiveCase->            Load("n"),
   recursiveCase->            ConstInt32(1));

   TR::IlValue *fib_nMinusOne;
   if (_inlineDepth > 0)
      {
      // memory leak here, but just an example
      InliningRecursiveFibonacciMethod *inlineFib = new InliningRecursiveFibonacciMethod(this);
      fib_nMinusOne = recursiveCase->Call(inlineFib, 1, nMinusOne);
      }
   else
      fib_nMinusOne = recursiveCase->Call("fib", 1, nMinusOne);

   TR::IlValue *nMinusTwo =
   recursiveCase->         Sub(
   recursiveCase->            Load("n"),
   recursiveCase->            ConstInt32(2));
   
   TR::IlValue *fib_nMinusTwo;
   if (_inlineDepth > 0)
      {
      // memory leak here, but just an example
      InliningRecursiveFibonacciMethod *inlineFib = new InliningRecursiveFibonacciMethod(this);
      fib_nMinusTwo = recursiveCase->Call(inlineFib, 1, nMinusTwo);
      }
   else
      fib_nMinusTwo = recursiveCase->Call("fib", 1, nMinusTwo);

   recursiveCase->Store("result",
   recursiveCase->   Add(fib_nMinusOne, fib_nMinusTwo));

#if defined(RFIB_DEBUG_OUTPUT)
   Call("printString", 1,
      ConstInt64((int64_t)prefix));
   Call("printInt32", 1,
      Load("n"));
   Call("printString", 1,
      ConstInt64((int64_t)middle));
   Call("printInt32", 1,
      Load("result"));
   Call("printString", 1,
      ConstInt64((int64_t)suffix));
#endif

   Return(
      Load("result"));

   return true;
   }