示例#1
0
size_t StackIterator::numberOfFrames()
{
    int savedFrameIndex = m_frame.index();
    resetIterator();
    while (m_frame.callFrame())
        gotoNextFrameWithFilter();
    size_t numberOfFrames = m_frame.index();

    resetIterator();
    gotoFrameAtIndex(savedFrameIndex);

    return numberOfFrames;
}
	//-----------------------------------------------------------------------
	Particle* ParticlePool::getFirst(void)
	{
		resetIterator();
		mLatestParticle = mVisualParticlesPool.getFirst();
		if (!mLatestParticle)
		{
			mLatestParticle = mParticleEmitterPool.getFirst();
			if (!mLatestParticle)
			{
				mLatestParticle = mParticleTechniquePool.getFirst();
				if (!mLatestParticle)
				{
					mLatestParticle = mParticleAffectorPool.getFirst();
					if (!mLatestParticle)
					{
						mLatestParticle = mParticleSystemPool.getFirst();
						if (!mLatestParticle)
						{
							// Todo: Add other particle types
						}
					}
				}
			}
		}

		return mLatestParticle;
	}
	//-----------------------------------------------------------------------
	Particle* ParticlePool::getFirst(const Particle::ParticleType particleType)
	{
		resetIterator();
		switch (particleType)
		{
			case Particle::PT_VISUAL:
				mLatestParticle = mVisualParticlesPool.getFirst();
				break;

			case Particle::PT_EMITTER:
				mLatestParticle = mParticleEmitterPool.getFirst();
				break;

			case Particle::PT_TECHNIQUE:
				mLatestParticle = mParticleTechniquePool.getFirst();
				break;

			case Particle::PT_AFFECTOR:
				mLatestParticle = mParticleAffectorPool.getFirst();
				break;

			case Particle::PT_SYSTEM:
				mLatestParticle = mParticleSystemPool.getFirst();
				break;
		}

		return mLatestParticle;
	}
bool
NodeMobilityMgr::updateLocations(double currentTime)
{
    m_nextUpdateTime = PACKET_TIME_MAX;
    //qDebug(QString("Mobility Mgr updating node locations"));
    if (m_tsAnimNodes.empty())
    {
        //qDebug(QString("m_tsAnimNodes empty"));
        return false;
    }

    if(m_lastTime > currentTime)
    {
        resetIterator();
    }
    for(NodeIdTimeLocationMap_t::const_iterator i = m_tsAnimNodes.begin();
        i != m_tsAnimNodes.end();
        ++i)
    {
        updateNodeLocationsPerNode(currentTime, i->first, &i->second);

    }
    m_lastTime = currentTime;
    return true;
}
示例#5
0
void ByteSection::outTab(ofstream *output)
{
	ofstream &out = *output;

	// dopunjavanje do 4 bajta
	/*for (int i = cnt; i < 4; i++)
	{
		dw[i] = 0;
	}
	endInsert(dw);
	cnt = 0;*/

	out << "#" << this->getName() << endl;

	dword *tek;
	int i=0;
	for (resetIterator(); getBoolIt(); iteratorNext())
	{
		tek = getItEntPointer();

		tek->outDword(output);
		out << "  ";
		if ((i % 4) == 3) out << endl;
		i++;
	}
	if(i == 0) out << "(empty)";
	out << endl;
}
示例#6
0
void ParticleContainerLC::add(Particle& p) {
	particles.push_back(p);
	resetIterator();

	// define index of cell for particle
#if 1==DIM
	int particleIndex[]= {p.getX()[0]/radius, p.getX()[1]/radius, p.getX()[2] / radius};
#elif 2==DIM
	int particleIndex[]= {p.getX()[0]/radius, p.getX()[1]/radius, p.getX()[2] / radius};
#elif 3==DIM
	int particleIndex[] = { p.getX()[0] / cellsSize[0], p.getX()[1] / cellsSize[1],
			p.getX()[2] / cellsSize[2] };
#endif

	// skip particles that don't suite into the domain
	bool outofbound = false;
	for (int d = 0; d < 3; d++) {
		if (particleIndex[d] >= cellNums[d] || particleIndex[d] < 0
				|| p.getX()[d] < 0.0 || p.getX()[d] > domainSize[d])
			outofbound = true;
	}
	if (outofbound)
		return;

	ParticleList* pl = new ParticleList;;
	pl->p = &p;
	pl->next = NULL;
	insertList((ParticleList**)&(cells[calcIndex(particleIndex, cellNums)].root), pl);
}
	//-----------------------------------------------------------------------
	void ParticlePool::increasePool (const Particle::ParticleType particleType, 
		size_t size, 
		Particle::ParticleBehaviourList& behaviours,
		ParticleTechnique* technique)
	{
		switch(particleType)
		{
			case Particle::PT_VISUAL:
				_increaseVisualParticlePool(size, behaviours);
				break;

			case Particle::PT_EMITTER:
				_increaseParticleEmitterPool(size, behaviours, technique);
				break;

			case Particle::PT_TECHNIQUE:
				_increaseParticleTechniquePool(size, behaviours, technique->getParentSystem());
				break;

			case Particle::PT_AFFECTOR:
				_increaseParticleAffectorPool(size, behaviours, technique);
				break;

			case Particle::PT_SYSTEM:
				_increaseParticleSystemPool(size, behaviours, technique);
				break;
		}
		resetIterator();
	}
	//-----------------------------------------------------------------------
	void ParticlePool::lockAllParticles (void)
	{
		mVisualParticlesPool.lockAllElements();
		mParticleEmitterPool.lockAllElements();
		mParticleTechniquePool.lockAllElements();
		mParticleAffectorPool.lockAllElements();
		mParticleSystemPool.lockAllElements();
		resetIterator();
	}
