예제 #1
0
QQuickStochasticEngine::QQuickStochasticEngine(QList<QQuickStochasticState*> states, QObject *parent) :
    QObject(parent), m_states(states), m_timeOffset(0), m_addAdvance(false)
{
    //Default size 1
    setCount(1);
}
예제 #2
0
DeleteMutation::DeleteMutation(int count)
{
    setCount(count);
}
예제 #3
0
QQuickStochasticEngine::QQuickStochasticEngine(QObject *parent) :
    QObject(parent), m_timeOffset(0), m_addAdvance(false)
{
    //Default size 1
    setCount(1);
}
예제 #4
0
int QDeclarativeParticles::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDeclarativeItem::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 17)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 17;
    }
#ifndef QT_NO_PROPERTIES
    else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0:
            *reinterpret_cast< QUrl*>(_v) = source();
            break;
        case 1:
            *reinterpret_cast< int*>(_v) = count();
            break;
        case 2:
            *reinterpret_cast< int*>(_v) = emissionRate();
            break;
        case 3:
            *reinterpret_cast< qreal*>(_v) = emissionVariance();
            break;
        case 4:
            *reinterpret_cast< int*>(_v) = lifeSpan();
            break;
        case 5:
            *reinterpret_cast< int*>(_v) = lifeSpanDeviation();
            break;
        case 6:
            *reinterpret_cast< int*>(_v) = fadeInDuration();
            break;
        case 7:
            *reinterpret_cast< int*>(_v) = fadeOutDuration();
            break;
        case 8:
            *reinterpret_cast< qreal*>(_v) = angle();
            break;
        case 9:
            *reinterpret_cast< qreal*>(_v) = angleDeviation();
            break;
        case 10:
            *reinterpret_cast< qreal*>(_v) = velocity();
            break;
        case 11:
            *reinterpret_cast< qreal*>(_v) = velocityDeviation();
            break;
        case 12:
            *reinterpret_cast< QDeclarativeParticleMotion**>(_v) = motion();
            break;
        }
        _id -= 13;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0:
            setSource(*reinterpret_cast< QUrl*>(_v));
            break;
        case 1:
            setCount(*reinterpret_cast< int*>(_v));
            break;
        case 2:
            setEmissionRate(*reinterpret_cast< int*>(_v));
            break;
        case 3:
            setEmissionVariance(*reinterpret_cast< qreal*>(_v));
            break;
        case 4:
            setLifeSpan(*reinterpret_cast< int*>(_v));
            break;
        case 5:
            setLifeSpanDeviation(*reinterpret_cast< int*>(_v));
            break;
        case 6:
            setFadeInDuration(*reinterpret_cast< int*>(_v));
            break;
        case 7:
            setFadeOutDuration(*reinterpret_cast< int*>(_v));
            break;
        case 8:
            setAngle(*reinterpret_cast< qreal*>(_v));
            break;
        case 9:
            setAngleDeviation(*reinterpret_cast< qreal*>(_v));
            break;
        case 10:
            setVelocity(*reinterpret_cast< qreal*>(_v));
            break;
        case 11:
            setVelocityDeviation(*reinterpret_cast< qreal*>(_v));
            break;
        case 12:
            setMotion(*reinterpret_cast< QDeclarativeParticleMotion**>(_v));
            break;
        }
        _id -= 13;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 13;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 13;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 13;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 13;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 13;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 13;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
