• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Tree类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setProperty

void setProperty (Tree t, Tree key, Tree val)
{
	CTree* pl = t->attribut();
	if (pl) t->attribut(updateKey(pl, key, val)); 
	else 	t->attribut(updateKey(nil, key, val));
}
开发者ID:gauravchawla03,项目名称:Stanford,代码行数:6,代码来源:list.cpp


示例2: calc_node_statistics_tree

node_statistics calc_node_statistics_tree( Tree const& tree )
{
    node_statistics stat;
    detail::update_statistics( tree.root() , stat );
    return stat;
}
开发者ID:Ambrosys,项目名称:gpcxx,代码行数:6,代码来源:node_statistics.hpp


示例3: vector

	bool TestBTree::testErase()
	{
		status << "Running Test Insert\n";

		Map map;
		Tree tree;
		Vector vector( elements );
		_init( vector );
		
		for( unsigned int i = 0; i < iterations; ++i )
		{
			switch( random() % 2 )
			{
				case 0:
				{
					size_t index = random() % vector.size();
					map.insert( std::make_pair( vector[ index ], i ) );
					Tree::iterator fi = 
						tree.lower_bound( vector[ index ] );
					fi = tree.insert( fi, 
						std::make_pair( vector[ index ], i ) );
					if( fi->first != vector[ index ] )
					{
						status << "Insert failed, returned iterator with key " 
						<< fi->first << " does not match inserted value " 
						<< vector[ index ] << "\n";
						dumpTree( tree, path );
						return false;
					}		
					break;
				}
								
				case 1:
				{
					size_t index = random() % vector.size();
					size_t index1 = random() % vector.size();
					Map::iterator mi = map.find( vector[ index ] );
					Map::iterator mi1 = map.find( vector[ index1 ] );
					Tree::iterator ti = tree.find( vector[ index ] );
					Tree::iterator ti1 = tree.find( vector[ index1 ] );
					
					if( mi == map.end() && mi1 == map.end() )
					{
						break;
					}
					
					if( mi == map.end() && mi1 != map.end() )
					{
						std::swap( mi, mi1 );
						std::swap( ti, ti1 );
					}
					else if( mi != map.end() && mi1 != map.end() )
					{
						if( mi1->first < mi->first )
						{
							std::swap( mi, mi1 );
							std::swap( ti, ti1 );
						}
					}
					
					map.erase( mi, mi1 );
					tree.erase( ti, ti1 );
					break;
				}
			}
		}
			
		{
			Map::iterator mi = map.begin();
			Tree::iterator ti = tree.begin();

			for( ; mi != map.end() && ti != tree.end(); ++mi, ++ti )
			{
				if( mi->first != ti->first )
				{
					status << "Erase failed, map key " << mi->first
						<< " does not match tree key " << ti->first 
						<< "\n";
					dumpTree( tree, path );
					return false;
				}
				if( mi->second != ti->second )
				{
					status << "Erase failed, map value " 
						<< mi->second
						<< " does not match tree value " << ti->second 
						<< "\n";
					dumpTree( tree, path );
					return false;
				}
			}
		}
		
		status << "  Test Erase Passed.\n";
		return true;
	}
开发者ID:3upperm2n,项目名称:hydrazine,代码行数:96,代码来源:TestBTree.cpp


示例4: main

