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


C++ tree::empty方法代码示例

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


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

示例1: areMirrored

bool areMirrored(tree<int> l, tree<int> r) {
  if (l.empty() && r.empty()) {
    return true;
  }
  if (l.empty() || r.empty()) {
    return false;
  }
  if (l.RootTree() != r.RootTree()) {
    return false;
  }

  return areMirrored(l.LeftTree(), r.RightTree())
      && areMirrored(l.RightTree(), r.LeftTree());
}
开发者ID:stefolog,项目名称:fmi-sdp2015,代码行数:14,代码来源:treeproblems.cpp

示例2: writeSiblingsXML

void writeSiblingsXML(const tree<AstNode>& t, const tree<AstNode>::iterator iRoot, ostream& stream)
{
	if(t.empty()) 
		return;
	if (iRoot->getType() == "root") {
		tree<AstNode>::sibling_iterator iChildren = t.begin(iRoot);
		stream << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" << endl;
		writeSiblingsXML(t,iChildren,stream);
	}
	else if (t.number_of_children(iRoot) == 0) {
		string type = iRoot->getType();
		stream << "<php:" << type << '>';
		if (iRoot->getValue().length() > 0)
			stream << htmlentities(iRoot->getValue());
		stream << "</php:" << type << '>' << endl;
	}
	else {
		string type = iRoot->getType();
		string xmlns="";
		if (type == "start")
			xmlns = " xmlns:php=\"http://php.net/csl\"";
		stream << "<php:" << type << xmlns << '>' << endl;
		int siblingNum;
		tree<AstNode>::sibling_iterator iChildren;
		for (iChildren = t.begin(iRoot), siblingNum = 0; iChildren != t.end(iRoot); ++iChildren) 
		{
			writeSiblingsXML(t,iChildren,stream);
		}
		stream << "</php:" << type << '>' << endl;
	}
}
开发者ID:laiello,项目名称:php-oracle,代码行数:31,代码来源:AstContainer.cpp

示例3: AddItem

FILE_ITEM CFileTree::AddItem(char *absolutePath, unsigned char* handle)
{
	FILE_ITEM item;
	item.handle = handle;
	item.bCached = false;

	if (filesTree.empty()) {
		item.path = new char[strlen(absolutePath) + 1];
		strcpy_s(item.path, (strlen(absolutePath) + 1), absolutePath);
		item.nPathLen = strlen(item.path);

		filesTree.set_head(item);
		topNode = filesTree.begin();
	}
	else {
		std::string sPath(absolutePath);
		tree_node_<FILE_ITEM>* parentNode = findParentNodeFromRootForPath(absolutePath);
		std::string splittedPath = sPath.substr(sPath.find_last_of('\\') + 1);
		item.path = new char[splittedPath.length() + 1];
		strcpy_s(item.path, (splittedPath.length() + 1), splittedPath.c_str());
		if (parentNode) {
			filesTree.append_child(tree<FILE_ITEM>::iterator_base(parentNode), item);
		} else {
			//printf("Parent node found for %s", absolutePath);
		}
	}

	DisplayTree(topNode.node, 0);

	return item;
}
开发者ID:CandoImage,项目名称:winnfsd,代码行数:31,代码来源:FileTree.cpp

示例4: sum

int sum(tree<int> & t, tree<char>&op){
int s = 0;
if (t.empty() && op.empty()) return s;

tree<int>left = t.leftTree();
tree<int>right = t.rightTree();

int sumLeft = sum(t.leftTree(), op.leftTree());
int sumrRight = sum(t.rightTree(), op.rightTree());

int result = 0;
char operation = op.rootTree();
switch (operation){
	//...
}

}
开发者ID:stefolog,项目名称:fmi-sdp2015-test2,代码行数:17,代码来源:fn81231_zad1(1).cpp

示例5: topsCount

int topsCount(tree<int>& t)
{
	if (t.empty()) return 0;                                                  // prazno
	else if (t.LeftTree().empty() && t.RightTree().empty()) return 1;         // listo					// nenujno
	else if (t.LeftTree().empty()) return  1 + topsCount(t.RightTree());      // ima dqsno			// nenujno
	else if (t.RightTree().empty()) return  1 + topsCount(t.LeftTree());      // ima lqvo				// nenujno
	else return 1 + topsCount(t.LeftTree()) + topsCount(t.RightTree());       // ima i lqvo i dqsno

}
开发者ID:stefolog,项目名称:fmi-sdp2015-test2,代码行数:9,代码来源:zad2_fn81198.cpp

