本文整理汇总了C++中NodePtr::Costs方法的典型用法代码示例。如果您正苦于以下问题:C++ NodePtr::Costs方法的具体用法?C++ NodePtr::Costs怎么用?C++ NodePtr::Costs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodePtr
的用法示例。
在下文中一共展示了NodePtr::Costs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildReply
void GCGV_ReqGetNodes::BuildReply() {
size_t pwdLen = parent->PWD().ToString().length() +1;
reply.StartArray("nodes");
for (SortedNodes::reverse_iterator it = sortedNodes.rbegin();
it != sortedNodes.rend();
++it)
{
NodePtr node = it->second;
long total = node->Costs()[0];
long average = double(total) / node->Calls();
std::string path =
GCGV_Callgraph::GetPath(node).ToString();
if (path.length() > pwdLen) {
path = path.c_str() + pwdLen;
}
reply.StartAnonymousObject();
reply.Add("path", path);
reply.Add("calls", node->Calls());
reply.Add("cost", total);
reply.Add("avCost", average);
reply.EndObject();
}
reply.EndArray();
}
示例2: switch
void GCGV_ReqGetNodes::SortedNodes::AddNode(NodePtr node, SORT_BY sort) {
long idx = 0;
switch (sort) {
case COST:
idx = node->Costs()[0];
break;
case AV_COST:
idx = node->Costs()[0] / node->Calls();
break;
default:
throw InvalidRequestException { 0, "Invalid Sort Type" };
}
insert(SortedNodes::value_type(idx, node));
}
示例3: AddNode
void GCGVCallgraph_ReqGraph::AddNode(NodePtr node, size_t node_depth) {
if (node_depth == request.Get<depth>()) {
// The top-level node lives in the top-level JSON, so does not need an
// object wrapper
} else {
builder.StartAnonymousObject();
}
builder.Add("name",node->Name());
if (node->Name().length() > 50) {
builder.Add("shortName",node->Name().substr(0,50));
} else {
builder.Add("shortName",node->Name());
}
builder.Add("cost",node->Costs()[0]);
if (node_depth>0 && node->NumChildren() > 0)
{
builder.StartArray("children");
node-> ForEach([&] (NodePtr child) -> void {
this->AddNode(child,node_depth-1);
});
builder.EndArray();
}
if (node_depth == request.Get<depth>()) {
// The top-level node lives in the top-level JSON, so does not need an
// object wrapper
} else {
builder.EndObject();
}
}