// Begin the main program.
int main (int argc, char** argv)
{

LibMeshInit init (argc, argv);
Mesh mesh(3);
EquationSystems equation_systems (mesh);
read_parameters(equation_systems,argc,argv);
std::string result_file_name (equation_systems.parameters.get<std::string>("result_file_name"));

unsigned int n_timesteps = equation_systems.parameters.get<Real>("n_timesteps");
unsigned int N_eles=equation_systems.parameters.get<Real>("N_eles");
 
Real time = 0;
Real end_time = equation_systems.parameters.get<Real>("end_time");
const unsigned int n_nonlinear_steps = 6;
const Real nonlinear_tolerance = 1.e-3;
const Real initial_linear_solver_tol = 1.e-18;

if(!equation_systems.parameters.get<std::string>("problem").compare("cube")){

MeshTools::Generation::build_cube (
mesh,
                                       1,1,2,
                                       0.0, 1.0,
                                       0.0, 1.0,
																			 0.0, 1.0,
                                       HEX8);
                                      

}	


if((!equation_systems.parameters.get<std::string>("problem").compare("lung")) || (!equation_systems.parameters.get<std::string>("problem").compare("cylinder"))){
  
std::string mesh_file_name (equation_systems.parameters.get<std::string>("mesh_input"));
GmshIO(mesh).read(mesh_file_name);

}
 
//Create tree
Tree tree;
tree.read_tree(equation_systems);

mesh.prepare_for_use();

setup_equationsystem(equation_systems);
TransientLinearImplicitSystem& newton_update = equation_systems.get_system<TransientLinearImplicitSystem>("Newton-update");
TransientLinearImplicitSystem& reference = equation_systems.get_system<TransientLinearImplicitSystem>("Reference-Configuration");
TransientLinearImplicitSystem& last_non_linear_soln = equation_systems.get_system<TransientLinearImplicitSystem>("Last-non-linear-soln");
TransientLinearImplicitSystem& postvars = equation_systems.get_system<TransientLinearImplicitSystem>("postvars");




equation_systems.init ();
equation_systems.print_info();
 
/*
const MeshBase::const_node_iterator nd_end_tlc =
      equation_systems.get_mesh().local_nodes_end();
for (MeshBase::const_node_iterator nd = equation_systems.get_mesh().local_nodes_begin();
      nd != nd_end_tlc; ++nd) {
  const Node *node = *nd;

//Copy initial mesh into reference.solution
  for (unsigned int d = 0; d < 3; ++d) {
		//Save the TLC reference
    unsigned int dest_dof = node->dof_number(reference.number(), d+4, 0);
    Real value = (*node)(d);
    reference.current_local_solution->set(dest_dof, value);
    reference.solution->set(dest_dof, value);

	}
}
 */

//Move mesh and tree from inspiration to registered expiration
  
 const Point Aexp = equation_systems.parameters.get<Point>("A");
const Point bexp = equation_systems.parameters.get<Point>("b");

Real facexp=1.4;
//Update the position of the airway tree
std::cout<<"Moving tree to expiratory FRC " <<std::endl;
    for (double j=0; j <tree.number_nodes ; j++) {
			for (unsigned int d = 0; d < 3; ++d) {
				tree.nodes(j)(d)=tree.nodes(j)(d)-facexp*( tree.nodes(j)(d)*Aexp(d)+bexp(d) );
			}
				
				
				//Move mesh a bit more to ecncompass tree on;y do this for N48
				//	if((!equation_systems.parameters.get<std::string>("mesh_input").compare("meshes/lung/N048r_fine2881.msh")) || (!equation_systems.parameters.get<std::string>("mesh_input").compare("meshes/lung/N048_node5036.msh"))){
					  	if( (!equation_systems.parameters.get<std::string>("mesh_input").compare("meshes/lung/N048_node5036.msh"))){
						
						//tree.nodes(j)(0)= tree.nodes(j)(0)*0.98+2; //-paper don't know why ??
						//tree.nodes(j)(1)= tree.nodes(j)(1)*0.98+4; //-paper don't know why ??
						//tree.nodes(j)(2)= tree.nodes(j)(2)*0.98+2; //-paper don't know why ??
											
						tree.nodes_deformed(j)(0)=tree.nodes(j)(0);
//.........这里部分代码省略.........
开发者ID:loztop,项目名称:large_deformation_lung,代码行数:101,代码来源:poro_main.C


示例5: switch

void World::touchMove(int id, int x, int y) {
	if(id>1)
		return;

 	touchCurrentX[id] = x;
	touchCurrentY[id] = y;

#if !USE_MOUSE
	if(id == 1) {
		touched[1] = true;
		touchStartX[1] = touchCurrentX[1];
		touchStartY[1] = touchCurrentY[1];

		touchEvent = TE_ZOOM;
		touchStartX[0] = touchCurrentX[0];
		touchStartY[0] = touchCurrentY[0];
		panStart = pos;
		scaleStart = scale;
		return;
	}
#endif

	switch(touchEvent) {
		case TE_ZOOM: 
			setScale(scaleStart * (vec2((float)touchCurrentX[0] - touchCurrentX[1], (float)touchCurrentY[0] - touchCurrentY[1]).length() /
				vec2((float)touchStartX[0] - touchStartX[1], (float)touchStartY[0] - touchStartY[1]).length() ) );
			move(panStart + pointToPos((touchStartX[0] + touchStartX[1]) / 2, (touchStartY[0] + touchStartY[1]) / 2)
				-	pointToPos((touchCurrentX[0] + touchCurrentX[1]) / 2, (touchCurrentY[0] + touchCurrentY[1]) / 2) );
			break;
		case TE_PAN:
			move(panStart + pointToPos(touchStartX[id], touchStartY[id]) - pointToPos(touchCurrentX[id], touchCurrentY[id]));
			break;
		case TE_TRY:
		case TE_CAN_LINK:
		case TE_CAN_UNLINK:
			if(id>0)
				break;
			{
			Planet* targetPlanet = getPlanet( pointToPos(x, y) );
			if(!targetPlanet || targetPlanet == sourcePlanet) {
				touchEvent = TE_TRY;
				break;
			}
			Tree *targetTree = targetPlanet->getTree(currentRace);
			if(targetTree) {
				if(targetTree->isLinked(sourcePlanet)) {
					touchEvent = TE_CAN_UNLINK;
					break;
				}
			}
			Tree *sourceTree = sourcePlanet->getTree(currentRace);
			if(sourceTree) {
				if(sourceTree->isLinked(targetPlanet)) {
					touchEvent = TE_TRY;
					break;
				}
				touchEvent = TE_CAN_LINK;
			}
			}
			break;
	}

}
开发者ID:alexsaen,项目名称:Roots,代码行数:63,代码来源:World.cpp


示例6: defined

EstOutput Parsimony::createProcesses(Tree* t, vector< vector<string> > namesOfGroupCombos, CountTable* ct) {
	try {
        int process = 1;
		vector<int> processIDS;
		
		EstOutput results;

#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
				
		//loop through and create all the processes you want
		while (process != processors) {
			int pid = fork();
			
			if (pid > 0) {
				processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
				process++;
			}else if (pid == 0){
				EstOutput myresults;
				myresults = driver(t, namesOfGroupCombos, lines[process].start, lines[process].num, ct);
				
				if (m->control_pressed) { exit(0); }
				
				//pass numSeqs to parent
				ofstream out;
				string tempFile = outputDir + toString(getpid()) + ".pars.results.temp";
				m->openOutputFile(tempFile, out);
				out << myresults.size() << endl;
				for (int i = 0; i < myresults.size(); i++) {  out << myresults[i] << '\t';  } out << endl;
				out.close();
				
				exit(0);
			}else { 
				m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
				for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
				exit(0); 
			}
		}
		
		results = driver(t, namesOfGroupCombos, lines[0].start, lines[0].num, ct);
		
		//force parent to wait until all the processes are done
		for (int i=0;i<processIDS.size();i++) { 
			int temp = processIDS[i];
			wait(&temp);
		}
		
		if (m->control_pressed) { return results; }
			
		//get data created by processes
		for (int i=0;i<processIDS.size();i++) { 
			ifstream in;
			string s = outputDir + toString(processIDS[i]) + ".pars.results.temp";
			m->openInputFile(s, in);
			
			//get scores
			if (!in.eof()) {
				int num;
				in >> num; m->gobble(in);
				
				if (m->control_pressed) { break; }
				
				double w; 
				for (int j = 0; j < num; j++) {
					in >> w;
					results.push_back(w);
				}
				m->gobble(in);
			}
			in.close();
			m->mothurRemove(s);
		}
#else
        //fill in functions
        vector<parsData*> pDataArray;
		DWORD   dwThreadIdArray[processors-1];
		HANDLE  hThreadArray[processors-1];
        vector<CountTable*> cts;
        vector<Tree*> trees;
		
		//Create processor worker threads.
		for( int i=1; i<processors; i++ ){
            CountTable* copyCount = new CountTable();
            copyCount->copy(ct);
            Tree* copyTree = new Tree(copyCount);
            copyTree->getCopy(t);
            
            cts.push_back(copyCount);
            trees.push_back(copyTree);
            
            parsData* temppars = new parsData(m, lines[i].start, lines[i].num, namesOfGroupCombos, copyTree, copyCount);
			pDataArray.push_back(temppars);
			processIDS.push_back(i);
            
			hThreadArray[i-1] = CreateThread(NULL, 0, MyParsimonyThreadFunction, pDataArray[i-1], 0, &dwThreadIdArray[i-1]);
		}
		
		results = driver(t, namesOfGroupCombos, lines[0].start, lines[0].num, ct);
		
		//Wait until all threads have terminated.
		WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
//.........这里部分代码省略.........
开发者ID:jonls,项目名称:mothur,代码行数:101,代码来源:parsimony.cpp


示例7: addTree

bool Tree::addTree(const Tree& tree, const std::string& tree_name,
        const std::string& hook_name) {
    return this->addTreeRecursive(tree.getSegment("root"), tree_name, hook_name);
}
开发者ID:Eibriel,项目名称:blender-dfelinto,代码行数:4,代码来源:tree.cpp


示例8: getLnTreeProb

double Treescale::updateTreeScale(double &oldLnL) {
	
	Tree *t = modelPtr->getActiveTree();
	Node *rt = t->getRoot();

	double oldtreeprob = getLnTreeProb(t);
	
	if(retune && tuning > scaleVal)
		tuning = scaleVal * 0.5;
		
	double limO = scaleVal + tuning;
	double limY = scaleVal - tuning;
	double rtLB = t->getNodeLowerBoundTime(rt) * scaleVal;
	double lowBound = rtLB;
	
	double hiBound = limO;
	if(treeTimePrior == 4){
		if(hiBound > treeOriginTime)
			hiBound = treeOriginTime;
	}
	
	if(isBounded){
		if(lowBound < yngBound)
			lowBound = yngBound;
		if(hiBound > oldBound)
			hiBound = oldBound;
	}
	
	double oldRH, newRH;
	oldRH = scaleVal;
		
	double u = ranPtr->uniformRv(-0.5,0.5) * (limO - limY);
	newRH = oldRH + u;
	while(newRH < lowBound || newRH > hiBound){
		if(newRH < lowBound)
			newRH = (2 * lowBound) - newRH;
		if(newRH > hiBound)
			newRH = (2 * hiBound) - newRH;
	}
		
	double scaleRatio = oldRH / newRH;
	int numNodes = t->getNumNodes();
	for(int i=0; i<numNodes; i++){
		Node *p = t->getNodeByIndex(i);
		if(p != rt){
			if(p->getIsLeaf() && p->getIsCalibratedDepth() == false){
				p->setNodeDepth(0.0);
			}
			else{
				double oldP = p->getNodeDepth();
				double newP = oldP * scaleRatio;
				p->setNodeDepth(newP);
				p->setFossAttchTime(0.0);
				if(false){
					double oldPhi = p->getFossAttchTime();
					double fA = p->getNodeYngTime();
					double newPhi = oldPhi * scaleRatio;
					if(newPhi*newRH < fA){
						cout << i << " op = " << oldPhi*oldRH << "  np = " << newPhi*newRH << " oRH = " << oldRH << "  nRH = " 
							<< newRH << "  fA = " << fA << endl;
					}
					int x = t->countDecLinsTimeIntersect(p, newPhi, newP);
					p->setFossAttchTime(newPhi);
					p->setNumFossAttchLins(x); 
				}
			}
		}
	}
	scaleVal = newRH;
	t->setTreeScale(scaleVal);
	t->treeScaleUpdateFossilAttchTimes(scaleRatio, oldRH, newRH);
	t->treeUpdateNodeOldestBoundsAttchTimes();
	t->setAllNodeBranchTimes();
		
	double lnPriorRatio = 0.0; 
	double newtreeprob = getLnTreeProb(t);
	lnPriorRatio += (newtreeprob - oldtreeprob);
	if(tsPriorD == 2){
		if(exponHPCalib)
			expoRate = t->getRootCalibExpRate();
		lnPriorRatio += lnExponentialTSPriorRatio(newRH, oldRH);
	}
	double lnProposalRatio = 0.0;
	
	double jacobian = 0.0;
	if(treeTimePrior < 2)
		jacobian = (log(oldRH) - log(newRH)) * (t->getNumTaxa() - 2);


	t->flipAllCls();
	t->flipAllTis();
	t->upDateAllCls();
	t->upDateAllTis();
	modelPtr->setTiProb();
	
	
	return lnPriorRatio + lnProposalRatio + jacobian;
}
开发者ID:lheins,项目名称:FDPPDIV,代码行数:98,代码来源:Parameter_treescale.cpp


示例9: tmap

Tree tmap (Tree key, tfun f, Tree t)
{	
	//printf("start tmap\n");
	Tree p; 
	
	if (getProperty(t, key, p)) {
		
		return (isNil(p)) ? t : p;	// truc pour eviter les boucles
		
	} else {
		
		Tree r1=nil;
		switch (t->arity()) {
			
			case 0 : 
				r1 = t; 
				break;
			case 1 : 
				r1 = tree(t->node(), tmap(key,f,t->branch(0))); 
				break;
			case 2 : 
				r1 = tree(t->node(), tmap(key,f,t->branch(0)), tmap(key,f,t->branch(1))); 
				break;
			case 3 : 
				r1 = tree(t->node(), tmap(key,f,t->branch(0)), tmap(key,f,t->branch(1)),
										   tmap(key,f,t->branch(2))); 
				break;
			case 4 : 
				r1 = tree(t->node(), tmap(key,f,t->branch(0)), tmap(key,f,t->branch(1)),
										   tmap(key,f,t->branch(2)), tmap(key,f,t->branch(3))); 
				break;
		}
		Tree r2 = f(r1);
		if (r2 == t) {
			setProperty(t, key, nil);
		} else {
			setProperty(t, key, r2);
		}
		return r2;
	}
}
开发者ID:gauravchawla03,项目名称:Stanford,代码行数:41,代码来源:list.cpp


示例10: subst

static Tree subst (Tree t, Tree propkey, Tree id, Tree val)
{
	Tree p;
	
	if (t==id) {
		return val;
		
	} else if (t->arity() == 0) {
		return t;
	} else if (getProperty(t, propkey, p)) {
		return (isNil(p)) ?  t : p;
	} else {
		Tree r=nil;
		switch (t->arity()) {
			
			case 1 : 
				r = tree(t->node(), 
							subst(t->branch(0), propkey, id, val)); 
				break;
				
			case 2 : 
				r = tree(t->node(), 
							subst(t->branch(0), propkey, id, val), 
							subst(t->branch(1), propkey, id, val)); 
				break;
				
			case 3 : 
				r = tree(t->node(), 
							subst(t->branch(0), propkey, id, val), 
							subst(t->branch(1), propkey, id, val), 
							subst(t->branch(2), propkey, id, val)); 
				break;
				
			case 4 : 
				r = tree(t->node(), 
							subst(t->branch(0), propkey, id, val), 
							subst(t->branch(1), propkey, id, val), 
							subst(t->branch(2), propkey, id, val), 
							subst(t->branch(3), propkey, id, val)); 
				break;
			
		}
		if (r == t) {
			setProperty(t, propkey, nil);
		} else {
			setProperty(t, propkey, r);
		}
		return r;
	}
		
}
开发者ID:gauravchawla03,项目名称:Stanford,代码行数:51,代码来源:list.cpp


示例11: getProperty

bool getProperty (Tree t, Tree key, Tree& val)
{
	CTree* pl = t->attribut();
	if (pl) return findKey(pl, key, val);
	else 	return false;
}
开发者ID:gauravchawla03,项目名称:Stanford,代码行数:6,代码来源:list.cpp


示例12: remProperty

void remProperty (Tree t, Tree key)
{
	CTree* pl = t->attribut();
	if (pl) t->attribut(removeKey(pl, key));
}
开发者ID:gauravchawla03,项目名称:Stanford,代码行数:5,代码来源:list.cpp


示例13: main

int main()
{
	Tree tree;
	tree.insert("yiyuan",new HosPartNode(1,"yiyuan"));

	tree.insert("yiyuan",new HosPartNode(10,"louceng"));

	tree.insert("louceng",new HosPartNode(1,"zhongyangdating"));
	tree.insert("louceng",new HosPartNode(4,"peilou"));

	tree.insert("zhongyangdating",new HosPartNode(1,"TV"));
	tree.insert("zhongyangdating",new HosPartNode(2,"sofa"));

	tree.insert("peilou",new HosPartNode(2,"changzoulang"));
	tree.insert("peilou",new HosPartNode(1,"zoulanglianjie"));

	tree.insert("changzoulang",new HosPartNode(21,"bingfang"));

	tree.insert("zoulanglianjie",new HosPartNode(5,"kufang"));

	tree.insert("bingfang",new HosPartNode(1,"washroom"));
	tree.insert("bingfang",new HosPartNode(4,"chazuo"));
	tree.insert("bingfang",new HosPartNode(2,"bingchuang"));

	tree.insert("washroom",new HosPartNode(1,"ximianpen"));
	tree.insert("washroom",new HosPartNode(1,"zuobianqi"));

	tree.insert("chazuo",new HosPartNode(2,"chakou"));
	tree.insert("chazuo",new HosPartNode(1,"mianban"));

//	tree.getParent(tree.Find("bingfang"))->print();
//	tree.Find("bingfang")->print();
//	cout<<endl;
	tree.WithTraverse(tree.getRoot());
	cout<<endl;
	cout<<"每个楼层中病房的数量为 : "<<tree.count("louceng","bingfang")<<endl;
	return 0;
}
开发者ID:cxy229,项目名称:dshomework,代码行数:38,代码来源:dshw3_4_2.cpp


示例14: tagsOpen

QString Parse::getTypeOfToken(const QString &ident, const QString &className,
                              Scope * scope, bool token_is_function)
{
	/* if we have a variable and already found a local definition, just return it after duplicating */
	if (!token_is_function && scope->localdef.length())
		return scope->localdef;

	/* if the identifier is this-> return the current class */
	if (ident == "this")
		return scope->scope;

	Tree *tree = NULL;
	if (className.length())
	{
		tree = Tree::buildInheritanceTree(className);
		if (!tree)
			return NULL;
	}

	tagFileInfo info;
	tagEntry entry;
	tagFile *tfile = tagsOpen(tagsFilePath.toAscii(), &info);
	if (tfile && info.status.opened)
	{
		if (tagsFind(tfile, &entry, ident.toAscii(), TAG_OBSERVECASE | TAG_FULLMATCH) ==
		        TagSuccess)
		{
			do
			{
				if (tree && !tree->isMemberOfScope(&entry, scope))
					continue;

				const char *kind = tagsField(&entry, "kind");
				if (token_is_function)	/* only list if tag is a function */
				{
					if (!kind
					        || (strcmp(kind, "function") && strcmp(kind, "prototype")))
						continue;
				}
				else		/* or a variable */
				{
					//brc: add externvar for extern variables like cout
					if (!kind
					        || (strcmp(kind, "variable") && strcmp(kind, "externvar")
					            //brc: namespace workarround: add namespace
					            && strcmp(kind, "namespace") && strcmp(kind, "member")))
						continue;
				}

				/* need to duplicate the pattern, don't ask me why */
				QString type = extractTypeQualifier(entry.address.pattern, ident);
				if(tree)
					tree->freeTree();
				tagsClose(tfile);
				return type;
			}
			while (tagsFindNext(tfile, &entry) == TagSuccess);
		}
		tagsClose(tfile);
	}
	return NULL;
}
开发者ID:pasnox,项目名称:monkeystudio1,代码行数:62,代码来源:parse.cpp


示例15: TreeCtrlEntry

/*************************************************************************
    Sample specific initialisation goes here.
*************************************************************************/
bool TreeDemoSample::initialiseSample()
   {
   using namespace CEGUI;
   Tree *      theTree;
   TreeItem *  newTreeCtrlEntryLvl1;  // Level 1 TreeCtrlEntry (branch)
   TreeItem *  newTreeCtrlEntryLvl2;  // Level 2 TreeCtrlEntry (branch)
   TreeItem *  newTreeCtrlEntryLvl3;  // Level 3 TreeCtrlEntry (branch)
   TreeItem *  newTreeCtrlEntryParent;
   Image *     iconArray[9];

#if defined( __WIN32__ ) || defined( _WIN32 )
   // Windows specific code.
   srand(time(NULL));
#endif

   // Get window manager which we will use for a few jobs here.
   WindowManager& winMgr = WindowManager::getSingleton();

//   CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Standard);
//   CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);
   CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Insane);

   // Load the scheme to initialise the skin which we use in this sample
   SchemeManager::getSingleton().create(SCHEME_FILE_NAME);

   // set default mouse image
   System::getSingleton().setDefaultMouseCursor(IMAGES_FILE_NAME, "MouseArrow");

   // load an image to use as a background
   ImagesetManager::getSingleton().createFromImageFile("BackgroundImage", "GPN-2000-001437.tga");

   // Load some icon images for our test tree
  // Imageset *iconImages = ImagesetManager::getSingleton().create("TreeIcons.imageset");
   Imageset& drives = ImagesetManager::getSingleton().create("DriveIcons.imageset");

   // here we will use a StaticImage as the root, then we can use it to place a background image
   Window* background = winMgr.createWindow(STATICIMAGE_NAME);

   // set area rectangle
   background->setArea(URect(cegui_reldim(0), cegui_reldim(0), cegui_reldim(1), cegui_reldim(1)));
   // disable frame and standard background
   background->setProperty("FrameEnabled", "false");
   background->setProperty("BackgroundEnabled", "false");
   // set the background image
   background->setProperty("Image", "set:BackgroundImage image:full_image");
   // install this as the root GUI sheet
   System::getSingleton().setGUISheet(background);

//   CEGUI::System::getSingleton().setTooltip(TOOLTIP_NAME);

    FontManager::getSingleton().create("DejaVuSans-10.font");
//	if(!FontManager::getSingleton().isFontPresent("Commonwealth-10"))
//		FontManager::getSingleton().createFont("Commonwealth-10.font");


   TreeDemoWindow = winMgr.loadWindowLayout(LAYOUT_FILE_NAME);

   background->addChildWindow(TreeDemoWindow);

   // listen for key presses on the root window.
   background->subscribeEvent(Window::EventKeyDown, Event::Subscriber(&TreeDemoSample::handleRootKeyDown, this));

   theTree = (Tree *)TreeDemoWindow->getChild(TreeID);
   theTree->initialise();
   theTree->subscribeEvent(Tree::EventSelectionChanged, Event::Subscriber(&TreeDemoSample::handleEventSelectionChanged, this));
   theTree->subscribeEvent(Tree::EventBranchOpened, Event::Subscriber(&TreeDemoSample::handleEventBranchOpened, this));
   theTree->subscribeEvent(Tree::EventBranchClosed, Event::Subscriber(&TreeDemoSample::handleEventBranchClosed, this));

   // activate the background window
   background->activate();

   Imageset& iconImages = drives;
   iconArray[0] = (Image *)&iconImages.getImage("Artic");
   iconArray[1] = (Image *)&iconImages.getImage("Black");
   iconArray[2] = (Image *)&iconImages.getImage("Sunset");
   iconArray[3] = (Image *)&iconImages.getImage("DriveStack");
   iconArray[4] = (Image *)&iconImages.getImage("GlobalDrive");
   iconArray[5] = (Image *)&iconImages.getImage("Blue");
   iconArray[6] = (Image *)&iconImages.getImage("Lime");
   iconArray[7] = (Image *)&iconImages.getImage("Silver");
   iconArray[8] = (Image *)&iconImages.getImage("GreenCandy");

   // Create a top-most TreeCtrlEntry
   newTreeCtrlEntryLvl1 = new TreeItem("Tree Item Level 1a");
   newTreeCtrlEntryLvl1->setIcon(drives.getImage("Black"));
   newTreeCtrlEntryLvl1->setSelectionBrushImage(IMAGES_FILE_NAME, BRUSH_NAME);
//   newTreeCtrlEntryLvl1->setUserData((void *)someData);
   theTree->addItem(newTreeCtrlEntryLvl1);
   // Create a second-level TreeCtrlEntry and attach it to the top-most TreeCtrlEntry
   newTreeCtrlEntryLvl2 = new TreeItem("Tree Item Level 2a (1a)");
   newTreeCtrlEntryLvl2->setIcon(drives.getImage("Artic"));
   newTreeCtrlEntryLvl2->setSelectionBrushImage(IMAGES_FILE_NAME, BRUSH_NAME);
   newTreeCtrlEntryLvl1->addItem(newTreeCtrlEntryLvl2);
   // Create a third-level TreeCtrlEntry and attach it to the above TreeCtrlEntry
   newTreeCtrlEntryLvl3 = new TreeItem("Tree Item Level 3a (2a)");
   newTreeCtrlEntryLvl3->setIcon(drives.getImage("Blue"));
   newTreeCtrlEntryLvl3->setSelectionBrushImage(IMAGES_FILE_NAME, BRUSH_NAME);
//.........这里部分代码省略.........
开发者ID:CharlesSadler,项目名称:CharlesSadlerRTSGame,代码行数:101,代码来源:Sample_TreeDemo.cpp


示例16: main

int main()
{
   Tree myTree;

 	bool inMenu = true;	// while the user is using the program this var is set to true and the menu keeps looping.
						// when the user wants to quit, it is set to false and the loop ends.
	char keyPressed;	// This var stores which menu selection the user picks.

	while ( inMenu )
	{
		cout<< endl << endl << endl;
		cout << "****************************************************" << endl;
		cout  <<"**  MENU:(press a character to select an option)  **" << endl;
 		cout << "****************************************************" << endl;
		cout<<"Q. [QUIT]     Quit."<<endl;
  		cout<<"D. [Display]  Display all values stored in the tree"<<endl;
 		cout<<"I. [Insert]   Insert an integer"<<endl;
		cout << endl;

		cout<<"M. [Maximum] Determine the maximum of all values stored in the tree" << endl;
		cout<<"A. [Average] Determine the average of all values stored in the tree" << endl;
		cout<<"H. [Height]  Determine the height of the tree" << endl;
		cout << "****************************************************" <<endl<< endl;

		cout<<"Your choice is: ";
		cin >> keyPressed ;

		int value;
		switch(keyPressed)
		{
			case 'M': case 'm'://Maximum
				cout << "[Maximum]:" << endl;
				cout << "Maximum value stored is:" << myTree.FindMaximum() << endl;
				break;

			case 'A': case 'a'://Average
				cout << "[Average]:" << endl;
				cout << "Average of all values stored is:" << myTree.FindAverage() << endl;
				break;

			case 'H': case 'h'://height
				cout << "[Height]:" << endl;
				cout << "Height of the tree is:" << myTree.FindHeight()<< endl;
				break;


			case 'Q': case 'q'://Quit
				cout << "[QUIT]:" << endl;
				inMenu = false;
				break;

			case 'D': case 'd':
				cout << "[Display]:" << endl;
				myTree.Display();
				break;

			case 'I': case 'i':
				cout << "[insert]:" << endl;
				cout << "Value to insert:";
				cin >> value;
				myTree.Insert(value);
				break;

			default:
				cout << "[?? UNKNOWN COMMAND]:" << endl;
				// Unrecognized key, do nothing
				break;
		}


	} // End of while loop

	return 0;
}
开发者ID:RoyalSix,项目名称:binarysearchtree,代码行数:74,代码来源:main.cpp


示例17: ProgAlignSubFams


//.........这里部分代码省略.........
		if (L > uMaxL)
			uMaxL = L;
		}

	SetIter(1);
	g_bDiags.get() = g_bDiags1.get();
	SetSeqStats(uSeqCount, uMaxL, uTotL/uSeqCount);

	SetMuscleSeqVect(v);

	MSA::SetIdCount(uSeqCount);

// Initialize sequence ids.
// From this point on, ids must somehow propogate from here.
	for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
		v.SetSeqId(uSeqIndex, uSeqIndex);

	if (uSeqCount > 1)
		MHackStart(v);

	if (0 == uSeqCount)
		{
		msaOut.Clear();
		return;
		}

	if (1 == uSeqCount && ALPHA_Amino == Alpha)
		{
		const Seq &s = v.GetSeq(0);
		msaOut.FromSeq(s);
		return;
		}

	Tree GuideTree;
	TreeFromSeqVect(v, GuideTree, g_Cluster1.get(), g_Distance1.get(), g_Root1.get());
	SetMuscleTree(GuideTree);

	MSA msa;
	if (g_bLow.get())
		{
		ProgNode *ProgNodes = 0;
		ProgNodes = ProgressiveAlignE(v, GuideTree, msa);
		delete[] ProgNodes;
		}
	else
		ProgressiveAlign(v, GuideTree, msa);
	SetCurrentAlignment(msa);
	TreeFromMSA(msa, GuideTree, g_Cluster2.get(), g_Distance2.get(), g_Root2.get());
	SetMuscleTree(GuideTree);

	unsigned *SubFams = new unsigned[uSeqCount];
	unsigned uSubFamCount;
	SubFam(GuideTree, g_uMaxSubFamCount.get(), SubFams, &uSubFamCount);

	SetProgressDesc("Align node");
	const unsigned uNodeCount = 2*uSeqCount - 1;

	ProgNode *ProgNodes = new ProgNode[uNodeCount];
	bool *NodeIsSubFam = new bool[uNodeCount];
	bool *NodeInSubFam = new bool[uNodeCount];

	for (unsigned i = 0; i < uNodeCount; ++i)
		{
		NodeIsSubFam[i] = false;
		NodeInSubFam[i] = false;
		}
开发者ID:Wyss,项目名称:mauve-py,代码行数:67,代码来源:subfam.cpp


示例18: write_simple

void write_simple( std::ostream &out , Tree const& t , bool write_infix , SymbolMapper const& mapper )
{
    if( !t.empty() )
        write_simple_cursor( out , t.root() , write_infix , mapper );
}
开发者ID:Ambrosys,项目名称:gpcxx,代码行数:5,代码来源:simple.hpp


示例19: main

int main(int argc, char **argv)
{
#ifdef MOAB_HAVE_MPI
  int fail = MPI_Init(&argc, &argv);
  if (fail) return fail;
#else
  // silence the warning of parameters not used, in serial; there should be a smarter way :(
  argv[0]=argv[argc-argc];
#endif

  int npoints = 100, dim = 3;
  int dints = 1, dleafs = 1, ddeps = 1, csints = 0;
  
  ProgOptions po;
  po.addOpt<int>( "candidateplaneset,c", "Candidate plane set (0=SUBDIVISION,1=SUBDIV_SNAP,2=VERTEX_MEDIAN,3=VERTEX_SAMPLE", &csints);
  po.addOpt<int>( "ints,i", "Number of doublings of intervals on each side of scd mesh", &dints);
  po.addOpt<int>( "leaf,l", "Number of doublings of maximum number of elements per leaf", &dleafs);
  po.addOpt<int>( "max_depth,m", "Number of 5-intervals on maximum depth of tree", &ddeps);
  po.addOpt<int>( "npoints,n", "Number of query points", &npoints);
//  po.addOpt<void>( "print,p", "Print tree details", &print_tree);
  po.parseCommandLine(argc, argv);

  std::vector<int> ints, deps, leafs;
  ints.push_back(10);
  for (int i = 1; i < dints; i++) ints.push_back(2*ints[i-1]);
  deps.push_back(30);
  for (int i = 1; i < ddeps; i++) deps.push_back(deps[i-1]-5);
  leafs.push_back(6);
  for (int i = 1; i < dleafs; i++) leafs.push_back(2*leafs[i-1]);

  ErrorCode rval = MB_SUCCESS;
  std::cout << "Tree_type" << " "
            << "Elems_per_leaf" << " "
            << "Tree_depth" << " "
            << "Ints_per_side" << " "
            << "N_elements" << " "
            << "search_time" << " "
            << "perc_outside" << " "
            << "initTime" << " "
            << "nodesVisited" << " "
            << "leavesVisited" << " "
            << "numTraversals" << " "
            << "leafObjectTests" << std::endl;

// outermost iteration: # elements
  for (std::vector<int>::iterator int_it = ints.begin(); int_it != ints.end(); ++int_it) {
    Core mb;
    Range elems;
    rval = create_hex_mesh(mb, elems, *int_it, 3);
    if (MB_SUCCESS != rval) return rval;
    
      // iteration: tree depth
    for (std::vector<int>::iterator dep_it = deps.begin(); dep_it != deps.end(); ++dep_it) {
  
        // iteration: tree max elems/leaf
      for (std::vector<int>::iterator leafs_it = leafs.begin(); leafs_it != leafs.end(); ++leafs_it) {
  
          // iteration: tree type
        for (int tree_tp = 1; tree_tp < 2; tree_tp++) {
            // create tree
          Tree *tree;
          if (0 == tree_tp)
            tree = new BVHTree(&mb);
          else
            tree = new AdaptiveKDTree(&mb);

          std::ostringstream opts;
          opts << "MAX_DEPTH=" << *dep_it << ";MAX_PER_LEAF=" << *leafs_it;
          if (csints) {
            if (opts.str().length() > 0) 
              opts << ";";
            opts << "PLANE_SET=" << csints;
          }
          FileOptions fo(opts.str().c_str());
          rval = tree->parse_options(fo);
          if (MB_SUCCESS != rval) return rval;
          SpatialLocator sl(&mb, elems, tree);

            // call evaluation
          double cpu_time, perc_outside;
          rval = test_locator(sl, npoints, cpu_time, perc_outside);
          if (MB_SUCCESS != rval) return rval;

          std::cout << (tree_tp == 0 ? "BVH" : "KD") << " "
                    << *leafs_it << " "
                    << *dep_it << " "
                    << *int_it << " "
                    << (*int_it)*(*int_it)*(dim == 3 ? *int_it : 1) << " "
                    << cpu_time << " "
                    << perc_outside << " ";

          tree->tree_stats().output_all_stats();

        } // tree_tp

      } // max elems/leaf

    } // max depth

  } // # elements
//.........这里部分代码省略.........
开发者ID:obmun,项目名称:moab,代码行数:101,代码来源:tree_searching_perf.cpp


示例20: printWelcome

void  printWelcome(){
	Menu welcome("BLACK","BLUE","RED", 50,17,15,2);
		char ID[20];
		char passtemp[10];
		char idtemp[10];
		char subtemp;
		int password=0;
		
	
	COORD position;
	position.X=27;
	position.Y=5;


	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),position);
	cout << "Welcome To First Last Bank!";
	
	position.X+=3; position.Y+=4;
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),position);
	cout << "Enter ID: ";



	
 position.Y+=2;
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),position);
	cout << "Enter Password: ";

	position.X+=10;	 position.Y-=2;
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),position);
	

	
	
		for(int i=0; i<8; i++)
	{
	subtemp=getch();	

	if(i==0 && toupper(subtemp) >=65 && toupper(subtemp) <=90)
	{
		cout << (char)toupper(subtemp);
		idtemp[i]= (char)toupper(subtemp);
	}
	else if(i>=1 && subtemp>=48 && subtemp<=57)
	{
		idtemp[i] = subtemp;
		cout << subtemp;
	}
	else 
		i--;

	}
	idtemp[i]='\0';

	strcpy(ID,idtemp);
	



	::found = FBLTree.Find(ID);
	position.X+=6; position.Y+=2;
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),position);
	
	

	

	

	for( i=0; i<4; i++)
	{
	subtemp=getch();	
	if(subtemp>=48 && subtemp<=57)
	{
		passtemp[i] = subtemp;
		cout << "*";
	}
	else 
		i--;

	}
	
	password=atoi(passtemp);


	

	if(::found!=NULL && stricmp(::found->ID,ID)==0 && ::found->password==password)
	   {
		::counter=0;
		prin 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TreeItem类代码示例发布时间:2022-05-31
下一篇:
C++ Treap类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap