Example #1
0
template < class KEY, class CONTENT > void AVLTree < KEY, CONTENT >::insert (const KEY & key, const CONTENT & c) {
  if (root == 0) {
      root->set_rthread (1);
      root->set_lthread (1);
    }
else { _target_key = &key; _add (root); }
}
Example #2
0
static
Value *
eval(const Ast *expr) {
	switch(expr->class) {
	case N_CALL:
		return call(expr);
	case N_ASSIGNMENT:
		return assignment(expr);
	case N_IDENTIFIER:
		return identifier(expr);
	case N_NEG:
		return _neg(expr);
	case N_NOT:
		return _not(expr);
	case N_EQ:
		return _eq(expr);
	case N_NEQ:
		return _neq(expr);
	case N_AND:
		return _and(expr);
	case N_IOR:
		return _ior(expr);
	case N_XOR:
		return _neq(expr); // alias
	case N_LT:
		return _lt(expr);
	case N_LE:
		return _le(expr);
	case N_GE:
		return _ge(expr);
	case N_GT:
		return _gt(expr);
	case N_ADD:
		return _add(expr);
	case N_SUB:
		return _sub(expr);
	case N_MUL:
		return _mul(expr);
	case N_DIV:
		return _div(expr);
	case N_POW:
		return _pow(expr);
	case N_MOD:
		return _mod(expr);
	case N_BOOLEAN:
		return _bool(expr);
	case N_INTEGER:
		return _int(expr);
	case N_FLOAT:
		return _float(expr);
	case N_STRING:
		return _string(expr);
	case N_SET:
		return _set(expr);
	case N_R:
		return _relation(expr);
	}
printf("EVALFAIL %d ", expr->class); pn(expr);
	assert(false && "should not be reached");
}
Example #3
0
/*
 * POSIX and the C Standard are unclear or inconsistent about
 * what %C and %y do if the year is negative or exceeds 9999.
 * Use the convention that %C concatenated with %y yields the
 * same output as %Y, and that %Y contains at least 4 bytes,
 * with more only if necessary.
 */
static char *
_yconv(const int a, const int b, const int convert_top,
	   const int convert_yy, char *pt, const char *const ptlim)
{
	int			lead;
	int			trail;

#define DIVISOR		  100
	trail = a % DIVISOR + b % DIVISOR;
	lead = a / DIVISOR + b / DIVISOR + trail / DIVISOR;
	trail %= DIVISOR;
	if (trail < 0 && lead > 0)
	{
		trail += DIVISOR;
		--lead;
	}
	else if (lead < 0 && trail > 0)
	{
		trail -= DIVISOR;
		++lead;
	}
	if (convert_top)
	{
		if (lead == 0 && trail < 0)
			pt = _add("-0", pt, ptlim);
		else
			pt = _conv(lead, "%02d", pt, ptlim);
	}
	if (convert_yy)
		pt = _conv(((trail < 0) ? -trail : trail), "%02d", pt, ptlim);
	return pt;
}
Example #4
0
void DirEntryList::add(const string &name, const Key &blobKey, fspp::Dir::EntryType entryType, mode_t mode,
                            uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
    if (_hasChild(name)) {
        throw fspp::fuse::FuseErrnoException(EEXIST);
    }
    _add(name, blobKey, entryType, mode, uid, gid, lastAccessTime, lastModificationTime);
}
Example #5
0
void ScreenLock::requestStreamAcceptance(const QString uri)
{
    if (_locked)
        _add(uri);
    else
        emit streamAccepted(uri);
}
Example #6
0
	/**
	 * Delete and add a resource ("dadd").
	 * @param index Resource index.
	 * @param obj Pointer to object data.
	 * @param type Resource type.
	 */
	int ResourceArray::_dadd(unsigned index, void* obj, byte type) {
		if(index&DYNAMIC_PLACEHOLDER_BIT) {
			unsigned pIndex = index&(~DYNAMIC_PLACEHOLDER_BIT);
			TESTINDEX(pIndex, mDynResSize);
			if(mDynRes[pIndex] != NULL) {
				_destroy(index);
			}
			return _add(index, obj, type);
		} else {
			TESTINDEX(index, mResSize);
			if(mRes[index] != NULL) {
				_destroy(index);
			}
			return _add(index, obj, type);
		}
	}
