本文整理汇总了C++中NodeVector::end方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeVector::end方法的具体用法?C++ NodeVector::end怎么用?C++ NodeVector::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeVector
的用法示例。
在下文中一共展示了NodeVector::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calculate_path
NodePath* Dijkstra::calculate_path(Node* start, Node* dest) {
/**
* This is the dijkstra algorithm that searches through the node graph for
* the most efficiant way from start node to destination node.
*/
//Initialize; set cost to startnode to zero and rest to inf.
Node* current_node = start;
NodeVector graph = grid->get_nodes();
for (NodeVector::iterator it = graph.begin(); it != graph.end(); it++) {
(*it)->set_cost_from_start(max_cost);
}
start->set_cost_from_start(0);
prio_queue.push(current_node);
//Core loop
while (!prio_queue.empty()) {
current_node = prio_queue.top();
prio_queue.pop();
if (current_node == dest) {
save_path(start, dest);
while (!prio_queue.empty())
{
prio_queue.pop();
}
return create_path_copy(saved_paths[NodePair(start, dest)]);
}
NodeVector neighbors = current_node->get_neighbors();
for (NodeVector::iterator neighbor = neighbors.begin(); neighbor != neighbors.end(); neighbor++) {
if (*neighbor == current_node)
continue;
if (!(*neighbor)->is_allowed())
continue;
int new_cost = current_node->get_cost_from_start();
new_cost++;
int neighbor_cost = (*neighbor)->get_cost_from_start();
if (new_cost < neighbor_cost) {
(*neighbor)->set_cost_from_start(new_cost);
(*neighbor)->set_parent(current_node);
prio_queue.push((*neighbor));
}
}
}
save_path(start, dest);
return create_path_copy(saved_paths[NodePair(start, dest)]);
}
示例2: copyUnique
/**
* Copies the entries of the input vector of types to the output vector,
* omitting duplicate types. Useful for TypeSet and UnionType simplification.
*/
void copyUnique(const NodeVector& input, NodeVector& output)
{
for (NodeVector::const_iterator it = input.begin(); it != input.end(); it++) {
bool exists = false;
for (NodeVector::iterator is = output.begin(); is != output.end(); is++) {
if (equal(*it, *is)) {
exists = true;
break;
}
}
if (!exists) output.push_back(*it);
}
assert(output.size() <= input.size());
assert(output.empty() == input.empty());
}
示例3: willRemoveChildren
static void willRemoveChildren(ContainerNode* container)
{
NodeVector children;
getChildNodes(container, children);
container->document()->nodeChildrenWillBeRemoved(container);
#if ENABLE(MUTATION_OBSERVERS)
ChildListMutationScope mutation(container);
#endif
for (NodeVector::const_iterator it = children.begin(); it != children.end(); it++) {
Node* child = it->get();
#if ENABLE(MUTATION_OBSERVERS)
mutation.willRemoveChild(child);
child->notifyMutationObserversNodeWillDetach();
#endif
#if ENABLE(UNDO_MANAGER)
if (UndoManager::isRecordingAutomaticTransaction(container))
UndoManager::addTransactionStep(NodeRemovingDOMTransactionStep::create(container, child));
#endif
// fire removed from document mutation events.
dispatchChildRemovalEvents(child);
}
ChildFrameDisconnector(container, ChildFrameDisconnector::DoNotIncludeRoot).disconnect();
}
示例4: parserInsertBefore
void ContainerNode::parserInsertBefore(PassRefPtr<Node> newChild, Node* nextChild)
{
ASSERT(newChild);
ASSERT(nextChild);
ASSERT(nextChild->parentNode() == this);
NodeVector targets;
collectTargetNodes(newChild.get(), targets);
if (targets.isEmpty())
return;
if (nextChild->previousSibling() == newChild || nextChild == newChild) // nothing to do
return;
RefPtr<Node> next = nextChild;
RefPtr<Node> nextChildPreviousSibling = nextChild->previousSibling();
for (NodeVector::const_iterator it = targets.begin(); it != targets.end(); ++it) {
Node* child = it->get();
insertBeforeCommon(next.get(), child);
childrenChanged(true, nextChildPreviousSibling.get(), nextChild, 1);
ChildNodeInsertionNotifier(this).notify(child);
}
}
示例5: sortNodes
void sortNodes(NodeVector& all){
// int count=0;
int max=0;
deque<Node*> sorted;
for (int i=0; i<all.size(); i++) {
Node* n=all[i];
if(n->statementCount>max){
sorted.push_front(n);
max=n->statementCount;
}
else sorted.push_back(n);
}
for (int i=0; i<all.size(); i++) {
all[i]=sorted[i];
}
std::sort(all.begin(), all.end(),sortNodePredicate);
// auto x=all.begin();
// auto y=all.end();
// std::sort(x, y, sortNodePredicate);// [] (Node* a, Node* b){ return a->statementCount > b->statementCount; });
// std::sort(all.begin(), all.end(), [] (Node* a, Node* b)->bool { return a->statementCount < b->statementCount; });
// showNodes(all,false,false,false);
// std::sort(all.begin(), all.end(), [] (Node* a, Node* b) { return a->statementCount < b->statementCount; });
// showNodes(all,false,false,false);
// std::sort(all.begin(),all.end(),);
}
示例6: intersect
/**
* Returns the intersection between the TypeSet and the other node. The other
* node may also be a type set, in which case this function is called
* recursively to resolve the intersect.
*/
NodePtr intersect(const TypeSet::Ptr& typeSet, const NodePtr& other)
{
// Intersect all types in the type set with the other type.
NodeVector newTypes;
const NodeVector& types = typeSet->getTypes();
for (NodeVector::const_iterator it = types.begin(); it != types.end(); it++) {
NodePtr type = intersect(*it, other);
if (type->isKindOf(kInvalidType)) continue; // skip if the intersect was impossible
bool exists = false;
for (NodeVector::iterator is = newTypes.begin(); is != newTypes.end(); is++) {
if (equal(type, *is)) {
exists = true;
break;
}
}
if (!exists) newTypes.push_back(type);
}
// Return the new type set if it contains multiple types, a single type if
// there's only one left after the intersect, or InvalidType if the
// intersect yielded no types in the set.
if (newTypes.empty()) {
return NodePtr(new InvalidType);
} else if (newTypes.size() == 1) {
return newTypes.front();
} else {
TypeSet::Ptr ts(new TypeSet);
ts->setTypes(newTypes);
return ts;
}
}
示例7: GetUnitsInRadius
void CUniformGrid::GetUnitsInRadius(NodeVector * dstVector, const Vector3 & point, float radius)
{
const Vector3 radiusPoint(radius, radius, 0);
int minX, minY;
CellCoordFromMapPoint(&minX, &minY, point - radiusPoint);
minX = math::max(0, math::min(minX, (m_Width - 1)));
minY = math::max(0, math::min(minY, (m_Height - 1)));
int maxX, maxY;
CellCoordFromMapPoint(&maxX, &maxY, point + radiusPoint);
maxX = math::max(0, math::min(maxX, (m_Width - 1)));
maxY = math::max(0, math::min(maxY, (m_Height - 1)));
dstVector->clear();
for (int y = minY; y <= maxY; ++y)
{
for (int x = minX; x <= maxX; ++x)
{
// FIXME: non optimal - square, refactor me
NodeVector * gridVector = GetCell(x, y);
dstVector->insert(dstVector->end(), gridVector->begin(), gridVector->end());
}
}
}
示例8:
template<class NodeVector> void FileSystem::debugPrintNodes(NodeVector nodes) {
if( debug) {
unsigned int ix;
NodeInfo* node;
for (ix = 0; ix < nodes.size(); ++ix) {
node = nodes.at(ix);
cout << "Node: " << node->getName()
<< "\t\tSize: " << node->getSize()
<< "\tModify: " << node->getModifyTime()
<< "\tPath: " << node->getPath()
<< "\tSimilars: ";
vector<NodeInfo*>::iterator it;
vector<NodeInfo*> nodes = node->getSimilar();
for(it=nodes.begin(); it != nodes.end(); ++it) {
cout << (*it)->getPath() << ", ";
}
cout << endl;
}
}
}
示例9: wrapFuncArgs
void InitRootTypes::wrapFuncArgs(NodeVector& args, const NodeVector& funcArgs)
{
for (NodeVector::const_iterator it = funcArgs.begin(); it != funcArgs.end(); it++) {
const FuncArg::Ptr& funcArg = FuncArg::from(*it);
TupleTypeArg::Ptr arg(new TupleTypeArg);
arg->setName(funcArg->getName());
arg->setType(funcArg->getPossibleType());
args.push_back(arg);
}
}
示例10: isEmbedded
bool isEmbedded()
{
if (isAssocClass)
for (NodeVector::const_iterator it = oFields.begin(); it != oFields.end(); ++it)
{
if (*it == NULL) continue;
if (CSLTestBoolean(CPLGetXMLValue( *it, "EmbeddedTransfer", "FALSE" )))
return true;
}
return false;
}
示例11: addFields
void Class::addFields(const NodeVector& fields)
{
// Make sure all the nodes given as parameters have the right kind
for ( Node* field: fields )
{
if ( field->nodeKind() != nkFeatherDeclVar )
REP_INTERNAL(field->location(), "Node %1% must be a field") % field;
}
children_.insert(children_.end(), fields.begin(), fields.end());
}
示例12: clear_saved_paths
void Dijkstra::clear_saved_paths() {
for (std::map<NodePair, NodePath*>::iterator it = saved_paths.begin();
it != saved_paths.end(); it++) {
delete (*it).second;
(*it).second = NULL;
}
saved_paths.clear();
NodeVector nodes = grid->get_nodes();
for (NodeVector::iterator node = nodes.begin(); node != nodes.end(); node++) {
(*node)->set_cost_from_start(max_cost);
}
}
示例13: intersect
// todo: presorted jumplists
NodeVector intersect(NodeVector a, NodeVector b) {
NodeVector c;
NodeVector::iterator it;
for(it = a.begin(); it != a.end(); ++it)
if (contains(b, *it))
// c.insert(*it);
c.push_back(*it);
// for (int i=0; i < a.size(); i++) {
// Node* n=a[0];
// if (contains(b, n)) c.push_back(n);
// }
return c;
}
示例14: findAlgorithm
Algorithm* Network::findAlgorithm(const std::string& name) {
NodeVector nodes = depthFirstSearch(_visibleNetworkRoot);
for (NodeVector::iterator node = nodes.begin(); node != nodes.end(); ++node) {
if ((*node)->algorithm()->name() == name) return (*node)->algorithm();
}
ostringstream msg;
msg << "Could not find algorithm with name '" << name << "'. Known algorithms are: ";
if (!nodes.empty()) msg << '\'' << nodes[0]->algorithm()->name() << '\'';
for (int i=1; i<(int)nodes.size(); i++) {
msg << ", '" << nodes[i]->algorithm()->name() << '\'';
}
throw EssentiaException(msg);
}
示例15: Collide
void CUniformGrid::Collide(NodeVector * dstVector, IUniformGridDelegate * delegate)
{
for (int y = 0; y < m_Height; ++y)
{
for (int x = 0; x < m_Width; ++x)
{
dstVector->clear();
NodeVector * cellList = GetCell(x, y);
dstVector->insert(dstVector->end(), cellList->begin(), cellList->end());
cellList = GetCell(x + 1, y);
if (NULL != cellList)
{
dstVector->insert(dstVector->end(), cellList->begin(), cellList->end());
}
cellList = GetCell(x + 1, y + 1);
if (NULL != cellList)
{
dstVector->insert(dstVector->end(), cellList->begin(), cellList->end());
}
cellList = GetCell(x, y + 1);
if (NULL != cellList)
{
dstVector->insert(dstVector->end(), cellList->begin(), cellList->end());
}
if (dstVector->size() > 0)
{
delegate->ProcessNeighbourNodes(dstVector);
}
}
}
}