예제 #5
0
파일: item.cpp 프로젝트: jhorda/otclient
void Item::unserializeItem(const BinaryTreePtr &in)
{
    try {
        while(in->canRead()) {
            int attrib = in->getU8();
            if(attrib == 0)
                break;

            switch(attrib) {
            case ATTR_COUNT:
            case ATTR_RUNE_CHARGES:
                setCount(in->getU8());
                break;
            case ATTR_CHARGES:
                setCount(in->getU16());
                break;
            case ATTR_HOUSEDOORID:
            case ATTR_SCRIPTPROTECTED:
            case ATTR_DUALWIELD:
            case ATTR_DECAYING_STATE:
                m_attribs.set(attrib, in->getU8());
                break;
            case ATTR_ACTION_ID:
            case ATTR_UNIQUE_ID:
            case ATTR_DEPOT_ID:
                m_attribs.set(attrib, in->getU16());
                break;
            case ATTR_CONTAINER_ITEMS:
            case ATTR_ATTACK:
            case ATTR_EXTRAATTACK:
            case ATTR_DEFENSE:
            case ATTR_EXTRADEFENSE:
            case ATTR_ARMOR:
            case ATTR_ATTACKSPEED:
            case ATTR_HITCHANCE:
            case ATTR_DURATION:
            case ATTR_WRITTENDATE:
            case ATTR_SLEEPERGUID:
            case ATTR_SLEEPSTART:
            case ATTR_ATTRIBUTE_MAP:
                m_attribs.set(attrib, in->getU32());
                break;
            case ATTR_TELE_DEST: {
                Position pos;
                pos.x = in->getU16();
                pos.y = in->getU16();
                pos.z = in->getU8();
                m_attribs.set(attrib, pos);
                break;
            }
            case ATTR_NAME:
            case ATTR_TEXT:
            case ATTR_DESC:
            case ATTR_ARTICLE:
            case ATTR_WRITTENBY:
                m_attribs.set(attrib, in->getString());
                break;
            default:
                stdext::throw_exception(stdext::format("invalid item attribute %d", attrib));
            }
        }
    } catch(stdext::exception& e) {
        g_logger.error(stdext::format("Failed to unserialize OTBM item: %s", e.what()));
    }
}
예제 #6
0
파일: screens_drm.cpp 프로젝트: 8l/kwin
void DrmScreens::updateCount()
{
    setCount(m_backend->outputs().size());
}
예제 #7
0
파일: screens_fb.cpp 프로젝트: 8l/kwin
void FramebufferScreens::updateCount()
{
    setCount(1);
}
예제 #8
0
void WifiNetworkProperties::increaseCount()
{
    setCount(count() + 1);
}
예제 #9
0
/**
 * Count the number of occurrences of each subtree of root
 */
Occurrences::Occurrences(Tree root)
{
    fKey = specificKey(root);
    countOccurrences(root);
    setCount(root,0); 	// root as no occurences in itself
}
예제 #10
0
SkipMutation::SkipMutation(int skip)
{
    setCount(skip);
}
예제 #11
0
    void compute(RideItem *item, Specification spec, const QHash<QString,RideMetric*> &) {

        // no ride or no samples
        if (spec.isEmpty(item->ride()) ||
            !item->isRun || item->ride()->recIntSecs() == 0) {
            setValue(RideFile::NIL);
            setCount(0);
            return;
        }

        double weight = item->ride()->getWeight();
        double height = item->ride()->getHeight();

        int rollingwindowsize120 = 120 / item->ride()->recIntSecs();
        int rollingwindowsize30 = 30 / item->ride()->recIntSecs();

        double total = 0.0;
        int count = 0;

        // no point doing a rolling average if the
        // sample rate is greater than the rolling average
        // window!!
        if (rollingwindowsize30 > 1) {

            QVector<double> rollingSpeed(rollingwindowsize120);
            QVector<double> rollingSlope(rollingwindowsize120);
            QVector<double> rollingPower(rollingwindowsize30);
            int index120 = 0;
            int index30 = 0;
            double sumSpeed = 0.0;
            double sumSlope = 0.0;
            double sumPower = 0.0;
            double initial_speed = 0.0;

            // loop over the data and convert to a rolling
            // average for the given windowsize
            RideFileIterator it(item->ride(), spec);
            while (it.hasNext()) {
                struct RideFilePoint *point = it.next();

                double speed = point->kph/3.6;
                sumSpeed += speed;
                sumSpeed -= rollingSpeed[index120];
                rollingSpeed[index120] = speed;
                double speed120 = sumSpeed/std::min(count+1, rollingwindowsize120); // speed rolling average

                double slope = point->slope/100.0;
                sumSlope += slope;
                sumSlope -= rollingSlope[index120];
                rollingSlope[index120] = slope;
                double slope120 = sumSlope/std::min(count+1, rollingwindowsize120); // slope rolling average

                // running power based on 120sec averages
                double watts = running_power(weight, height, speed120, slope120, speed120*item->ride()->recIntSecs(), initial_speed);
                initial_speed = speed120;

                sumPower += watts;
                sumPower -= rollingPower[index30];
                rollingPower[index30] = watts;

                total += pow(sumPower/std::min(count+1, rollingwindowsize30), 4); // raise rolling average to 4th power
                count ++;

                // move index on/round
                index120 = (index120 >= rollingwindowsize120-1) ? 0 : index120+1;
                index30 = (index30 >= rollingwindowsize30-1) ? 0 : index30+1;
            }
        }
        if (count) {
            lnp = pow(total/count, 0.25);
            secs = count * item->ride()->recIntSecs();
        } else {
            lnp = secs = 0;
        }

        setValue(lnp);
        setCount(secs);
    }
