本文整理汇总了C++中AbstractNode类的典型用法代码示例。如果您正苦于以下问题:C++ AbstractNode类的具体用法?C++ AbstractNode怎么用?C++ AbstractNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AbstractNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
/*protected*/
std::auto_ptr<BoundableList>
AbstractSTRtree::createParentBoundables(BoundableList* childBoundables,
int newLevel)
{
assert(!childBoundables->empty());
std::auto_ptr< BoundableList > parentBoundables ( new BoundableList() );
parentBoundables->push_back(createNode(newLevel));
std::auto_ptr< BoundableList > sortedChildBoundables ( sortBoundables(childBoundables) );
for (BoundableList::iterator i=sortedChildBoundables->begin(),
e=sortedChildBoundables->end();
i!=e; i++)
//for(std::size_t i=0, scbsize=sortedChildBoundables->size(); i<scbsize; ++i)
{
Boundable *childBoundable=*i; // (*sortedChildBoundables)[i];
AbstractNode *last = lastNode(parentBoundables.get());
if (last->getChildBoundables()->size() == nodeCapacity)
{
last=createNode(newLevel);
parentBoundables->push_back(last);
}
last->addChildBoundable(childBoundable);
}
return parentBoundables;
}
示例2: simulate
void Simulator::simulate(void){
AbstractNode * node;
cout << graph.getTitle() << "\n";
node = graph.getStartNode().first;
cout << "Starting the simulation...\nThis is the starting node:\n";
cout << "Actor: " << static_cast<StartStopNode *>(node)->getActor()
<< endl;
cout << "Message: " << static_cast<StartStopNode *>(node)->getMessage()
<< endl;
cout << "Moving on to first task...\n";
node = graph.getNextNode().first;
if(node == NULL){
cout << "There was an error somewhere... Exiting...\n";
exit(1);
}
while(node->getTraverseType() != STOP){
askIfCompleted(static_cast<Task *>(node));
node = graph.getNextNode().first;
if(node == NULL){
cout << "There was an error somewhere... Exiting...\n";
exit(1);
}
}
cout << "Actor: " << static_cast<Task *>(node)->getActor() << "\n";
cout << "This is the end of the simulation... Exiting..." << "\n";
}
示例3: assert
/*protected*/
std::auto_ptr<BoundableList>
SIRtree::createParentBoundables(BoundableList *childBoundables,int newLevel)
{
assert(!childBoundables->empty());
std::auto_ptr<BoundableList> parentBoundables ( new BoundableList() );
parentBoundables->push_back(createNode(newLevel));
std::auto_ptr<BoundableList> sortedChildBoundables ( sortBoundables(childBoundables) );
//for(unsigned int i=0;i<sortedChildBoundables->size();i++)
for (BoundableList::iterator i=sortedChildBoundables->begin(),
e=sortedChildBoundables->end();
i!=e; ++i)
{
//Boundable *childBoundable=(AbstractNode*)(*sortedChildBoundables)[i];
Boundable *childBoundable=*i;
AbstractNode* lNode = lastNode(parentBoundables.get());
if (lNode->getChildBoundables()->size() == nodeCapacity)
{
parentBoundables->push_back(createNode(newLevel));
}
lNode->addChildBoundable(childBoundable);
}
return parentBoundables;
}
示例4: AbstractNode
AbstractNode *NodeFactory::createOpenBracket()
{
AbstractNode *an = new AbstractNode();
Data *tmp = new Operator();
tmp->setOperator('(');
tmp->setPriority(3);
an->setData(tmp);
return an;
}
示例5: while
bool AbstractNode::isDisjunctionOfComplexConjunctions()
{
if(AbstractNode::TYPE_OPERATION_OR != getType())
return false; //not a disjunction
int numOperations = 0;
ChainIterator<AbstractNode*> *iterator = children->getIterator();
while(true == iterator->hasNext()) {
AbstractNode *child = iterator->next(); //Get an element which might be conjunction
//Disjunction contains elements which are not parts of conjunction
if(!((AbstractNode::TYPE_VARIABLE == child->getType()) ||
(AbstractNode::TYPE_OPERATION_AND == child->getType()) ||
(AbstractNode::TYPE_OPERATION_NOT == child->getType()))) {
return false;
}
if(AbstractNode::TYPE_OPERATION_AND == child->getType()) {
if(child->getChildren()->getSize() > 1)
numOperations++;
}
if(AbstractNode::TYPE_OPERATION_NOT == child->getType()) {
AbstractNode *grandChild = child->getChildren()->getFirstElement();
if(AbstractNode::TYPE_VARIABLE != grandChild->getType()) {
return false; //Contains complex NOT operation
}
}
}
return (numOperations > 0);
}
示例6: while
unsigned long AttrMap::length() const
{
unsigned long result = 0;
AbstractNode* pAttr = _pElement->_pFirstAttr;
while (pAttr)
{
pAttr = static_cast<AbstractNode*>(pAttr->nextSibling());
++result;
}
return result;
}
示例7: calculateDownForces
void BalanceGraph::calculateDownForces()
{
for(Segment* segment : segments) {
AbstractNode* head = segment->nodes.first();
if (head->getPredecessors().isEmpty()) {
segment->dForce = 0;
} else {
qreal sum = 0;
for(AbstractNode* pred : head->getPredecessors()) {
sum += pred->getOutport().x() - head->getInport().x();
}
segment->dForce = (double) (sum / head->getPredecessors().size());
}
}
}
示例8: if
/*protected*/
void
AbstractSTRtree::query(const void* searchBounds, const AbstractNode& node,
ItemVisitor& visitor)
{
const BoundableList& boundables = *(node.getChildBoundables());
for (BoundableList::const_iterator i=boundables.begin(), e=boundables.end();
i!=e; i++)
{
const Boundable* childBoundable = *i;
if (!getIntersectsOp()->intersects(childBoundable->getBounds(), searchBounds)) {
continue;
}
if(const AbstractNode *an=dynamic_cast<const AbstractNode*>(childBoundable))
{
query(searchBounds, *an, visitor);
}
else if (const ItemBoundable *ib=dynamic_cast<const ItemBoundable *>(childBoundable))
{
visitor.visitItem(ib->getItem());
}
else
{
assert(0); // unsupported childBoundable type
}
}
}
示例9:
/* private */
bool
AbstractSTRtree::remove(const void* searchBounds, AbstractNode& node, void* item)
{
// first try removing item from this node
if ( removeItem(node, item) ) return true;
BoundableList& boundables = *(node.getChildBoundables());
// next try removing item from lower nodes
for (BoundableList::iterator i=boundables.begin(), e=boundables.end();
i!=e; i++)
{
Boundable* childBoundable = *i;
if (!getIntersectsOp()->intersects(childBoundable->getBounds(), searchBounds))
continue;
if (AbstractNode *an=dynamic_cast<AbstractNode*>(childBoundable))
{
// if found, record child for pruning and exit
if ( remove(searchBounds, *an, item) )
{
if (an->getChildBoundables()->empty()) {
boundables.erase(i);
}
return true;
}
}
}
return false;
}
示例10: getType
bool AbstractNode::isSingleVariable(){
if(!(AbstractNode::TYPE_VARIABLE == getType() ||
AbstractNode::TYPE_OPERATION_NOT == getType()))
return false;
AbstractNode *var = NULL;
if(AbstractNode::TYPE_VARIABLE == getType()) {
var = this;
} else if(AbstractNode::TYPE_OPERATION_NOT == getType()) {
var = children->getFirstElement();
}
if(AbstractNode::TYPE_VARIABLE == var->getType())
return true;
return false;
}
示例11: distance
/**
* \brief Determines the neighbor that is closest to the random node, sets its predecessor
* to the current node, and adds it to the list of explored nodes.
* \param[in] currentNode The current node.
* \param[in] neighbors The list of neighbors of the current node.
* \param[in] randomNode The randomly drawn node.
* \param[in,out] list The list of already expanded nodes.
*/
void RRT::addNearestNeighbor(GridNode* const currentNode, const std::vector<AbstractNode*>& neighbors,
GridNode* const randomNode, std::vector<AbstractNode*>& list) const {
/* TODO: Determine the neighbor that is closest to the random node, set its predecessor
* to the current node, and add it to the list of explored nodes.
*/
/* Available methods and fields:
* - node->setPredecessor(AbstractNode* node): store the predecessor node for a node (required
* later for extracting the path)
* - getClosestNodeInList(node, list): Defined above
*/
int min_cost = INT_MAX;
AbstractNode* minNode = NULL;
std::vector<AbstractNode *>::const_iterator it;
it = neighbors.begin();
for (;it != neighbors.end(); it++ )
{
double cost = distance(*it,randomNode);
if (cost < min_cost)
{
minNode = *it;
min_cost = cost;
}
}
minNode->setPredecessor(currentNode) ;
list.push_back(minNode);
// int min_cost = INT_MAX;
// AbstractNode* minNode = NULL;
// std::vector<AbstractNode*>::iterator it;
// for(it=neighbors.begin() ; it < neighbors.end(); it++)
// {
// double cost = distance(*it,randomNode);
// if (cost < min_cost)
// {
// minNode = *it;
// min_cost = cost;
// }
// }
// minNode->predecessor = currentNode;
// list.push_back(minNode);
}
示例12: calculateUpForces
void BalanceGraph::calculateUpForces()
{
for(Segment* segment : segments) {
AbstractNode* tail = segment->nodes.last();
if (tail->getSuccessors().isEmpty()) {
segment->dForce = 0;
} else {
qreal sum = 0;
for(AbstractNode* succ : tail->getSuccessors()) {
sum += succ->getInport().x() - tail->getOutport().x();
}
segment->dForce = (double) (sum / tail->getSuccessors().size());
}
}
}
示例13: visitChildren_via_iter
void NodeVisitor::visitChildren_via_iter(AbstractNode& node)
{
IIterator* i = node.createIterator();
for (i->First(); !i->IsDone(); i->Next()) {
i->CurrentItem()->accept(*this);
}
delete i;
}
示例14: setStatusMsg
void AssignLayers::run(Graph &graph)
{
emit setStatusMsg("Assigning layers...");
// copy the nodes to a linked list
QLinkedList<AbstractNode*> vertices;
for(AbstractNode* v : graph.getNodes()) {
vertices.append(v);
}
QSet<AbstractNode*> U;
QSet<AbstractNode*> Z;
QList<QList<AbstractNode*>> layers;
//add the first layer
int currentLayer = 0;
layers.append(QList<AbstractNode*>());
while(!vertices.isEmpty()) {
AbstractNode* selected = nullptr;
for(AbstractNode* v : vertices) {
if(Z.contains(v->getPredecessors().toSet())) {
selected = v;
break;
}
}
if(selected != nullptr) {
selected->setLayer(currentLayer);
layers.last().append(selected);
U.insert(selected);
vertices.removeOne(selected);
} else {
currentLayer++;
layers.append(QList<AbstractNode*>());
Z.unite(U);
}
}
graph.setLayers(layers);
graph.repaintLayers();
emit setStatusMsg("Assigning layers... Done!");
}
示例15: poco_check_ptr
void NodeAppender::appendChild(Node* newChild)
{
poco_check_ptr (newChild);
poco_assert (_pLast == 0 || _pLast->_pNext == 0);
if (static_cast<AbstractNode*>(newChild)->_pOwner != _pParent->_pOwner)
throw DOMException(DOMException::WRONG_DOCUMENT_ERR);
if (newChild->nodeType() == Node::DOCUMENT_FRAGMENT_NODE)
{
AbstractContainerNode* pFrag = static_cast<AbstractContainerNode*>(newChild);
AbstractNode* pChild = pFrag->_pFirstChild;
if (pChild)
{
if (_pLast)
_pLast->_pNext = pChild;
else
_pParent->_pFirstChild = pChild;
while (pChild)
{
_pLast = pChild;
pChild->_pParent = _pParent;
pChild = pChild->_pNext;
}
pFrag->_pFirstChild = 0;
}
}
else
{
AbstractNode* pAN = static_cast<AbstractNode*>(newChild);
pAN->duplicate();
if (pAN->_pParent)
pAN->_pParent->removeChild(pAN);
pAN->_pParent = _pParent;
if (_pLast)
_pLast->_pNext = pAN;
else
_pParent->_pFirstChild = pAN;
_pLast = pAN;
}
}