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


C++ NodeTree::getChildren方法代码示例

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


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

示例1:

std::vector<NodeTree<int>*>* GraphStructuredStack::getReachable(NodeTree<int>* start, int length) {
	std::vector<NodeTree<int>*>* reachableList = new std::vector<NodeTree<int>*>();
	std::queue<NodeTree<int>*> currentNodes;
	std::queue<NodeTree<int>*> nextNodes;
	currentNodes.push(start);
	for (int i = 0; i < length; i++) {
		while (!currentNodes.empty()) {
			NodeTree<int>* currentNode = currentNodes.front();
			currentNodes.pop();
			std::vector<NodeTree<int>*> children = currentNode->getChildren();
			//std::cout << currentNode->getData() << " has children ";
			for (std::vector<NodeTree<int>*>::size_type j = 0; j < children.size(); j++) {
				std::cout << children[j]->getData() << " ";
				nextNodes.push(children[j]);
			}
			std::cout << std::endl;
		}
		currentNodes = nextNodes;
		//No clear function, so go through and remove
		while(!nextNodes.empty())
			nextNodes.pop();
	}
	while (!currentNodes.empty()) {
		reachableList->push_back(currentNodes.front());
		//std::cout << currentNodes.front()->getData() << " is reachable from " << start->getData() << " by length " << length << std::endl;
		currentNodes.pop();
	}
	return reachableList;
}
开发者ID:jorendorff,项目名称:kraken,代码行数:29,代码来源:GraphStructuredStack.cpp

示例2: key

/*!
  Load the plugin options.
  \param server The server object to use.
 */
int
PluginsManager::loadOptions (Server *server)
{
  int ret = 0;
  string key ("server.plugins");

  NodeTree<string>* node = server->getNodeTree (key);

  if (node == NULL)
    return 0;

  list<NodeTree<string>*> *children = node->getChildren ();

  if (children == NULL)
    return 0;

  string namespaceKey ("namespace");
  string pluginKey ("plugin");
  string globalKey ("global");
  string enabledKey ("enabled");

  for (list<NodeTree<string>*>::iterator it = children->begin ();
          it != children->end ();
          it++)
    {
      NodeTree<string>* node = *it;

      string plugin;
      string namespaceName;
      bool global = false;
      bool enabled = false;

      if (node->getAttr (namespaceKey))
        namespaceName.assign (*node->getAttr (namespaceKey));

      if (node->getAttr (pluginKey))
        plugin.assign (*node->getAttr (pluginKey));

      if (node->getAttr (globalKey))
        global = stringcmpi (*node->getAttr (globalKey), "YES") == 0;

      if (node->getAttr (enabledKey))
        enabled = stringcmpi (*node->getAttr (enabledKey), "YES") == 0;

      if (plugin.length ())
        addPluginInfo (plugin, new PluginInfo (plugin, enabled, global));
      else
        {
          server->log (MYSERVER_LOG_MSG_WARNING,
                              _("Invalid plugin name in PLUGIN block."));
          ret = -1;
        }
    }

  return ret;
}
开发者ID:rupinder,项目名称:GNU-MyServer-GSoC,代码行数:60,代码来源:plugins_manager.cpp


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