本文整理汇总了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;
}
示例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;
}