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


C++ Aggregate类代码示例

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


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

示例1: print_it

// Recursively print the hierarchy starting from the root.
// If there is only one aggregate object, the hierarchy will
// only be one level deep (i.e. the children of the one
// aggregate).  However, if there are other aggregates nested 
// within the top one, the printer will print each nested
// aggregate with further indentation.
void printer::print_it( std::ostream &out, Object *root )
    {
    if( root == NULL ) return;
    if( root->PluginType() == aggregate_plugin )
        {
        Aggregate *agg = (Aggregate *)root;
        out << indent() << "begin " << root->MyName() << endl;
        indent_n += 4;
        agg->Begin();
        for( int n = 0;  ; n++ )
            {
            Object *obj = agg->GetChild();
            if( obj == NULL ) break;
            if( limit > 0 && n == limit )
                {
                // Indicate that the list has been truncated.
                out << indent() << "..." << endl;
                break;
                }
            else print_it( out, obj );
            }
        indent_n -= 4;
        out << indent() << "end" << endl;
        }
    else if( root->PluginType() == primitive_plugin )
        {
        out << indent() << root->MyName() << endl;
        }
    }
开发者ID:IshwarKulkarni,项目名称:ToyTracer,代码行数:35,代码来源:printer.cpp

示例2: insertSlice

// appends to the current aggregate a slice from a given aggregate from position i1 to position i2
void Aggregate::insertSlice(Aggregate a,Word pos,Word i1,Word i2){
	ADJUSTOFFSET(elements(),pos);ADJUSTOFFSET2(a.elements(),i1,i2);assert0(i1<=i2,"appendSlice");
	Word sz=i2-i1;checkResize(sz);
	elements(elements()+sz);
	WordMove(dataP()+pos+sz,dataP()+pos,elements()-pos);
	WordCpy(dataP()+pos,a.dataP()+i1,sz);
}
开发者ID:gkourtis,项目名称:napl22,代码行数:8,代码来源:Aggregate.cpp

示例3: CASEIF

AggregateOrdered ET::match(const Aggregate s,AggregateOrdered positions, Obj pat,AggregateOrdered r){
	SWITCHstart
		CASEIF(pat.isInstanceOf(classInt))
			uWord sn=s.elements();
// looping on the positions 
// if a position is between start and end and the pattern equals 
// the value at pos then add the next position to the results.
			for(auto p:positions){
				if(0<=p && p<sn && pat.w==s[p]) 
					r&=p+1; //&= adds a single object to an ordered aggregate (if it doesn't exists already)
			}
		CASEIF(pat.isInstanceOf(classDouble))
			uWord sn=s.elements();
			for(auto p:positions){
				if(0<=p && p<sn && compare(pat,s[p])==0) 
					r&=p+1; //&= adds a single object to an ordered aggregate (if it doesn't exists already)
			}
		CASEIF(pat.isInstanceOf(classPatternAll))
			AggregateOrdered r1=positions;
			for(auto pat1:(Aggregate)pat)
				r1=match(s,r1,pat1);
			if(r.elements()==0) r=r1;else r+=r1;
		CASEIF(pat.isInstanceOf(classPatternAny))
			for(auto pat1:(Aggregate)pat)
				match(s,positions,pat1,r);
		CASEIF(pat.isInstanceOf(classAggregate))
			stack().push(positions);
			execute(pat,true); // should execute independently from the execution status ? should be explained !
			r=stack().pop();
		DEFAULT
			assert0(false,"unexpected in matchAll");
	endSWITCH
	return r;
}
开发者ID:gkourtis,项目名称:napl22,代码行数:34,代码来源:patternMatching.cpp

示例4: main

int main() {
    
    Persona p1(20);
    Persona p2(30);
    Aggregate<Persona> lista;
    lista.add(p1);
    lista.add(p2);
    
    for (Iterator<Persona> i = lista.getIterator(); ; ) {
        
    }
    
    return 0;
}
开发者ID:EngelTz,项目名称:TC2004,代码行数:14,代码来源:main.cpp

示例5: CountObjects