示例#9
0
LOCA::Abstract::Iterator::Iterator(Teuchos::ParameterList& p) :
  stepNumber(0),
  numFailedSteps(0),
  numTotalSteps(0),
  maxSteps(100),
  iteratorStatus(LOCA::Abstract::Iterator::NotFinished)
{
  resetIterator(p);
}
示例#10
0
void MWWorld::ContainerStoreIterator::nextType()
{
    while (mType!=-1)
    {
        incType();

        if ((mType & mMask) && mType>0)
            if (resetIterator())
                break;
    }
}
示例#11
0
void ByteSection::replace(dword dw, int offset)
{
	dword *tek;

	resetIterator();
	for (int i = 0; i < offset / INS_SIZE; i++)
		iteratorNext();

	tek = getItEntPointer();

	tek->sumOr(dw);
}
示例#12
0
int DiffModification::restore(){
	LogIterator iter;
	resetIterator(&iter);
	//A_diff_t* diff = getNext(&logIterator);
	//printf("HBRuntime: merge log(%x)\n", flog);
	int count = 0;
	while(iter.pageIterator != NULL){

		iter.iterator = (A_diff_t*)iter.pageIterator->dataStart();
		iter.iteratorLimit = (A_diff_t*)(iter.pageIterator->dataLimit());
		while(iter.iterator < iter.iteratorLimit){
			count ++;
			A_diff_t* diff = iter.iterator;
			#if (DIFF_GRANULARITY_CONFIG == _GRANULARITY_BYTE_SIZE)
			//#if defined ( BYTE_SIZE_DIFF )
			//if(configs::DIFF_GRANULARITY == configs::BYTE_SIZE_DIFF){
			char* addr = (char*)diff->addr;
			char value = diff->value;
			//signal_up ++;
			*addr = value;
			//signal_up --;
			//#elif defined (INT_SIZE_DIFF)
			//}
			//else if(configs::DIFF_GRANULARITY == configs::BYTE_SIZE_DIFF){
			#elif (DIFF_GRANULARITY_CONFIG == _GRANULARITY_INT_SIZE)
			//#ifdef INT_SIZE_DIFF
			int* addr = (int*)diff->addr;
			int value = diff->value;
			*addr = value;
			//int tmp = is_in_data(addr);
			//if(tmp != -1){
				//fprintf(stderr, "Thread %d merge data item %d (%x) to %x\n", me->tid, tmp/4, addr, value);
			//}
			//#endif
			//}
			#endif
			iter.iterator += 1;
		}

		iter.pageIterator = iter.pageIterator->next;
		//printf("HBRuntime: in iterations(%d)\n", i);

		//ASSERT(true, "Error: addr = NULL\n")
		//diff = getNext(&logIterator);
	}

	return count;
}
示例#13
0
void RelTab::outTab(ofstream *output)
{
	ofstream &out = *output;

	string name = bTab->getName();
	name = name.substr(0, 4);
	if (name.compare(".bss") == 0) return;

	out << "#.rel" << bTab->getName() << endl;
	out << "offset\t\tType\t\t\Val[" << bTab->getName() << "]:" << endl;

	Elf_Rel *tek;
	for (resetIterator(); getBoolIt(); iteratorNext())
	{
		tek = getItEntPointer();

		tek->outRel(output);
	}
}
示例#14
0
 /* 0-credit */