Example #7
0
ISTFLOAT GetDet(ISTFLOAT a[4][4], ISTSHORT n)
{
	ISTSHORT i, j, j1, j2;
	ISTFLOAT det = 0;
	ISTFLOAT mat[4][4] = {{0}};

	if (n == 2) { /* terminate recursion */
		det = _sub(_mul(a[0][0], a[1][1]), _mul(a[1][0], a[0][1]));
	} else {
		det = 0;
		for (j1 = 0; j1 < n; j1++) { /* do each column */
			for (i = 1; i < n; i++) { /* create minor */
				j2 = 0;
				for (j = 0; j < n; j++) {
					if (j == j1) {
						continue;
					}
					mat[i-1][j2] = a[i][j];
					j2++;
				}
			}
			/* sum (+/-)cofactor * minor */
			if ((j1 % 2) == 0) {
				det = _add(det, _mul(a[0][j1], GetDet(mat, n-1)));
			} else {
				det = _sub(det, _mul(a[0][j1], GetDet(mat, n-1)));
			}
		}
	}
	return det;
}
Example #8
0
void
MMOModel::_parseEquation (string id, const ASTNode *node, MMODeclType tydec,
			  MMOSectionType type)
{
  MMOMath eq = MMOMath (_replace, &_functions, _prefix);
  eq.parseEquation (node);
  _addAlgebraicReplacement (eq);
  if (eq.hasEquation ())
    {
      MMODecl *exp = new MMODecl (id, eq.getExp (), tydec);
      if (tydec == algebraic_equation)
	{
	  _variables.insert (
	      pair<string, list<string> > (id, eq.getVariables ()));
	}
      _add (exp, type);
      if (_variableParameters.find (id) != _variableParameters.end ())
	{
	  MMODecl *dec = _declarations.findDec (id);
	  if (!dec->isState ())
	    {
	      dec->setType (algebraic);
	    }
	}
    }
  addExpressionZeroCrossings (eq, id);
}
    //-----------------------------------------------------------------------
    CollisionModelPtr CollisionModelManager::getCollisionModel(const Ogre::MeshPtr& mesh)
    {
        // Find in the cache
        CacheItemMap::iterator it = mCacheItemMap.find(mesh.get());

        if (it == mCacheItemMap.end())
        {
            // Free out-of-date collision models first
            _checkMemoryUsage();

            // Create new collision model
            CollisionModelPtr collisionModel(new CollisionModel);
            collisionModel->addMesh(mesh);
            collisionModel->build(false);

            // Add to cache
            _add(mesh, collisionModel);

            return collisionModel;
        }
        else
        {
            CacheItem* item = &it->second;

            // Update LRU queue
            _moveToFront(item);

            return item->collisionModel;
        }
    }
