您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ traverse函数代码示例

51自学网 2021-06-03 08:58:27
  C++
这篇教程C++ traverse函数代码示例写得很实用,希望能帮到您。

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

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

示例1: min

void LevelUpdater::operator()(osg::Node *node, osg::NodeVisitor *nv){        double currentStepTime = viewer.getFrameStamp()->getSimulationTime();        // compensate error arising from the osg::Viewer resetting its SimulationTime    if(currentStepTime - _previousStepTime < 0.0f)    {        Player::getInstance()->resetPosition();        ((LazyCameraManipulator *)viewer.getCameraManipulator())->resetCamera();                _previousStepTime = currentStepTime - 0.5;            }        int numSimulationSubSteps = _level->getPhysicsWorld()->stepSimulation(currentStepTime - _previousStepTime,                                         (int)((currentStepTime - _previousStepTime) * 60.0f) + 1);                                             ((LazyCameraManipulator *)viewer.getCameraManipulator())->setNumSimulationSubSteps(numSimulationSubSteps);           _previousStepTime = currentStepTime;        // player dies when falling too low    {        btVector3 position = Player::getInstance()->getController()->getGhostObject()->getWorldTransform().getOrigin();        int yBucketIndex = (int)(position.y() / 20.0f);            if(yBucketIndex >= _level->getDeadlyAltitudes().size())            yBucketIndex = _level->getDeadlyAltitudes().size() - 1;        float minimum = min(_level->getDeadlyAltitudes()[yBucketIndex],                             (_level->getDeadlyAltitudes())[yBucketIndex + 1]);        if(position.z() < (minimum - 5.0f))            _level->playerDied();    }        // fade out when level is finished    osg::Vec4 constantBlendColor = _blendColor->getConstantColor();    float alpha = constantBlendColor.a();        // player reached finish    {        osg::Vec3 position = Player::getInstance()->getPosition();        std::vector<osg::Vec3> finishs = _level->getFinishs();        for(size_t i = 0; i < finishs.size(); i++)        {            float maxDistance = 1.0f;            osg::Vec3 diff = position - finishs[i];                        if(diff.x() < maxDistance && diff.x() > -maxDistance &&                diff.y() < maxDistance * 3.0f && diff.y() > -maxDistance &&                diff.z() < maxDistance && diff.z() > -maxDistance)                {                    if(alpha == 1.0f)                    {                        alpha -= 0.01f;                        _level->getHeadUpDisplay()->stopTimer();                        viewer.getEventHandlers().remove(_level->getKeyboardHandler());                        ((LazyCameraManipulator *)viewer.getCameraManipulator())->fadeOut();                        Player::getInstance()->getPlayerState()->setRequestAccelerate(false);                        Player::getInstance()->getPlayerState()->setRequestDecelerate(true);                    }                                    }        }                if(alpha < 1.0f)        {            alpha -= 0.01f;            if(alpha <= 0.0f)            {                alpha = 0.0f;                                 _level->setReachedFinish(true);            }            constantBlendColor[3] = alpha;            _blendColor->setConstantColor(constantBlendColor);        }    }        traverse(node, nv);}
开发者ID:starjumper,项目名称:Starjumper,代码行数:82,


示例2: main

//BEGIN MAINint main (int argc, char *arg[]) {	char *userInput; //what the user types in		size_t buffer = 128; //sets buffer for getline()		char **tokens; //array of pointers to tokens of command typed	int numTokens; //the number of tokens in input command		tokens = (char **)malloc(sizeof(char *) * 128); //mallocs tokens with a max number of 128	//----------------------------------------------------------------------------------------------//BEGIN PROGRAM WHILE LOOP	while(1) { 			printf("COMMAND> "); //print prompt to user		userInput = (char *)malloc(sizeof(char) * 128); //malloc for userInput before tokenizing		getline(&userInput, &buffer, stdin);// get user input		userInput[strcspn(userInput, "/n")] = '/0'; //removes null character from end of user input			//---Tokenize the user input		char *point;		int count;		for(count = 0, point = strtok(userInput, " "); point != NULL; count++, point = strtok(NULL, " ")) {            tokens[count] = (char *)malloc(strlen(point) + 1);            strcpy(tokens[count], point);        } //END tokenizing loop        numTokens = count; //sets the number of token var equal to the number of actual tokens        	//---Check for output redirection and handle output if so        int outputFile, consoleOutput;        fflush(stdout); //clear stdout as a precaution        int i; //counter for output redirection loop        for(i = 0; i < numTokens; i++) {            if(strcmp(tokens[i], ">") == 0) {                //Output redirection                outputFile = open(tokens[i+1], O_WRONLY | O_CREAT | O_TRUNC, 0644);                consoleOutput = dup(STDOUT_FILENO); //Copy original STDOUT                if(outputFile) {                    dup2(outputFile, STDOUT_FILENO);                    close(outputFile);                }                break; //break out of output redirection loop            }        } //END output redirection for loop        	//---QUIT COMMAND - quit the program		if(strcmp(tokens[0], "quit") == 0) {			break;		}//END QUIT COMMAND			//---HELP COMMAND - print the help menu		else if(strcmp(tokens[0], "help") == 0) {			printf("/nWelcome to the floppy program!/n");			printf("Here is a list of commands supported.../n");			printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/n");			printf("help - prints the help menu (You just did this!)/n");			printf("	usage: 	help/n");			printf("~/n");			printf("fmount - mounts a floppy image/n");			printf("	usage:	fmount [floppyname]/n");			printf("~/n");			printf("fumount - unmounts the mounted floppy image/n");			printf("	usage:	fumount/n");			printf("~/n");			printf("structure - lists the stucture of the floppy/n");			printf("	usage:	structure/n");			printf("~/n");			printf("traverse - lists the content in the root directory/n");			printf("	usage:	traverse/n");			printf("~/n");			printf("traverse -l - with the -l flag, the traverse command outputs more detailed info/n");			printf("	usage:	traverse -l/n");			printf("~/n");			printf("showsector - show the content (in a hex dump) of the provided sector number/n");			printf("	usage:	showsector [sectornumber]/n");			printf("~/n");			printf("showfat - show the content of the FAT table (in a hex dump)/n");			printf("	usage: showfat/n");			printf("~/n");			printf(">>>THIS PROGRAM SUPPORTS OUTPUT REDIRECTION<<</n");			printf("/n");				}//END HELP COMMAND			//---FMOUNT COMMAND - mounts the floppy		else if(strcmp(tokens[0], "fmount") == 0) {						int mounted;						if(numTokens < 2) {				printf("ERROR: INCORRECT USAGE - see help menu/n");				continue;			}			else {				mount(tokens[1]);				mounted = checkMount();				if(mounted < 0) {					printf("ERROR: COULD NOT MOUNT FLOPPY/n");//.........这里部分代码省略.........
开发者ID:nickwhite917,项目名称:UDP-Client-Server-in-C,代码行数:101,


示例3: traverse

/* Procedure typeCheck performs type checking * by a postorder syntax tree traversal */voidAnalyze::typeCheck( TreeNode *syntaxTree ){    traverse( syntaxTree, nullProc, checkNode );}
开发者ID:leeminghao,项目名称:lj-compiler,代码行数:8,


示例4: pathname

 pathname(const Arena& arena) {traverse(arena);}  // Traverse ancestors
开发者ID:adam-dziedzic,项目名称:scidb,代码行数:1,


示例5: main

int main(){	int i,j,k;	int l,m,n,o,bc,flag=0,count1=0,x=0,count2=0,row=0,count3=0,col=0,col2=0,prevcount=0,count5=0,size1=2,size2=3;	int cancount=0,lk,lm,count11=0;		int arr1[3],arr2[3],arr3[3];	int ab,div1,div2,count10=0,initial=0,initial2=0,candicount=0,prevcount1=0;			for(i=1;i<=size;i++)	{		for(j=1;j<=size;j++)		{			headarray[i][j]=NULL;			}	}	scanf("%d",&size);	memset(check, 0, (sizeof check[0][0])*size*size);	memset(notin, 0, (sizeof notin[0][0])*size*size);	memset(see, 0, (sizeof see[0][0])*size*size);	// taking sudoku input		for(i=1;i<=(size*size);i++)	{		for(j=1;j<=(size*size);j++)		{			scanf("%d",&arr[i][j]);			if(arr[i][j]==0)			count++;		}	}			traverse();		            // updating missing no matrix	cross();	   	    	// crosshatching	candidatelist();		// preparing candidate list	rule1();			// rule1	while(1)	{		prevcount1=count;				    		rule1();		    	// rule1		rule2_box();			//rule2 for box		rule2_row();			// rule2 column		rule2_col();			// rule 2 for row		rule1();	    		// rule 1						rule3();			// rule 3		rule2_box();			//rule2 for box		rule2_row();					rule2_col();		    		rule4();			// rule 4		if(prevcount1==count)		break;				    		}		    		for(i=1;i<=size*size;i++)	{		for(j=1;j<=size*size;j++)		{			printf("%d ",arr[i][j]);		}		printf("/n");	}	return 0;}
开发者ID:akashmagnet,项目名称:Sudoku-solver,代码行数:73,


示例6: traverse

 void Node::animate() {   traverse("animate"); }
开发者ID:ospray,项目名称:OSPRay,代码行数:4,


示例7: sumRootToLeaf

    int sumRootToLeaf(TreeNode* root) {		return traverse(root, 0);    }
开发者ID:cenhao,项目名称:coding,代码行数:3,


示例8: begin

static Iter begin(Node *root) {    return Iter(traverse(root, [](int *_) ->void* { return new ValueContinue(nullptr, nullptr); }));}
开发者ID:GHScan,项目名称:DailyProjects,代码行数:3,


示例9: traverse

void VisitorGetTransformationNode::visit(TransformationNodeModel* transformationNode) {  if(m_foundNode == nullptr && transformationNode->getKey() == m_nodeToFind)    m_foundNode = transformationNode;  else    traverse(transformationNode);}
开发者ID:aplars,项目名称:spiral,代码行数:6,


示例10: traverse

Column_Space * Column_Space::col_space_at_index(int index){    Column_Space * col;      traverse(col, this, 0, index);    return col;}
开发者ID:azelick,项目名称:cs202p1-2,代码行数:6,


示例11: chdirec

static intchdirec(vnode_t *vp, int ischroot, int do_traverse){	int error;	vnode_t *oldvp;	proc_t *pp = curproc;	vnode_t **vpp;	refstr_t *cwd;	int newcwd = 1;	if (vp->v_type != VDIR) {		error = ENOTDIR;		goto bad;	}	if (error = VOP_ACCESS(vp, VEXEC, 0, CRED(), NULL))		goto bad;	/*	 * The VOP_ACCESS() may have covered 'vp' with a new filesystem,	 * if 'vp' is an autoFS vnode. Traverse the mountpoint so	 * that we don't end up with a covered current directory.	 */	if (vn_mountedvfs(vp) != NULL && do_traverse) {		if (error = traverse(&vp))			goto bad;	}	/*	 * Special chroot semantics: chroot is allowed if privileged	 * or if the target is really a loopback mount of the root (or	 * root of the zone) as determined by comparing dev and inode	 * numbers	 */	if (ischroot) {		struct vattr tattr;		struct vattr rattr;		vnode_t *zonevp = curproc->p_zone->zone_rootvp;		tattr.va_mask = AT_FSID|AT_NODEID;		if (error = VOP_GETATTR(vp, &tattr, 0, CRED(), NULL))			goto bad;		rattr.va_mask = AT_FSID|AT_NODEID;		if (error = VOP_GETATTR(zonevp, &rattr, 0, CRED(), NULL))			goto bad;		if ((tattr.va_fsid != rattr.va_fsid ||		    tattr.va_nodeid != rattr.va_nodeid) &&		    (error = secpolicy_chroot(CRED())) != 0)			goto bad;		vpp = &PTOU(pp)->u_rdir;	} else {		vpp = &PTOU(pp)->u_cdir;	}	if (audit_active)	/* update abs cwd/root path see c2audit.c */		audit_chdirec(vp, vpp);	mutex_enter(&pp->p_lock);	/*	 * This bit of logic prevents us from overwriting u_cwd if we are	 * changing to the same directory.  We set the cwd to NULL so that we	 * don't try to do the lookup on the next call to getcwd().	 */	if (!ischroot && *vpp != NULL && vp != NULL && VN_CMP(*vpp, vp))		newcwd = 0;	oldvp = *vpp;	*vpp = vp;	if ((cwd = PTOU(pp)->u_cwd) != NULL && newcwd)		PTOU(pp)->u_cwd = NULL;	mutex_exit(&pp->p_lock);	if (cwd && newcwd)		refstr_rele(cwd);	if (oldvp)		VN_RELE(oldvp);	return (0);bad:	VN_RELE(vp);	return (error);}
开发者ID:MatiasNAmendola,项目名称:AuroraUX-SunOS,代码行数:84,


示例12: traverse

void xml_compiler::url_loader::traverse(const extracted_ptree& pt) const {  for (const auto& it : pt) {    if (it.get_tag_name() != "vkopenurldef") {      if (!it.children_empty()) {        traverse(it.children_extracted_ptree());      }    } else {      std::shared_ptr<url> newurl(new url());      if (!newurl) continue;      // ----------------------------------------      bool error = false;      for (const auto& child : it.children_extracted_ptree()) {        if (child.get_tag_name() == "name") {          newurl->set_name(pqrs::string::remove_whitespaces_copy(child.get_data()));          if (!boost::starts_with(*(newurl->get_name()), "KeyCode::VK_OPEN_URL_")) {            error = true;            xml_compiler_.error_information_.set(boost::format("<name> within <vkopenurldef> must start with /"KeyCode::VK_OPEN_URL_/":/n/n<name>%1%</name>") %                                                 *(newurl->get_name()));          }        } else if (child.get_tag_name() == "url") {          newurl->set_url(boost::trim_copy(child.get_data()));          auto type = child.get_optional("<xmlattr>.type");          if (type) {            newurl->set_type(boost::trim_copy(*type));          }        } else if (child.get_tag_name() == "background") {          newurl->set_background(true);        }      }      if (error) {        continue;      }      // ----------------------------------------      // Validation      // name      if (!newurl->get_name()) {        xml_compiler_.error_information_.set(boost::format("No <name> within <%1%>.") %                                             it.get_tag_name());        continue;      }      if (newurl->get_name()->empty()) {        xml_compiler_.error_information_.set(boost::format("Empty <name> within <%1%>.") %                                             it.get_tag_name());        continue;      }      // url      if (!newurl->get_url()) {        xml_compiler_.error_information_.set(boost::format("No <url> within <%1%>.") %                                             it.get_tag_name());        continue;      }      if (newurl->get_url()->empty()) {        xml_compiler_.error_information_.set(boost::format("Empty <url> within <%1%>.") %                                             it.get_tag_name());        continue;      }      // ----------------------------------------      // register to symbol_map_.      if (!symbol_map_.get_optional(*(newurl->get_name()))) {        auto keycode = symbol_map_.add("KeyCode",                                       boost::replace_first_copy(*(newurl->get_name()), "KeyCode::", ""));        vk_open_url_map_[keycode] = newurl;      }    }  }}
开发者ID:LuizGsa21,项目名称:Karabiner,代码行数:78,


示例13: main

void main (){  int n = __VERIFIER_nondet_int();  node_t* head = init_nondet_ll(n);  traverse(head);}
开发者ID:QEuphemia,项目名称:sv-benchmarks,代码行数:6,


示例14: seq_read

/** *	seq_read -	->read() method for sequential files. *	@file: the file to read from *	@buf: the buffer to read to *	@size: the maximum number of bytes to read *	@ppos: the current position in the file * *	Ready-made ->f_op->read() */ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos){	struct seq_file *m = file->private_data;	size_t copied = 0;	loff_t pos;	size_t n;	void *p;	int err = 0;	mutex_lock(&m->lock);	/*	 * seq_file->op->..m_start/m_stop/m_next may do special actions	 * or optimisations based on the file->f_version, so we want to	 * pass the file->f_version to those methods.	 *	 * seq_file->version is just copy of f_version, and seq_file	 * methods can treat it simply as file version.	 * It is copied in first and copied out after all operations.	 * It is convenient to have it as  part of structure to avoid the	 * need of passing another argument to all the seq_file methods.	 */	m->version = file->f_version;	/* Don't assume *ppos is where we left it */	if (unlikely(*ppos != m->read_pos)) {		while ((err = traverse(m, *ppos)) == -EAGAIN)			;		if (err) {			/* With prejudice... */			m->read_pos = 0;			m->version = 0;			m->index = 0;			m->count = 0;			goto Done;		} else {			m->read_pos = *ppos;		}	}	/* grab buffer if we didn't have one */	if (!m->buf) {		m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);		if (!m->buf)			goto Enomem;	}	/* if not empty - flush it first */	if (m->count) {		n = min(m->count, size);		err = copy_to_user(buf, m->buf + m->from, n);		if (err)			goto Efault;		m->count -= n;		m->from += n;		size -= n;		buf += n;		copied += n;		if (!m->count)			m->index++;		if (!size)			goto Done;	}	/* we need at least one record in buffer */	pos = m->index;	p = m->op->start(m, &pos);	while (1) {		err = PTR_ERR(p);		if (!p || IS_ERR(p))			break;		err = m->op->show(m, p);		if (err < 0)			break;		if (unlikely(err))			m->count = 0;		if (unlikely(!m->count)) {			p = m->op->next(m, p, &pos);			m->index = pos;			continue;		}		if (m->count < m->size)			goto Fill;		m->op->stop(m, p);		kfree(m->buf);		m->count = 0;		m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);		if (!m->buf)			goto Enomem;		m->version = 0;		pos = m->index;		p = m->op->start(m, &pos);	}//.........这里部分代码省略.........
开发者ID:AmperificSuperKANG,项目名称:android_kernel_mako,代码行数:101,


示例15: apply

virtual void apply(osg::Geode &geode){    for (unsigned int i = 0; i < geode.getNumDrawables(); ++i)    {        tessellateDemoGeometry *geom = dynamic_cast<tessellateDemoGeometry*>(geode.getDrawable(i));        if (geom)        {            if (!geom->getBoundaryOnly())       // turn on bounds only            {       // NB this shows only the true boundary of the curves, no internal edges                geom->setBoundaryOnly(true);            }            else         // change to next type of tessellation...            {                geom->setBoundaryOnly(false);                switch (geom->getWindingType())                {                case         osgUtil::Tessellator::TESS_WINDING_ODD:                    geom->setWindingType(osgUtil::Tessellator::TESS_WINDING_NONZERO);                    break;                case    osgUtil::Tessellator::TESS_WINDING_NONZERO:                    geom->setWindingType(osgUtil::Tessellator::TESS_WINDING_POSITIVE);                    break;                case    osgUtil::Tessellator::TESS_WINDING_POSITIVE:                    geom->setWindingType(osgUtil::Tessellator::TESS_WINDING_NEGATIVE);                    break;                case    osgUtil::Tessellator::TESS_WINDING_NEGATIVE:                    geom->setWindingType(osgUtil::Tessellator::TESS_WINDING_ABS_GEQ_TWO);                    break;                case    osgUtil::Tessellator::TESS_WINDING_ABS_GEQ_TWO:                    geom->setWindingType(osgUtil::Tessellator::TESS_WINDING_ODD);                    break;                }            }            switch (geom->getWindingType())       // a text to be added to the scene.            {            case         osgUtil::Tessellator::TESS_WINDING_ODD:                str = "TESS_WINDING_ODD";                break;            case    osgUtil::Tessellator::TESS_WINDING_NONZERO:                str = "TESS_WINDING_NONZERO";                break;            case    osgUtil::Tessellator::TESS_WINDING_POSITIVE:                str = "TESS_WINDING_POSITIVE";                break;            case    osgUtil::Tessellator::TESS_WINDING_NEGATIVE:                str = "TESS_WINDING_NEGATIVE";                break;            case    osgUtil::Tessellator::TESS_WINDING_ABS_GEQ_TWO:                str = "TESS_WINDING_ABS_GEQ_TWO";                break;            }            if (geom->getBoundaryOnly())                str += " Boundary";            geom->retessellatePolygons(*geom);        }        osgText::Text *txt = dynamic_cast<osgText::Text*>(geode.getDrawable(i));        if (txt)        {            const osg::Vec4 &ct = txt->getColor();    // pick the text to be changed by its color            if (ct.z() < 0.9)            {                txt->setText(str.c_str());            }        }    }    traverse(geode);}
开发者ID:hyyh619,项目名称:OpenSceneGraph-3.4.0,代码行数:81,


示例16: zfsctl_snapdir_lookup

/* ARGSUSED */static intzfsctl_snapdir_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, pathname_t *pnp,    int flags, vnode_t *rdir, cred_t *cr, caller_context_t *ct,    int *direntflags, pathname_t *realpnp){	zfsctl_snapdir_t *sdp = dvp->v_data;	objset_t *snap;	char snapname[MAXNAMELEN];	char real[MAXNAMELEN];	char *mountpoint;	zfs_snapentry_t *sep, search;	struct mounta margs;	vfs_t *vfsp;	size_t mountpoint_len;	avl_index_t where;	zfsvfs_t *zfsvfs = dvp->v_vfsp->vfs_data;	int err;	/*	 * No extended attributes allowed under .zfs	 */	if (flags & LOOKUP_XATTR)		return (EINVAL);	ASSERT(dvp->v_type == VDIR);	/*	 * If we get a recursive call, that means we got called	 * from the domount() code while it was trying to look up the	 * spec (which looks like a local path for zfs).  We need to	 * add some flag to domount() to tell it not to do this lookup.	 */	if (MUTEX_HELD(&sdp->sd_lock))		return (ENOENT);	ZFS_ENTER(zfsvfs);	if (gfs_lookup_dot(vpp, dvp, zfsvfs->z_ctldir, nm) == 0) {		ZFS_EXIT(zfsvfs);		return (0);	}	if (flags & FIGNORECASE) {		boolean_t conflict = B_FALSE;		err = dmu_snapshot_realname(zfsvfs->z_os, nm, real,		    MAXNAMELEN, &conflict);		if (err == 0) {			nm = real;		} else if (err != ENOTSUP) {			ZFS_EXIT(zfsvfs);			return (err);		}		if (realpnp)			(void) strlcpy(realpnp->pn_buf, nm,			    realpnp->pn_bufsize);		if (conflict && direntflags)			*direntflags = ED_CASE_CONFLICT;	}	mutex_enter(&sdp->sd_lock);	search.se_name = (char *)nm;	if ((sep = avl_find(&sdp->sd_snaps, &search, &where)) != NULL) {		*vpp = sep->se_root;		if (VN_HOLD(*vpp) == NULL) {			*vpp = NULL;			err = EAGAIN;		} else {			err = traverse(vpp);			if (err) {				VN_RELE(*vpp);				*vpp = NULL;			} else if (*vpp == sep->se_root) {				/*				 * The snapshot was unmounted behind our backs,				 * try to remount it.				 */				goto domount;			} else {				/*				 * VROOT was set during the traverse call.  We need				 * to clear it since we're pretending to be part				 * of our parent's vfs.				 */				(*vpp)->v_flag &= ~VROOT;			}		}		mutex_exit(&sdp->sd_lock);		ZFS_EXIT(zfsvfs);		return (err);	}	/*	 * The requested snapshot is not currently mounted, look it up.	 */	err = zfsctl_snapshot_zname(dvp, nm, MAXNAMELEN, snapname);	if (err) {		mutex_exit(&sdp->sd_lock);		ZFS_EXIT(zfsvfs);//.........这里部分代码省略.........
开发者ID:glycerine,项目名称:zfs,代码行数:101,


示例17: main

//.........这里部分代码省略.........  if( argc == 2)    get_num_blocks(argv[1]);  else    exit(EXIT_FAILURE);  /* Initialize the graph and cycles arrays */  /* The graph array is an incidence matrix */  /* if graph(i,j) is true, then there is a */  /* directed edge from i -> j              */  for( i = 0; i < SIZE; ++i )    {      for( j = 0; j < SIZE; ++j )	{	  graph[i][j] = NO_CONN;	}    }    /* Get the input blocks */  for( i = 0; i < num_blocks; ++i )    {      /* for each block... */      if( get_block( &block ) > 2 )	{	  /* if the block has more than 2 '00' terms then just skip it */	  /* if the block has 3 or 4 sides with '00' terms then it     */	  /* cannot connect to anything so it doesn't matter           */	  continue;	}      /* else // block has less than 2 zeros                           */      /* if a block matches itself, then the structure is unbounded    */      /* We wouldn't have to do this, but it is a simple enough check  */      /* and as n -> 40,000 it can save a lot of time                  */      for( k = 0; k < 4; ++k )	{	  for( j = 0; j < 4; ++j )	    {	      if( block[k*2] == block[j*2] && block[k*2+1] != block[j*2+1] )		  goto unbounded;	    }	}      /* else // block does not match itself */      /* add links to the graph              */      for( j = 0; j < 4; ++j )	{	  /* For each side... */	  /* assume correct formatting so only need to test first block for if 0 */	  if( block[j*2] == '0' )	    {	      /* no links can be added */	      continue;	    }	  else	    {	      for( k = 0; k < 4; ++k )		{		  /* for every other side on the block... */		  if( j == k ) /* same side we are already on, so continue */		    continue;		  else if( block[k*2] == '0' ) /* side is 00 so continue */		    continue;		  /* else add link */		  /* The basic idea for the links is, add a directed edge */		  /* between the opposite of that side (i.d. opposite of  */		  /* P- is P+) to each of the other sides on the block.   */		  /* This is because if you can connect to the current    */		  /* side of the block (i.d. block[j*2]) then you will    */		  /* connect with the opposite of this block, and it will */		  /* connect you to any of the other sides of the current */		  /* block.                                               */		  /* The problem is actually pretty nice since you can    */		  /* rotate and reflect, the geometry of the block doesnt */		  /* actually matter.                                     */		  if( block[j*2+1] == '+' )		    graph[ NEGATIVE( block[j*2] ) ][ to_index( &block[k*2] ) ] = 1;		  /* else the block is negative */		  else		    graph[ POSITIVE( block[j*2] ) ][ to_index( &block[k*2] ) ] = 1;		}	    }	}      /* turn on __DEBUG__ if you want to see the graph */      print_graph();    }  /* graph is all set up, just check for cycles */  if( traverse() )    goto unbounded; /* U mad bro? */  /* if we made it here then it is a bounded structure */      printf("bounded/n");      exit(EXIT_SUCCESS);    unbounded:      printf("unbounded/n");      exit(EXIT_SUCCESS);} /**~ end main ~**/
开发者ID:selavy,项目名称:ACMpractice,代码行数:101,


示例18: traverse

void QueapTree<T>::traverseTree(){	traverse(root_, &QueapTree<T>::displayNode);}
开发者ID:sarahshekeran,项目名称:Queap-,代码行数:4,


示例19: levelOrderBottom

 vector<vector<int> > levelOrderBottom(TreeNode *root) {     vector<vector<int>> result;     traverse(root, 1, result);     std::reverse(result.begin(), result.end());     return result; }
开发者ID:Leetcode-W010,项目名称:Answers,代码行数:6,


示例20: tdb_traverse

int64_t tdb_traverse(struct tdb_context *tdb, tdb_traverse_func fn, void *p){	return traverse(tdb, F_WRLCK, fn, p);}
开发者ID:stewartsmith,项目名称:ccan,代码行数:4,


示例21: apply

 virtual void apply(osg::Node& node) {     apply(node.getStateSet());     traverse(node); }
开发者ID:151706061,项目名称:OpenSceneGraph,代码行数:5,


示例22: traverse

QList<KBookmark> KBookmarkGroupList::getList( const KBookmarkGroup &grp ) {    traverse(grp);    return m_list;}
开发者ID:vishesh,项目名称:kde-baseapps,代码行数:4,


示例23: ls_main

//.........这里部分代码省略.........		case 's':			f_size = 1;			break;		case 'T':			f_sectime = 1;			break;		case 't':			sortkey = BY_TIME;			break;		default:			usage();		}	}	argc -= optind;	argv += optind;	/*	 * If both -g and -l options, let -l take precedence.	 * This preserves compatibility with the historic BSD ls -lg.	 */	if (f_grouponly == -1)		f_grouponly = 0;	/*	 * If not -F, -i, -l, -p, -S, -s or -t options, don't require stat	 * information.	 */	if (!f_longform && !f_inode && !f_size && !f_type && !f_typedir &&	    sortkey == BY_NAME)		fts_options |= FTS_NOSTAT;	/*	 * If not -F, -d or -l options, follow any symbolic links listed on	 * the command line.	 */	if (!f_longform && !f_listdir && !f_type)		fts_options |= FTS_COMFOLLOW;	/* If -l or -s, figure out block size. */	if (f_longform || f_size) {		if (!kflag)			(void)getbsize(&notused, &blocksize);		blocksize /= 512;	}	/* Select a sort function. */	if (f_reversesort) {		switch (sortkey) {		case BY_NAME:			sortfcn = revnamecmp;			break;		case BY_SIZE:			sortfcn = revsizecmp;			break;		case BY_TIME:			if (f_accesstime)				sortfcn = revacccmp;			else if (f_statustime)				sortfcn = revstatcmp;			else /* Use modification time. */				sortfcn = revmodcmp;			break;		}	} else {		switch (sortkey) {		case BY_NAME:			sortfcn = namecmp;			break;		case BY_SIZE:			sortfcn = sizecmp;			break;		case BY_TIME:			if (f_accesstime)				sortfcn = acccmp;			else if (f_statustime)				sortfcn = statcmp;			else /* Use modification time. */				sortfcn = modcmp;			break;		}	}	/* Select a print function. */	if (f_singlecol)		printfcn = printscol;	else if (f_columnacross)		printfcn = printacol;	else if (f_longform)		printfcn = printlong;	else if (f_stream)		printfcn = printstream;	else		printfcn = printcol;	if (argc)		traverse(argc, argv, fts_options);	else		traverse(1, dotav, fts_options);	return (rval);}
开发者ID:aibrahim,项目名称:OpenBSD-src,代码行数:101,


示例24: main

int main() {int ar[11] = {14,4,3,9,7,5,15,18,16,17,30};node* root = NULL;stack<node*> *st_primary = new stack<node*>();stack<node*> *st_secondry = new stack<node*>();for (int i = 0; i < 11;i++) {	if (root == NULL) {		root = new node(ar[i]);		st_primary->push(root);		continue;	}	node * mainelem = st_primary->pop();	while (mainelem->data > ar[i]) {		st_secondry->push(mainelem);		if (st_primary->size() > 0) {			mainelem = st_primary->pop();		} else if (st_primary->size() == 0) {			mainelem = st_secondry->pop();			break;		}	}	if (mainelem->data > ar[i]) {		if (mainelem->left == NULL) {			node * n1 = new node(ar[i]);			mainelem->left = n1;			st_primary->push(n1);			st_primary->push(mainelem);			copystack(st_secondry,st_primary);				} else if (mainelem->left != NULL) {			st_primary->push(mainelem);			mainelem = st_secondry->pop();			node * n1 = new node(ar[i]);			if (mainelem->data > ar[i] ) {				if (mainelem->left != NULL) {					printf("/n ----logic break 11 left--/n");fflush(stdout);				} else {					mainelem->left = n1;					st_primary->push(n1);					st_primary->push(mainelem);					copystack(st_secondry, st_primary);									}					} else if (mainelem->data < ar[i]) {				if (mainelem->right != NULL) {					printf("/n ----logic break 11 rpte --/n");fflush(stdout);				} else {					mainelem->right = n1;					st_primary->push(mainelem);					st_primary->push(n1);					copystack(st_secondry, st_primary);				}			}		}	} else 	if (mainelem->data < ar[i]) {			if (mainelem->right == NULL) {				node * n1 = new node(ar[i]);				mainelem->right = n1;				st_primary->push(mainelem);				st_primary->push(n1);				copystack(st_secondry,st_primary);			} else if (mainelem->right != NULL) {				st_primary->push(mainelem);				mainelem = st_secondry->pop();				node *n1 = new node(ar[i]);				if (mainelem->data > ar[i]) {					if (mainelem->left != NULL) {						printf("/n ------loginc brealk lpointer /n");fflush(stdout);					} else {						mainelem->left = n1;						st_primary->push(n1);						st_primary->push(mainelem);						copystack(st_secondry, st_primary);					}									} else if (mainelem->data < ar[i]) {					if (mainelem->right != NULL) {						printf("/n --------logic break rpointer /n");fflush(stdout);					} else {						mainelem->right = n1;						st_primary->push(mainelem);						st_primary->push(n1);						copystack(st_secondry, st_primary);					} 				}			}	}} //for	traverse(root);}
开发者ID:mikedasuya,项目名称:ds,代码行数:94,


示例25: main

intmain(int argc, char *argv[]){	size_t path_len, total_files;	off_t bytes_wasted, total_wasted;	char path_buffer[PATH_MAX_LEN], *hash_value;	struct file_entry_t *file_entry, *trie_entry;	SListIterator slist_iterator;	SetIterator set_iterator;	/* Step 0: Session data */	struct file_info_t file_info;	clear_info(&file_info);	/* Step 1: Parse arguments */	while (--argc) {		/* Being unable to record implies insufficient resources */		if (!record(argv[argc], &file_info)){			fprintf(stderr, "[FATAL] out of memory/n");			destroy_info(&file_info);			return (EXIT_FAILURE);		}	}	/* Step 2: Fully explore any directories specified */	#ifndef NDEBUG	printf("[DEBUG] Creating file list.../n");	#endif	while (slist_length(file_info.file_stack) > 0) {		/* Pick off the top of the file stack */		file_entry = (struct file_entry_t *)(slist_data(file_info.file_stack));		slist_remove_entry(&file_info.file_stack, file_info.file_stack);		assert(file_entry->type == DIRECTORY);		/* Copy the basename to a buffer */		memset(path_buffer, '/0', PATH_MAX_LEN);		path_len = strnlen(file_entry->path, PATH_MAX_LEN);		memcpy(path_buffer, file_entry->path, path_len);		/* Ignore cases that would cause overflow */		if (path_len < PATH_MAX_LEN) {			/* Append a trailing slash */			path_buffer[path_len] = '/';			/* Record all contents (may push onto file stack or one of the lists) */			DIR *directory = opendir(file_entry->path);			if (traverse(&file_info, directory, path_buffer, ++path_len)) {				fprintf(stderr, "[FATAL] out of memory/n");				destroy_info(&file_info);				return (EXIT_FAILURE);			} else if (closedir(directory)) {				fprintf(stderr, "[WARNING] '%s' (close failed)/n", file_entry->path);			}		}		/* Discard this entry */		destroy_entry(file_entry);	}	/* Step 3: Warn about any ignored files */	if (slist_length(file_info.bad_files) > 0) {		slist_iterate(&file_info.bad_files, &slist_iterator);		while (slist_iter_has_more(&slist_iterator)) {			file_entry = slist_iter_next(&slist_iterator);			fprintf(stderr, "[WARNING] '%s' ", file_entry->path);			switch (file_entry->type) {			case INVALID:				++file_info.invalid_files;				fprintf(stderr, "(invalid file)/n");				break;			case INACCESSIBLE:				++file_info.protected_files;				fprintf(stderr, "(protected file)/n");				break;			default:				++file_info.irregular_files;				fprintf(stderr, "(irregular file)/n");				break;			}		}		fprintf(stderr, "[WARNING] %lu file(s) ignored/n",			(long unsigned)(num_errors(&file_info)));	}	#ifndef NDEBUG	if (num_errors(&file_info) > 0) {		fprintf(stderr, "[FATAL] cannot parse entire file tree/n");		destroy_info(&file_info);		return (EXIT_FAILURE);	}	printf("[DEBUG] Found %lu / %lu valid files/n",		(unsigned long)(num_files(&file_info)),		(unsigned long)(file_info.total_files));	#endif	/* Step 4: Begin the filtering process */	#ifndef NDEBUG	printf("[DEBUG] Creating file table.../n");	#endif	if (slist_length(file_info.good_files) > 0) {		file_info.hash_trie = trie_new();		file_info.shash_trie = trie_new();		optimize_filter(&file_info);		/* Extract each file from the list (they should all be regular) *///.........这里部分代码省略.........
开发者ID:hagemt,项目名称:bloom,代码行数:101,



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


C++ trayIconActivated函数代码示例
C++ traveller函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。