Fraction ContinuedFraction::getApproximation(unsigned int k) const {
	Fraction fract;//fraction to return
	stack<cf_int> stck;
	resetIterator(); 

	for (int i = k; i >=1; i--){
		stck.push(next()); // push all values onto stack
		if (hasNoMore()) break;}
	
	fract = {0,1};//initialize fraction
	
	while(!stck.empty()){
		fract.numerator = fract.denominator*stck.top() + fract.numerator;
		stck.pop();
		if(!stck.empty()){//modifying the fraction
			cf_int temp = fract.numerator;
			fract.numerator = fract.denominator;
			fract.denominator = temp;} }

	return fract;	}
示例#15
0
void HuffmanDecoder::push(istream &f) {
    
    char *line = new char[1024];
    f.getline(line, 1024);

    const string* word;

    for(int i = 0; i < strlen(line); i++) {
        
        // check if the input is valid
        if(line[i] != '0' && line[i] != '1') {
            throw 0;
        }

        try {
            word = getWordFromIter();
            savedWords.push(word);
            resetIterator();
            i--;
        } catch(const double e) {

            // go down to the apropriate children
            if(line[i] == '0'){
                moveDownOnZero();
            }
            else if(line[i] == '1'){
                moveDownOnOne();
            }
        }
    }

    try {
        word = getWordFromIter();
        savedWords.push(word);
    } catch(const double e) {
       throw 1;
   }

}
示例#16
0
MagicBoxCF::MagicBoxCF(ContinuedFraction const *f, unsigned long aParam, unsigned long bParam): a(aParam), b(bParam){
	mbnums = new cf_int[4];
	mbnums[0] = a; mbnums[1] = b;
	mbnums[2] = 1; mbnums[3] = 0;
	boxedFraction = f;
	resetIterator(); }