Example #10
0
void
MMOModel::add (const FunctionDefinition &f)
{
  string fname = f.getId ();
  MMOFunction *func = new MMOFunction (fname);
  int na = f.getNumArguments ();
  MMOMath d = MMOMath (_replace, &_functions, _prefix);
  list<string> funcArgs;
  for (int i = 0; i < na; i++)
    {
      d.parseEquation (f.getArgument (i));
      string argExp = d.getExp ();
      MMODecl *adec = new MMODecl (argExp, function_input);
      func->add (adec);
      funcArgs.push_back (argExp);
    }
  string var = MMOUtils::getInstance ()->getVar ();
  d.parseEquation (f.getBody ());
  _addAlgebraicReplacement (d);
  MMODecl *adec = new MMODecl (var, d.getExp (), function_definition);
  func->add (adec);
  _functions[fname] = pair<list<string>, ASTNode*> (
      funcArgs, new ASTNode (*f.getBody ()));
  _add (func, external_functions);
}
Example #11
0
    void ScanAndOrder::add(const BSONObj& o, const DiskLoc* loc) {
        verify( o.isValid() );
        BSONObj k;
        try {
            k = _order.getKeyFromObject(o);
        }
        catch (UserException &e) {
            if ( e.getCode() == ParallelArraysCode ) { // cannot get keys for parallel arrays
                // fix lasterror text to be more accurate.
                uasserted( 15925, "cannot sort with keys that are parallel arrays" );
            }
            else
                throw;
        }

        if ( k.isEmpty() ) {
            return;   
        }
        if ( (int) _best.size() < _limit ) {
            _add(k, o, loc);
            return;
        }
        BestMap::iterator i;
        verify( _best.end() != _best.begin() );
        i = _best.end();
        i--;
        _addIfBetter(k, o, i, loc);
    }
long _main()
{
struct EV_node * EV_list;
long EV_product;
long EV_sum;
long EV_result;
long EV_bigProduct;
long EV_i;
EV_i = 0;
EV_bigProduct = 0;
EV_list = _buildList();
EV_product = _multiple(EV_list);
EV_sum = _add(EV_list);
EV_result = (EV_product-(EV_sum/2));
while ((EV_i<10))
{
EV_bigProduct = (EV_bigProduct+_recurseList(EV_list));
EV_i = (EV_i+1);
}
printf("%ld\n", (long)EV_bigProduct);
while ((EV_bigProduct!=0))
{
EV_bigProduct = (EV_bigProduct-1);
}
printf("%ld\n", (long)EV_result);
printf("%ld\n", (long)EV_bigProduct);
return 0;
}
Example #13
0
void DirEntryList::_overwrite(vector<DirEntry>::iterator entry, const string &name, const Key &blobKey, fspp::Dir::EntryType entryType, mode_t mode,
                        uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime) {
    _checkAllowedOverwrite(entry->type(), entryType);
    // The new entry has possibly a different key, so it has to be in a different list position (list is ordered by keys).
    // That's why we remove-and-add instead of just modifying the existing entry.
    _entries.erase(entry);
    _add(name, blobKey, entryType, mode, uid, gid, lastAccessTime, lastModificationTime);
}
Example #14
0
void BTree::Add(T *d)
{
    Node *n = Search(d->number);
    if (n)
        n->addFine(d);
    else
        root = _add(root, d);
}
Example #15
0
static char *
_conv(int n, const char *format, char *pt, const char *ptlim)
{
	char		buf[INT_STRLEN_MAXIMUM(int) +1];

	sprintf(buf, format, n);
	return _add(buf, pt, ptlim);
}
Example #16
0
static char *
_conv(const int n, const char * const format, char * const pt, const char * const ptlim)
{
    char	buf[INT_STRLEN_MAXIMUM(int) + 1];

    (void) _snprintf(buf, sizeof buf, format, n);
    return _add(buf, pt, ptlim);
}
Example #17
0
 /**
  * @param hosts [ "a.foo.com" , "b.foo.com" ]
  */
 bool _addAll( StateMap& threads , const BSONObj& hosts ) {
     BSONObjIterator i( hosts );
     bool added = false;
     while ( i.more() ) {
         bool me = _add( threads , i.next().String() );
         added = added || me;
     }
     return added;
 }