// Count the number of objects (either just primitives, or both primitives
// and aggregates) contained in a scene graph.
int CountObjects( const Object *root, bool just_primitives )
    {
    if( root == NULL ) return 0;
    if( root->PluginType() != aggregate_plugin ) return 1;
    Aggregate *agg = (Aggregate *)root;
    agg->Begin();
    int count = ( just_primitives ? 0 : 1 );
    for(;;)
        {
        Object *obj = agg->GetChild();
        if( obj == NULL ) break;
        count += CountObjects( obj, just_primitives );
        }
    return count;
    }
开发者ID:IshwarKulkarni,项目名称:ToyTracer,代码行数:17,代码来源:util.cpp

示例6:

  Aggregate*
  Definition::FindAggregate ( uint32_t hash )
  {
    for ( uint32_t i = 0; i < m_NumAggregates; i++ )
    {
      Aggregate* aggregate = ( *this ) [i];

      if ( aggregate->GetNameHash() == hash )
      {
        return aggregate;
      }
    }

    return 0;
  }
开发者ID:macton,项目名称:DDLParser,代码行数:15,代码来源:DDLParser.cpp

示例7: ConcreteAggregate

					void Client::someOperation()
					{
						std::string names[3] = {"张三","李四","王五"};
						//创建聚合对象
						Aggregate *aggregate = new ConcreteAggregate(names);
						//循环输出聚合对象中的值
						Iterator it = aggregate->createIterator();
						//首先设置迭代器到第一个元素
						it->first();
						while(!it->isDone())
						{
							//取出当前的元素来
							object *obj = it->currentItem();
							puts("the obj=="+obj);
							//如果还没有迭代到最后,那么就向下迭代一个
							it->next();
						}
					}
开发者ID:Winnerhust,项目名称:MyTool,代码行数:18,代码来源:Client.cpp

示例8: main

int main(int argc, const char * argv[]) {
    FabricaFisica * aguascalientes;
    FabricaFisica * cdmx;
    
    Pastel * leches = aguascalientes->crearPastel("tresleches");
    leches->setNombre("pastelito");
    
    Pastel * sach = cdmx->crearPastel("sacher");
    leches->setNombre("pastelote");
    
    Pastel * impo = cdmx->crearPastel("imposible");
    leches->setNombre("impozzible");
    
    Pastel * choco = cdmx->crearPastel("chocolate");
    
    //Clonado
    Pastel * nueva;
    nueva = leches->clonar();
    nueva->empaquetado();
    
    //Aggregate e iterador
    Aggregate <Pastel*> pastelesAguascalientes;
    pastelesAguascalientes.add(leches);
    
    Aggregate <Pastel*> pastelesCDMX;
    pastelesCDMX.add(leches);
    pastelesCDMX.add(impo);
    
    Iterator<Pastel *> * iterador;
    /*
    for(iterador = pastelesCDMX.getIterator(); iterador->hasNext(); )
    {
        iterador->next()->amasado();
    }
     */
    iterador->imprimirPasteles(pastelesCDMX);
    iterador->buscarPastel("impozzible", pastelesCDMX);
    
    return 0;
}
开发者ID:iturbe,项目名称:ariel,代码行数:40,代码来源:main.cpp

示例9: main

int main()
{
    Aggregate* pAggregate = new ConcreateAggregate(4);
    /*
    Iterater* pIterater = new ConcreateIterater(pAggregate);

    for (; false == pIterater->IsDone(); pIterater->Next())
    {
        std::cout << pIterater->CurrentItem() << std::endl;


    }

    std::cout << pAggregate->GetItem(0)<< std::endl;
    std::cout << pAggregate->GetItem(1)<< std::endl;
    std::cout << pAggregate->GetItem(2)<< std::endl;
    std::cout << pAggregate->GetItem(3)<< std::endl;

    std::cout << pAggregate->GetSize()<< std::endl;
*/
    /*用法比较犀利*/
    Iterater* pIterater = pAggregate->CreateIterater(pAggregate);

    for (; false == pIterater->IsDone(); pIterater->Next())
    {
        std::cout << pIterater->CurrentItem() << std::endl;


    }

    std::cout << pAggregate->GetItem(0)<< std::endl;
    std::cout << pAggregate->GetItem(1)<< std::endl;
    std::cout << pAggregate->GetItem(2)<< std::endl;
    std::cout << pAggregate->GetItem(3)<< std::endl;

    std::cout << pAggregate->GetSize()<< std::endl;
    return 0;
}
开发者ID:ShiyuanSolutions,项目名称:c-_Learning,代码行数:38,代码来源:main.cpp