예제 #12
0
/** @ingroup SystemInfo
 * @brief Allows the caller to determine the value of various NSP2000 and API
 * system and configuration values.
 *
 * The configuration parameter desired is determined by the value specified in
 * Parameter. Note that the hash units are currently being treated the same
 * as the EA units since the NSP2000 does not have a separate hash core.
 *
 *  @param parameter   RO:  A constant naming the configuration value to 
 *                          return.
 *  @param value_p     WO:  A pointer to where to return the value(s) of the
 *                          requested system parameter. The format (type) of
 *                          what is returned depends on the value of
 *                          Parameter.
 *
 * @return
 *    returnResult - returns N8_STATUS_OK if successful or Error value.
 * @par Errors
 *      N8_INVALID_ENUM -     The value of Parameter is not one of the 
 *                            defined valid configuration enumerations. 
 *      N8_INVALID_OBJECT     The output parameter is NULL.
 * @par Assumptions
 *    None<br>
 *****************************************************************************/
N8_Status_t N8_GetSystemParameter(N8_Parameter_t parameter, void *value_p)
{
   N8_Status_t ret = N8_STATUS_OK;

   DBG(("N8_GetSystemParameter\n"));
   do
   {
       ret = N8_preamble();
       CHECK_RETURN(ret);

       /* verify value object */
       CHECK_OBJECT(value_p, ret);

       switch (parameter)
       {
           case N8_EACOUNT:
              ret = setCount(value_p, N8_EA);
              break;
           case N8_EATYPE:
              ret = setType(value_p, N8_EA);
              break;
           case N8_PKCOUNT:
              ret = setCount(value_p, N8_PKP);
              break;
           case N8_PKTYPE:
              ret = setType(value_p, N8_PKP);
              break;
           case N8_HPCOUNT:
              ret = setCount(value_p, N8_EA);
              break;
           case N8_HPTYPE:
              ret = setType(value_p, N8_EA);
              break;
           case N8_HARDWAREVERSION:
              ret = setHWversion(value_p);
              break;
           case N8_HARDWAREREVISION:
              ret = setHWrevision(value_p);
              break;
           case N8_SOFTWAREVERSION:
              ret = setSWversion(value_p);
              break;
           case N8_CONTEXTMEMSIZE:
              ret = setContextSize(value_p);
              break;
           case N8_SKSMEMSIZE:
              ret = setSKSsize(value_p);
              break;
           case N8_NUMBEROFCHIPS:
              ret = setNumberOfChips(value_p);
              break;
           case N8_SWVERSIONTEXT:
              ret = setSWversionText(value_p);
              break;
           case N8_INITIALIZE_INFO:
              ret = setInitInfo(value_p);
              break;
           case N8_FILEDESCRIPTOR:
              ret = setFD(value_p);
              break;
           default:
              /* invalid parameter */
              DBG(("Invalid parameter\n"));
              DBG(("N8_GetSystemParameter - return Error\n"));
              ret = N8_INVALID_ENUM;
              break;
       } /* switch */
   }while (FALSE);
   DBG(("N8_GetSystemParameter - OK\n"));
   return ret;
} /* N8_GetSystemParameter */
예제 #13
0
파일: PreLL1.c 프로젝트: HsuJv/Note
void PreLL1() {
	digType cflag = 0;

	// Detect and eliminate left recursion
	DLR();

#ifdef _DEBUG
	printf("After deleting the left recursion: \n");

	for (pRule p = gRules; p; p = p->next) {
		for (pRuleNode pr = p->addr; pr; pr = pr->next) {
			printf("%s ", pr->symbol);
		}
		printf("\n");
	}
	printf("\n\n\n");
#endif // _DEBUG

	// Terminals First set
	for (pSymbolNode p = ll[1]; p; p = p->next) {
		getSymbolFirst(p);
	}

	// Nonterminals First set
	while (1)
	{
		for (pSymbolNode p = ll[0]; p; p = p->next) {
			getSymbolFirst(p);
		}

		if (cflag == setCount(getSymbolFirst)) break;
		else cflag = setCount(getSymbolFirst);
	}

#ifdef _DEBUG
	printf("The First sets: \n");

	for (pSymbolNode p = ll[0]; p; p = p->next) {
		printf("%s: ", p->symbol);
		if (p->first)
			for (unsigned int i = 1; i <= *(p->first); i++) {
				char *s = findSerial(*(p->first + i));
				printf("%s ", s);
				free(s);
			}
		printf("\n");
	}
	printf("\n\n\n");
#endif // _DEBUG

	cflag = 0;

	//  Follow set
	while (1)
	{
		for (pSymbolNode p = ll[0]; p; p = p->next) {
			getFollow(p);
		}

		if (cflag == setCount(getFollow)) break;
		else cflag = setCount(getFollow);
	}
#ifdef _DEBUG
	printf("The Follow sets: \n");

	for (pSymbolNode p = ll[0]; p; p = p->next) {
		printf("%s: ", p->symbol);
		if (p->follow)
			for (unsigned int i = 1; i <= *(p->follow); i++) {
				char *s = findSerial(*(p->follow + i));
				printf("%s ", s);
				printf("(%d) ", *(p->follow + i));
				free(s);
			}
		printf("\n");
	}
	printf("\n\n\n");
#endif // _DEBUG

	// Construct LL(1) analysis table
	CLAT();

#ifdef _DEBUG
	printf("The Analysis table: \n\t");

	for (digType i = 0; i < gTerSerial / 2; i++) {
		if (!i)
			printf("# ");
		else {
			char* s = findSerial(i * 2);
			printf("%s ", s);
			free(s);
		}
	}
	printf("\n");

	for (digType row = 0; row < gNonTerSerial / 2; row++) {
		char* s = findSerial(row * 2 + 1);
		printf("%s\t", s);
		free(s);
		for (digType col = 0; col < gTerSerial / 2; col++) {
			if (!AT[row][col]) {
				printf(". ");
				continue;
			}

			s = findSerial(AT[row][col]->serial);
			if (s)
				printf("%s ", s);
			else
				printf("0 ");
			free(s);
		}
		printf("\n");
	}
	printf("\n\n\n");
#endif // _DEBUG
}
예제 #14
0
int countChars(unsigned short *s,int len,int maximumOrder)
{
  int j;

  struct countnode **n=&nodeTree;
  
  if (!*n) *n=calloc(sizeof(struct countnode),1);

  /*
    Originally, we inserted strings in a forward direction, e.g., inserting
    "lease" would have nodes root->l->e->a->s->e.  
    But we also had to insert the partial strings root->e->a->s->e, root->a->s->e,
    root->s->e and root->e.
    This is necessary because there may not be enough occurrences of "lease" to 
    have the full depth stored in the compressed file.  Also, when querying on,
    e.g., "amylase" or even just a misspelling of lease, a full depth entry may
    not exist.  Also, at the beginning of a message there are not enough characters
    to provide a full-depth context. 

    So for all these reasons, we not only had to store all the partial strings, but
    also query the partial strings if a full depth match does not exist when using
    the compressed statistics file.  This contributed to very slow compression and
    decompression performance.

    If we instead insert the strings backwards, it seems that things should be
    substantially better. Now, we would insert "lease" as root->e->s->a->e->l.
    Querying any length string with any length of match will return the deepest
    statistics possible in just one query.  We also don't need to store the partial
    strings, which should reduce the size of the compressed file somewhat.

    Storing strings backwards also introduces a separation between the tree structure
    and the counts.
  */
  int order=0;
  int symbol=charIdx(tolower(s[len-1]));
  if (symbol<0) return 0;
  for(j=len-2;j>=0;j--) {
    int c=charIdx(s[j]);
    if (0) fprintf(stderr,"  %d (%c)\n",c,s[j]);
    if (c<0) break;
    if (!(*n)) {
      *n=calloc(sizeof(struct countnode),1);
      if (0) fprintf(stderr,"    -- create node %p\n",*n);
      nodeCount++;
      if (!(nodeCount&0x3fff)) 
	fprintf(stderr,"[%lld,%lld,%lld]",
		nodeCount,nodeBigCountsCount,nodeBigChildrenCount);
    }
    (*n)->count++;
    setCount((*n),symbol,getCount((*n),symbol)+1);
    if (0) 
      fprintf(stderr,"   incrementing count of %d (0x%02x = '%c') @ offset=%d *n=%p (now %d)\n",
	      symbol,s[len-1],s[len-1],j,*n,getCount((*n),symbol));
    n=getChild(*n,c,1 /* create pointer if not already existing */); 
    if (order>=maximumOrder) 
      {
	break;
      }
    order++;
  }

  if (!(*n)) {
    *n=calloc(sizeof(struct countnode),1);
    if (0) fprintf(stderr,"    -- create terminal node %p\n",*n);
    nodeCount++;
  }
  (*n)->count++;
  setCount(*n,symbol,getCount(*n,symbol)+1);

  return 0;
}