Example #18
0
static char *
_conv(const int n, const char *const format, char *const pt,
      const char *const ptlim)
{
    char  buf[12];

    (void) snprintf(buf, 12, format, n);
    return _add(buf, pt, ptlim);
}
Example #19
0
QJSValue THREEVector3::add(QJSValue threeVector3) {
    THREEVector3 *vec = getAsTHREEVector3(threeVector3);
    if (!vec) {
        qDebug() << "THREEVector3::" << __FUNCTION__ << " parameter was not THREEVector3 was " << threeVector3.toQObject();
        return m_engine->newQObject(this);
    }

    return m_engine->newQObject(_add(vec));
}
Example #20
0
 void add(int u,int v,int z){
     int fu = top[u],fv = top[v];
     while(fu!=fv){
         if(dep[fu]<dep[fv]){
             swap(u,v);
             swap(fu,fv);
         }
         ql = pos[fu],qr = pos[u];
         _add(ql,qr,z);
         u = fa[fu];fu = top[u];
     }
     //		if(u==v) return;//边分治
     if(u==v);//点分治
     if(dep[u]>dep[v]) swap(u,v);
     //		ql = pos[son[u]],qr = pos[v];//边分治
     ql = pos[u],qr = pos[v];//点分治
     _add(ql,qr,z);
 }
Example #21
0
void DreamGenContext::dontloadseg() {
	ax = es.word(di);
	_add(di, 2);
	dx = ax;
	cx = 0;
	unsigned pos = engine->skipBytes(dx);
	dx = pos >> 16;
	ax = pos & 0xffff;
	flags._c = false;
}
Example #22
0
void CFrustum::CreateOccluder(Fvector* p, int count, Fvector& vBase, CFrustum& clip)
{
    VERIFY(count < FRUSTUM_SAFE);
    VERIFY(count >= 3);

    BOOL edge[FRUSTUM_SAFE];
    float cls[FRUSTUM_SAFE];
    ZeroMemory(edge, sizeof(edge));
    for (int i = 0; i < clip.p_count; i++)
    {
        // classify all points relative to plane #i
        fplane& P = clip.planes[i];
        for (int j = 0; j < count; j++) cls[j] = _abs(P.classify(p[j]));

        // test edges to see which lies directly on plane
        for (j = 0; j < count; j++)
        {
            if (cls[j] < EPS_L)
            {
                int next = j + 1;
                if (next >= count) next = 0;
                if (cls[next] < EPS_L)
                {
                    // both points lies on plane - mark as 'open'
                    edge[j] = true;
                }
            }
        }
    }

    // here we have all edges marked accordenly to 'open' / 'closed' classification
    _clear();
    _add(p[0], p[1], p[2]); // main plane
    for (i = 0; i < count; i++)
    {
        if (!edge[i])
        {
            int next = i + 1;
            if (next >= count) next = 0;
            _add(vBase, p[i], p[next]);
        }
    }
}
Example #23
0
void scp256_add(unsigned char *o, const unsigned char *x, const unsigned char *y) {

    fe a, b;

    _frombytes(a, x);
    _frombytes(b, y);
    _add(a, a, b);
    _tobytes(o, a);

    cleanup(a); cleanup(b);
}
Example #24
0
 // Add two entity tags which must be given the same patch index
 void addPair(const int eTag1, const int eTag2)
 {
   sharedPatch = true;
   PatchMapIt patch1 = _add(eTag1);
   PatchMapIt patch2 = _add(eTag2);
   if(patch1->second != patch2->second) {
     PatchData &PD1 = *(patch1->second);
     PatchData &PD2 = *(patch2->second);
     const int nTag = PD2.eTagVec.size();
     for(int iTag = 0; iTag != nTag; ++iTag) {
       // Move tag from PD2 to PD1
       const int tag = PD2.eTagVec[iTag];
       PD1.eTagVec.push_back(tag);
       // Update value in 'patch' for this tag
       if(tag != eTag2) patch[tag] = patch1->second;
     }
     patchData.erase(patch2->second);
     patch2->second = patch1->second;
   }
 }