示例10: extended

/**
 * From P <=> Agg
 * go to
 *
 * P <=> (Pnew | M1) & M2
 * Pnew <=> Agg
 * and M1 assumed false, M2 assumed true
 */
void OneShotUnsatCoreExtraction::add(const Aggregate& agg) {
	Aggregate extended(agg);
	auto oldhead = extended.head;
	auto newhead = getRemapper()->getNewVar();
	auto truemarker = getRemapper()->getNewVar();
	auto falsemarker = getRemapper()->getNewVar();
	auto tseitin = getRemapper()->getNewVar();
	extended.head = mkPosLit(newhead);
	switch (agg.sem) {
	case AggSem::DEF: {
		Rule impl(agg.getID(), tseitin, { mkPosLit(newhead), mkPosLit(falsemarker) }, false, agg.defID, agg.onlyif);
		Rule impl2(agg.getID(), var(oldhead), { mkPosLit(tseitin), mkPosLit(truemarker) }, true, agg.defID, agg.onlyif);
		space->add(impl);
		space->add(impl2);
		break;
	}
	case AggSem::COMP: {
		Implication impl(agg.getID(), mkPosLit(tseitin), ImplicationType::EQUIVALENT, { mkPosLit(newhead), mkPosLit(falsemarker) }, false);
		Implication impl2(agg.getID(), oldhead, ImplicationType::EQUIVALENT, { mkPosLit(tseitin), mkPosLit(truemarker) }, true);
		space->add(impl);
		space->add(impl2);
		break;
	}
	case AggSem::OR: {
		Implication impl2(agg.getID(), ~oldhead, ImplicationType::IMPLIES, { mkPosLit(newhead), mkPosLit(falsemarker) }, false);
		space->add(impl2);
		break;
	}
	}
	markerAssumptions.push_back(mkNegLit(falsemarker));
	markerAssumptions.push_back(mkPosLit(truemarker));
	id2constr[agg.getID()] = new Aggregate(agg);
	marker2ids[truemarker].push_back(agg.getID());
	marker2ids[falsemarker].push_back(agg.getID());
	space->add(extended);

}
开发者ID:vonwenm,项目名称:Minisatid,代码行数:45,代码来源:OneShotTasks.cpp

示例11: match

AggregateOrdered match(const Aggregate s,AggregateOrdered positions, Obj pat,AggregateOrdered r=0,Word pn=1){
// p holds the positions array that may have 1 or 2 columns per raw
#define loop(aa,step) for(Word i=0,i1=aa.elements(),p;i<i1 && (p=aa[i],true);i+=step)
	
	switch(pat.Class().w){
		case _classInt:{
			if(!r) 
				r=AggregateOrdered();
			uWord sn=s.elements();
			loop(positions,pn){
				if(0<=p && p+1<=sn && s[p]==pat.w) r.keyExists((Obj)(p+1));
			}
		};
		break;
		case _classAggregate:
			stack.push(positions);
			execute(pat,true);
			r=stack.pop();
			break;
		case _classString:
		case _classPatternAll:{
			AggregateOrdered r1=positions;
			for(auto pat1:(Aggregate)pat)
				r1=match(s,r1,pat1);
			if(!r) r=r1;else r+=r1;
			break;
		}
		case _classPatternAny:
			if(!r) 
				r=AggregateOrdered();
			for(auto pat1:(Aggregate)pat)
				match(s,positions,pat1,r);
			break;
		default:
			assert0(false,"unexpected in matchAll");
			break;
	}
	return r;
}
开发者ID:gkourtis,项目名称:napl22,代码行数:39,代码来源:patternMatching1.cpp

示例12: matchEnd

AggregateOrdered ET::matchEnd(Aggregate s,AggregateOrdered positions){
	AggregateOrdered r;
	if(positions.keyExists(s.elements(),false))
		r.push(s.elements());
	return r;
}
开发者ID:gkourtis,项目名称:napl22,代码行数:6,代码来源:patternMatching.cpp

