本文整理汇总了C++中NodeIterator类的典型用法代码示例。如果您正苦于以下问题:C++ NodeIterator类的具体用法?C++ NodeIterator怎么用?C++ NodeIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NodeIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: n
//------------------------------------------------------------------------------
void TreeDrawer::CalcCoordinates ()
{
double l = t->GetNumLeaves();
leafGap = height / (l - 1.0);
if (rooted)
nodeGap = width / l;
else
nodeGap = width / (l - 1.0);
leafCount = 0;
if (rooted)
{
// Allow for edge below root
left += nodeGap;
width -= nodeGap;
}
NodeIterator <Node> n (t->GetRoot());
Node *q = n.begin();
while (q)
{
if (q->IsLeaf ())
{
CalcLeaf (q);
}
else
{
CalcInternal (q);
}
q = n.next();
}
}
示例2: QObject
WordGraph::WordGraph(const WordGraph &o)
: QObject(o.parent()), m_disabledNodes(o.m_disabledNodes), m_disabledEdges(o.m_disabledEdges),
m_centralNodeId(o.m_centralNodeId), m_signalsEnabled(false)
{
ConstNodeIterator nodeIterEnd = o.m_nodes.constEnd();
ConstNodeIterator nodeIter;
for (nodeIter = o.m_nodes.constBegin(); nodeIter != nodeIterEnd; ++nodeIter) {
m_nodes[nodeIter.key()] = nodeIter.value()->clone();
m_nodes[nodeIter.key()]->m_graph = this;
}
ConstEdgeIterator edgeIterEnd = o.m_edges.constEnd();
ConstEdgeIterator edgeIter;
for (edgeIter = o.m_edges.constBegin(); edgeIter != edgeIterEnd; ++edgeIter) {
Edge *cloneEdge = edgeIter.value()->clone();
cloneEdge->m_graph = this;
cloneEdge->m_source = m_nodes[cloneEdge->m_source->id()];
cloneEdge->m_dest = m_nodes[cloneEdge->m_dest->id()];
m_edges[edgeIter.key()] = cloneEdge;
}
// Replace each node edges with this graph edges.
NodeIterator myNodeIterEnd = m_nodes.end();
for (NodeIterator iter = m_nodes.begin(); iter != myNodeIterEnd; ++iter) {
QSet<Edge*> newEdges;
QSet<Edge*> curEdges = iter.value()->edges();
foreach (Edge *edge, curEdges)
newEdges << m_edges[edge->id()];
iter.value()->m_edges = newEdges;
}
}
示例3: jsNodeIteratorPointerBeforeReferenceNode
JSValue jsNodeIteratorPointerBeforeReferenceNode(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slot.slotBase()));
UNUSED_PARAM(exec);
NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
return jsBoolean(imp->pointerBeforeReferenceNode());
}
示例4: PullSend
void PullSend::Execute() {
if (_resched) {
Action* ps_event = new PullSend(_node, _sched, _net, _resched);
_sched.after(ps_rate, ps_event);
}
LitterNode& lnode = dynamic_cast<LitterNode&>(_node);
if (lnode.getOnline() == false) return;
int end = _sched.getCurrentTime();
int start = lnode.getLastPull();
lnode.setLastPull(_sched.getCurrentTime());
int delay = 0;
NodeIterator* ni = lnode.getNeighborIT();
while (ni->moveNext()) {
Node* neighbor = ni->current();
LitterNode& dest = dynamic_cast<LitterNode&>(*neighbor);
if (dest.getOnline() == true) {
Action* pr_event = new PullRcv(*neighbor, _node, _sched, _net, start,
end);
LitterNetwork& lnet = dynamic_cast<LitterNetwork&>(_net);
lnet.send(lnode, dest, *pr_event, _sched, delay++);
lnode.stats.pulltx++;
}
}
}
示例5: jsNodeIteratorReferenceNode
JSValue jsNodeIteratorReferenceNode(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slot.slotBase()));
UNUSED_PARAM(exec);
NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
return toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->referenceNode()));
}
示例6: GapRcv
void CheckGap::send(Node& node, int start, int end) {
LitterNode& lnode = dynamic_cast<LitterNode&>(_node);
LitterNode& dnode = dynamic_cast<LitterNode&>(node);
lnode.stats.gapfound++;
if (dnode.getOnline() == true) {
Action* pr_event = new GapRcv(node, _node, _sched, _net,
start, end, node);
LitterNetwork& lnet = dynamic_cast<LitterNetwork&>(_net);
lnet.send(lnode, dnode, *pr_event, _sched);
lnode.stats.gaptx++;
}
else {
NodeIterator* ni = lnode.getNeighborIT();
while (ni->moveNext()) {
Node* neighbor = ni->current();
LitterNode& dest = dynamic_cast<LitterNode&>(*neighbor);
if (dest.getOnline() == true) {
LitterNetwork& lnet = dynamic_cast<LitterNetwork&>(_net);
if ( lnet.isNeighbor(dnode, dest)) {
Action* pr_event = new GapRcv(*neighbor, _node, _sched, _net,
start, end, node);
lnet.send(lnode, dest, *pr_event, _sched);
lnode.stats.gaptx++;
break;
}
}
}
}
}
示例7: TEST
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mcarray_examples, mcarray_xyz)
{
// we are using one node to hold group of example mcarrays purely out of
// convenience
Node dsets;
index_t npts = 100;
blueprint::mcarray::examples::xyz("interleaved",
npts,
dsets["interleaved"]);
blueprint::mcarray::examples::xyz("separate",
npts,
dsets["separate"]);
blueprint::mcarray::examples::xyz("contiguous",
npts,
dsets["contiguous"]);
NodeIterator itr = dsets.children();
while(itr.has_next())
{
Node info;
Node &mcarray = itr.next();
std::string name = itr.name();
// TODO: tests!
}
}
示例8: throwError
JSValue* JSNodeIteratorPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
if (!thisObj->inherits(&JSNodeIterator::info))
return throwError(exec, TypeError);
NodeIterator* imp = static_cast<NodeIterator*>(static_cast<JSNodeIterator*>(thisObj)->impl());
switch (id) {
case JSNodeIterator::NextNodeFuncNum: {
ExceptionCode ec = 0;
KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->nextNode(ec)));
setDOMException(exec, ec);
return result;
}
case JSNodeIterator::PreviousNodeFuncNum: {
ExceptionCode ec = 0;
KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->previousNode(ec)));
setDOMException(exec, ec);
return result;
}
case JSNodeIterator::DetachFuncNum: {
imp->detach();
return jsUndefined();
}
}
return 0;
}
示例9:
Node *FEMesh::closestNode(const double x, const double y, const double z=0)
#endif
{
double min=1.; // (initial value provided to suppress compiler warnings)
Node *node, *thenode=0;
for(NodeIterator ni = node_iterator(); !ni.end(); ++ni) {
node = ni.node();
double dx = node->position()(0) - x;
double dy = node->position()(1) - y;
#if DIM==2
double dist = dx*dx + dy*dy;
#elif DIM==3
double dz = node->position()(2) - z;
double dist = dx*dx + dy*dy + dz*dz;
#endif
if (ni.begin()) {
min = dist;
thenode = node;
}
else {
if (dist <= min) {
min = dist;
thenode = node;
}
}
}
return thenode;
}
示例10: while
//------------------------------------------------------------------------------
void RectangleTreeDrawer::CalcCoordinates ()
{
t->MakeNodeList();
maxDepth = 0;
// Clear internal node depths
for (int i = t->GetNumLeaves(); i < t->GetNumNodes(); i++)
{
(*t)[i]->SetDepth(0);
}
for (int i = 0; i < t->GetNumLeaves(); i++)
{
NodePtr p = (*t)[i]->GetAnc();
int count = 1;
while (p)
{
if (count > p->GetDepth())
{
p->SetDepth(count);
if (count > maxDepth)
maxDepth = count;
}
count++;
p = p->GetAnc();
}
}
double l = t->GetNumLeaves();
leafGap = height / (l - 1.0);
l = maxDepth + 1.0;
if (rooted)
nodeGap = width / l;
else
nodeGap = width / (l - 1.0);
leafCount = 0;
if (rooted)
{
// Allow for edge below root
left += nodeGap;
width -= nodeGap;
}
NodeIterator <Node> n (t->GetRoot());
Node *q = n.begin();
while (q)
{
if (q->IsLeaf ())
{
CalcLeaf (q);
}
else
{
CalcInternal (q);
}
q = n.next();
}
}
示例11: jsNodeIteratorWhatToShow
JSValue jsNodeIteratorWhatToShow(ExecState* exec, JSValue slotBase, const Identifier&)
{
JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slotBase));
UNUSED_PARAM(exec);
NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
JSValue result = jsNumber(imp->whatToShow());
return result;
}
示例12: jsNodeIteratorReferenceNode
JSValue jsNodeIteratorReferenceNode(ExecState* exec, JSValue slotBase, const Identifier&)
{
JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slotBase));
UNUSED_PARAM(exec);
NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->referenceNode()));
return result;
}
示例13: jsNodeIteratorPointerBeforeReferenceNode
JSValue jsNodeIteratorPointerBeforeReferenceNode(ExecState* exec, JSValue slotBase, const Identifier&)
{
JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slotBase));
UNUSED_PARAM(exec);
NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
JSValue result = jsBoolean(imp->pointerBeforeReferenceNode());
return result;
}
示例14: FirstNode
void PFLCFG::ResetValid(void)
{
NodeIterator i = FirstNode();
for (; i != LastNode(); i++)
{
BBType *bb = i.current()->NodeInfo;
bb->Valid = false;
}
}
示例15: isNeighbor
bool LitterNetwork::isNeighbor(LitterNode& source, LitterNode& dest) {
NodeIterator* ni = source.getNeighborIT();
while (ni->moveNext()) {
if (ni->current() == &dest) {
return true;
}
}
return false;
}