Example #25
0
 void ScanAndOrder::_addIfBetter(const BSONObj& k, const BSONObj& o, const BestMap::iterator& i,
                                 const DiskLoc* loc) {
     const BSONObj& worstBestKey = i->first;
     int cmp = worstBestKey.woCompare(k, _order._spec.keyPattern);
     if ( cmp > 0 ) {
         // k is better, 'upgrade'
         _validateAndUpdateApproxSize( -i->first.objsize() + -i->second.objsize() );
         _best.erase(i);
         _add(k, o, loc);
     }
 }
Example #26
0
static ret_t
_set_mode (cherokee_fdpoll_select_t *fdp, int fd, int rw)
{
	ret_t ret;

	ret = _del (fdp, fd);
	if (unlikely(ret < ret_ok))
		return ret;

	return _add (fdp, fd, rw);
}
Example #27
0
void DirEntryList::addOrOverwrite(const string &name, const Key &blobKey, fspp::Dir::EntryType entryType, mode_t mode,
                       uid_t uid, gid_t gid, timespec lastAccessTime, timespec lastModificationTime,
                       std::function<void (const blockstore::Key &key)> onOverwritten) {
    auto found = _findByName(name);
    if (found != _entries.end()) {
        onOverwritten(found->key());
        _overwrite(found, name, blobKey, entryType, mode, uid, gid, lastAccessTime, lastModificationTime);
    } else {
        _add(name, blobKey, entryType, mode, uid, gid, lastAccessTime, lastModificationTime);
    }
}
Example #28
0
	void Patches::add( const Patches * pSource, int ofs, int len )
	{
		if( ofs > pSource->m_size )
			return;
			
		if( len > pSource->m_size - ofs )
			len = pSource->m_size - ofs;
	
		for( int i = 0 ; i < len ; i++ )
			_add( pSource->m_pFirst[ofs++], 0 );
	}
Example #29
0
/*
 * Executes a given instruction, or errors out
 * ins - instruction to run
 */
void
execute (unsigned short int ins)
{
    /* seperate instruction into parts */
    short int a0 = (ins >> 12) % 16;
    short int a1 = (ins >> 8) % 16;
    short int a2 = (ins >> 4) % 16;
    short int a3 = (ins >> 0) % 16;

    /* Run associated instruction */
    switch(a0) {
    case 0x0:
        _add (a1, a2, a3);
        break;
    case 0x1:
        _sub (a1, a2, a3);
        break;
    case 0x2:
        _mul (a1, a2, a3);
        break;
    case 0x3:
        _div (a1, a2, a3);
        break;
    case 0x6:
        _beq (a1, a2, a3);
        break;
    case 0x7:
        _bgt (a1, a2, a3);
        break;
    case 0x8:
        _ld (a1, a2, a3);
        break;
    case 0x9:
        _st (a1, a2, a3);
        break;
    case 0xa:
        _lc (a1, a3);
        break;
    case 0xb:
        _jmp (a1, a3);
        break;
    case 0xc:
        _inc (a1, a3);
        break;
    case 0xf:
        _sys (a1, a3);
        break;
    default:
        printf ("Error: invalid opcode %#x.\n", a0);
        sys_dump (0x0);
        sys_halt (0x0);
    }
}
Example #30
0
void
MMOModel::_addAlgebraicReplacement (MMOMath& eq)
{
  for (pair<string, pair<string, list<string> > > def = eq.firstAlgebraic ();
      !eq.endAlgebraic (); def = eq.nextAlgebraic ())
    {
      MMODecl* exp = new MMODecl (def.first, def.second.first,
				  algebraic_equation);
      _variables.insert (
	  pair<string, list<string> > (def.first, def.second.second));
      _add (exp, equation);
    }
  for (string imp = eq.firstImport (); !eq.endImport (); imp = eq.nextImport ())
    {
      if (_imports.find (imp) == _imports.end ())
	{
	  MMODecl* exp = new MMODecl (imp, import);
	  _add (exp, imports);
	}
    }
}