示例#17
0
PosBlockArray::PosBlockArrayIter::PosBlockArrayIter(const PosBlockArray* pba_, bool startEndPosValid_, unsigned int startPos_, unsigned int endPos_) 
				: pba((PosBlockArray*)pba_), curBlockIter(NULL), currindex(0), startPos(startPos_), endPos(endPos_) , startEndPosValid(startEndPosValid_)
{
	resetIterator();
}
示例#18
0
StackIterator::StackIterator(CallFrame* startFrame, StackIterator::FrameFilter filter)
    : m_startFrame(startFrame)
    , m_filter(filter)
{
    resetIterator();
}
示例#19
0
HuffmanTree::HuffmanTree(const HuffmanCode &hc) {
    
    // get all the code
    string allCode[hc.size()];
    string allWord[hc.size()];
    int k = 0;
    for (map<string, string>::const_iterator it = hc.begin(); it != hc.end(); it++){

        // check if the code is made of 0 and 1
        if(!isZeroOne(it->second)){
            throw 2;
        } else {
            allCode[k] = it->second;
            allWord[k] = it->first;
            k++;
        }
    }

    // check if any of the code is the prefix of another
    for(int i = 0; i < sizeof(allCode) / sizeof(string); i++){
        if(isPrefixOfAnother(allCode[i], allCode)){
            throw 1;
        }
    }

    // create root
    root = new TreeNode();
    iter = root;


    for (int j = 0; j < sizeof(allCode) / sizeof(string); j++) {
        // create path to the leaf
        int i;
        for(i = 0; i < allCode[j].length() - 1; i++){
            if(allCode[j].at(i) == '0'){
                if(iter->children[0] == nullptr){
                    iter->children[0] = new TreeNode();
                    iter = iter->children[0];
                } else {
                    iter = iter->children[0];
                }

            } else {
                 if(iter->children[1] == nullptr){
                    iter->children[1] = new TreeNode();
                    iter = iter->children[1];
                } else {
                    iter = iter->children[1];
                }
            }
        }

        if(allCode[j].at(i) == '0'){
            if(iter->children[0] == nullptr){
                iter->children[0] = new TreeNode(allWord[j]);
                iter = iter->children[0];
            } else {
                iter = iter->children[0];
            }

        } else {
             if(iter->children[1] == nullptr){
                iter->children[1] = new TreeNode(allWord[j]);
                iter = iter->children[1];
            } else {
                iter = iter->children[1];
            }
        }

        resetIterator();
    }
}
void VoronoiDiagramGenerator::CloseEdges()
{
	RhinoApp().Print(L"\n close edges\n");
	float x1,y1,x2,y2;
	//Site *s1;
	//Site *s2;
	int arraysize = ((int)sqrt((double)numedges)+1);
	/*Point* bpln = (Point*)malloc(arraysize * sizeof(Point));
	Point* bpls = (Point*)malloc(arraysize * sizeof(Point));
	Point* bple = (Point*)malloc(arraysize * sizeof(Point));
	Point* bplw = (Point*)malloc(arraysize * sizeof(Point));*/

	
	//Point* pe, pr;
	int north=0;
	int south=0;
	int east=0;
	int west=0;
	int total = 0;
	int z,q; 
	//int elements;
	resetIterator();
	while(getNext(x1,y1,x2,y2))
	{
		if(sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))) < minDistanceBetweenSites)
		{
			//ignore it
		}
		else
		{
			if(x1 == borderMinX){west++;}
			if(x2 == borderMinX){west++;}
			if(x1 == borderMaxX){east++;}
			if(x2 == borderMaxX){east++;}
			if(y1 == borderMinY){south++;}
			if(y2 == borderMinY){south++;}
			if(y1 == borderMaxY){north++;}
			if(y2 == borderMaxY){north++;}
		}
	}

	Point* bpln = (Point*)malloc(north * sizeof(Point));
	Point* bpls = (Point*)malloc(south * sizeof(Point));
	Point* bple = (Point*)malloc(east * sizeof(Point));
	Point* bplw = (Point*)malloc(west * sizeof(Point));

	north=0;
	south=0;
	east=0;
	west=0;

	resetIterator();
	while(getNext(x1,y1,x2,y2))
	{
		if(sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))) < minDistanceBetweenSites)
		{
			//ignore it
		}
		else
		{
			if(x1 == borderMinX){bplw[west].x = x1; bplw[west].y = y1; west++;}
			if(x2 == borderMinX){bplw[west].x = x2; bplw[west].y = y2; west++;}
			if(x1 == borderMaxX){bple[east].x = x1; bple[east].y = y1; east++;}
			if(x2 == borderMaxX){bple[east].x = x2; bple[east].y = y2; east++;}
			if(y1 == borderMinY){bpls[south].x = x1; bpls[south].y = y1; south++;}
			if(y2 == borderMinY){bpls[south].x = x2; bpls[south].y = y2; south++;}
			if(y1 == borderMaxY){bpln[north].x = x1; bpln[north].y = y1; north++;}
			if(y2 == borderMaxY){bpln[north].x = x2; bpln[north].y = y2; north++;}
		}
	}
	total = (north+south+east+west+4);

	Point northwest, northeast, southeast, southwest;
	southwest.x = borderMinX; southwest.y = borderMinY;
	southeast.x = borderMaxX; southeast.y = borderMinY;
	northwest.x = borderMinX; northwest.y = borderMaxY;
	northeast.x = borderMaxX; northeast.y = borderMaxY;
	Point* bplt = (Point*)malloc(total * sizeof(Point));
	//RhinoApp().Print(L"\n filling pblt\n");
	RhinoApp().Print(L"numedges: %d, total: %d, north: %d, south: %d, east: %d, west: %d\n",numedges, total, north, south, east, west);
	q=0;

	bplt[q] = southwest; q++;

	qsort(bpls,south,sizeof(Point),EdgeCompare);
	for(z=0; z<south; z++){bplt[q] = bpls[z]; q++;}	
	//free(bpls);

	bplt[q] = southeast; q++;
	qsort(bple,east,sizeof(Point),EdgeCompare);
	for(z=0; z<east; z++) {bplt[q] = bple[z]; q++;}
	//free(bple);

	bplt[q] = northeast; q++;
	qsort(bpln,north,sizeof(Point),EdgeCompare);
	for(z=0; z<north; z++){bplt[q] = bpln[z]; q++;}
	//free(bpln);

	bplt[q] = northwest; q++;
	qsort(bplw,west,sizeof(Point),EdgeCompare);
	for(z=0; z<west; z++) {bplt[q] = bplw[z]; q++;}			
	//free(bplw);

	bplt[q] = southwest;
	RhinoApp().Print(L"q: %d\n",q);
	int e;
	for( e=1; e<=total; e++)
	{
			//bplt[e-1];
			//bplt[e];
			RhinoApp().Print(L"pushing edge: e = %d : %f,%f -> %f,%f \n",e,bplt[e-1].x,bplt[e-1].y,bplt[e].x, bplt[e].y);
			pushGraphEdge(bplt[e-1].x, bplt[e-1].y, bplt[e].x,bplt[e].y,NULL,NULL);
	}
	RhinoApp().Print(L"e: %d\n",e);
	//free(bplt);
}