示例6: treeHeight

int treeHeight(tree<int> t) {
  if (t.empty()) {
    return 0;
  }

  int leftTreeHeight = treeHeight(t.LeftTree());
  int rightTreeHeight = treeHeight(t.RightTree());

  return 1 + max(leftTreeHeight, rightTreeHeight);
}
开发者ID:stefolog,项目名称:fmi-sdp2015,代码行数:10,代码来源:treeproblems.cpp

示例7: countEdges

int countEdges(tree<T> t)
{
	if (t.empty())
	{
		return 0;
	}
	else
	{
		return 1 + countEdges(t.leftTree()) + countEdges(t.rightTree());
	}
}
开发者ID:stefolog,项目名称:fmi-sdp2015-test2,代码行数:11,代码来源:zad2_fn81091.cpp

示例8: findSumHelper

int findSumHelper(tree<int> nums, tree<char> opers)
{
	if (nums.empty())
	{
		return 0;
	}
	else
	{
		switch (opers.getRoot()->inf)
		{
		case '+': return (nums.getRoot()->inf + countEdges(nums)) + findSumHelper(nums.rightTree(), opers.rightTree()) + findSumHelper(nums.leftTree(), opers.leftTree());
		case '-': return (nums.getRoot()->inf - countEdges(nums)) + findSumHelper(nums.rightTree(), opers.rightTree()) + findSumHelper(nums.leftTree(), opers.leftTree());
		case '*': return (nums.getRoot()->inf * countEdges(nums)) + findSumHelper(nums.rightTree(), opers.rightTree()) + findSumHelper(nums.leftTree(), opers.leftTree());
		default: return 0;
		}
	}
}
开发者ID:stefolog,项目名称:fmi-sdp2015-test2,代码行数:17,代码来源:zad2_fn81091.cpp

示例9: AddItem

FILE_ITEM CFileTree::AddItem(char *absolutePath, unsigned char* handle)
{
	FILE_ITEM item;
	item.handle = handle;
	item.bCached = false;

	// If the tree is empty just add the new path as node on the top level.
	if (filesTree.empty()) {
		item.path = new char[strlen(absolutePath) + 1];
		strcpy_s(item.path, (strlen(absolutePath) + 1), absolutePath);
		item.nPathLen = strlen(item.path);

		filesTree.set_head(item);
		topNode = filesTree.begin();
	}
	else {
		// Check if the requested path belongs to an already registered parent node.
		std::string sPath(absolutePath);
		tree_node_<FILE_ITEM>* parentNode = findParentNodeFromRootForPath(absolutePath);
		std::string splittedPath = _basename_932(sPath);
		//printf("spl %s %s\n", splittedPath.c_str(), absolutePath);
		item.path = new char[splittedPath.length() + 1];
		strcpy_s(item.path, (splittedPath.length() + 1), splittedPath.c_str());
		// If a parent was found use th parent.
		if (parentNode) {
			//printf("parent %s\n", parentNode->data.path);
			filesTree.append_child(tree<FILE_ITEM>::iterator_base(parentNode), item);
		} else {
			// Node wasn't found - most likely a new root - add it to the top level.
			//printf("No parent node found for %s. Adding new sibbling.", absolutePath);
			item.path = new char[strlen(absolutePath) + 1];
			strcpy_s(item.path, (strlen(absolutePath) + 1), absolutePath);
			item.nPathLen = strlen(item.path);
			
			filesTree.insert(tree<FILE_ITEM>::iterator_base(topNode), item);
			topNode = filesTree.begin();
		}
	}

	DisplayTree(topNode.node, 0);

	return item;
}
开发者ID:abymmathew,项目名称:winnfsd,代码行数:43,代码来源:FileTree.cpp

示例10: isMirrored

bool isMirrored(tree<int> t) {
  if (t.empty()) {
    return true;
  }
  return areMirrored(t.LeftTree(), t.RightTree());
}
开发者ID:stefolog,项目名称:fmi-sdp2015,代码行数:6,代码来源:treeproblems.cpp


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