示例13: r

Aggregate ET::allPos(Aggregate s,Word startPos){
	uWord sn=s.elements(),n=(startPos<=sn?sn-startPos:0);
	Aggregate r(n,n);
	for(uWord i=0,j=startPos;i<n;i++,j++) r[i]=j;
	return r;
}
开发者ID:gkourtis,项目名称:napl22,代码行数:6,代码来源:patternMatching.cpp

示例14: Scene

	Scene(Aggregate* aggregate, const vector<Light *> & lights) 
		: aggregate(aggregate), lights(lights), bound(aggregate->world_bound()) {
		//if (volumeRegion) bound = Union(bound, volumeRegion->WorldBound());
	};
开发者ID:yushroom,项目名称:RenderFish,代码行数:4,代码来源:Scene.hpp

示例15: Interval

bool basic_builder::BuildScene( string file_name, Camera &camera, Scene &scene ) const
    {
    int line_num = 0;
    char input_line[512];
    Plugin    *dat = NULL;  // A container for arbitrary data.
    Object    *obj = NULL;  // The current object, which was the last object created.
    Shader    *shd = NULL;  // The current shader. 
    Aggregate *agg = NULL;  // Current aggregate object, to which all objects are now added.
    Envmap    *env = NULL;  // Current environment map.
    Material  *mat = NULL;  // Current material pointer.
    Material   material;    // Current material.

    scene.object    = NULL;
    scene.envmap    = NULL;
    scene.rasterize = NULL;

    // Attempt to open the input file.

    file_name += ".sdf";
    std::ifstream fin;
    fin.open( file_name.c_str() );
    if( fin.fail() )
        {
        cerr << "Error: Could not open file " << file_name << endl;
        return false;  // Report failure.
        }
    cout << "Reading " << file_name << "... ";
    cout.flush();

    // Set some defaults.

    material.diffuse      = White;
    material.emission     = Black;
    material.specular     = White;
    material.ambient      = Black;
    material.reflectivity = Black;
    material.translucency = Black;
    material.ref_index    = 0.0;
    material.Phong_exp    = 0.0;

    camera.x_res = default_image_width;
    camera.y_res = default_image_height;
    camera.x_win = Interval( -1.0, 1.0 );
    camera.y_win = Interval( -1.0, 1.0 );

    // Process lines until the end of file is reached.
    // Print a warning for all lines that are unrecognizable.

    while( fin.getline( input_line, 512 ) ) 
        {
        line_num++;
        if( Skip( input_line ) ) continue;

        // Ask each registered object if it recognizes the line.  If it does, it will
        // create a new instance of the object and return it as the function value.

        Plugin *plg = Instance_of_Plugin( input_line );

        if( plg != NULL )
            {
            switch( plg->PluginType() )
                {
                case data_plugin:
                    if( obj == NULL ) cerr << "Error: data ignored.  Line " << line_num << endl;
                    else obj->AddData( obj );
                    break;

                case shader_plugin:
                    shd = (Shader*)plg;
                    break;					
 
                case aggregate_plugin:
                    obj = (Object*)plg;
                    obj->shader   = shd;
                    obj->envmap   = env;
                    obj->material = Copy( mat, material );
                    obj->parent   = agg;
                    if( Emitter( material ) )
                        {
                        cerr << "Error: An aggregate object cannot be an emitter.  Line "
                             << line_num << ": "
                             << input_line << endl;
                        return false;
                        }
                    if( agg != NULL ) // If there is alrealy an agg obj, this one is a child.
                        {
                        // agg->AddChild( obj );
                        // Do not add aggregates as children until they are complete.
                        agg->material = Copy( mat, material );
                        }
                    else if( scene.object == NULL ) scene.object = obj;
	            agg = (Aggregate *)obj;
                    break;

                case primitive_plugin:
                    obj = (Object*)plg;
                    obj->shader   = shd;
                    obj->envmap   = env;
                    obj->material = Copy( mat, material );
                    obj->parent   = agg;
//.........这里部分代码省略.........
开发者ID:zackattacknyu,项目名称:CS211B_Assigment3,代码行数:101,代码来源:basic_builder.cpp


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