本文整理汇总了C++中BlockSet::find方法的典型用法代码示例。如果您正苦于以下问题:C++ BlockSet::find方法的具体用法?C++ BlockSet::find怎么用?C++ BlockSet::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BlockSet
的用法示例。
在下文中一共展示了BlockSet::find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
Shape *MakeLoop(BlockSet &Blocks, BlockSet& Entries, BlockSet &NextEntries) {
// Find the inner blocks in this loop. Proceed backwards from the entries until
// you reach a seen block, collecting as you go.
BlockSet InnerBlocks;
BlockSet Queue = Entries;
while (Queue.size() > 0) {
Block *Curr = *(Queue.begin());
Queue.erase(Queue.begin());
if (InnerBlocks.find(Curr) == InnerBlocks.end()) {
// This element is new, mark it as inner and remove from outer
InnerBlocks.insert(Curr);
Blocks.erase(Curr);
// Add the elements prior to it
for (BlockBranchMap::iterator iter = Curr->BranchesIn.begin(); iter != Curr->BranchesIn.end(); iter++) {
Queue.insert(iter->first);
}
}
}
assert(InnerBlocks.size() > 0);
for (BlockSet::iterator iter = InnerBlocks.begin(); iter != InnerBlocks.end(); iter++) {
Block *Curr = *iter;
for (BlockBranchMap::iterator iter = Curr->BranchesOut.begin(); iter != Curr->BranchesOut.end(); iter++) {
Block *Possible = iter->first;
if (InnerBlocks.find(Possible) == InnerBlocks.end() &&
NextEntries.find(Possible) == NextEntries.find(Possible)) {
NextEntries.insert(Possible);
}
}
}
PrintDebug("creating loop block:\n");
DebugDump(InnerBlocks, " inner blocks:");
DebugDump(Entries, " inner entries:");
DebugDump(Blocks, " outer blocks:");
DebugDump(NextEntries, " outer entries:");
// TODO: Optionally hoist additional blocks into the loop
LoopShape *Loop = new LoopShape();
Notice(Loop);
// Solipsize the loop, replacing with break/continue and marking branches as Processed (will not affect later calculations)
// A. Branches to the loop entries become a continue to this shape
for (BlockSet::iterator iter = Entries.begin(); iter != Entries.end(); iter++) {
Solipsize(*iter, Branch::Continue, Loop, InnerBlocks);
}
// B. Branches to outside the loop (a next entry) become breaks on this shape
for (BlockSet::iterator iter = NextEntries.begin(); iter != NextEntries.end(); iter++) {
Solipsize(*iter, Branch::Break, Loop, InnerBlocks);
}
// Finish up
Shape *Inner = Process(InnerBlocks, Entries, NULL);
Loop->Inner = Inner;
return Loop;
}
示例2: FindLive
void FindLive(Block *Root) {
BlockList ToInvestigate;
ToInvestigate.push_back(Root);
while (ToInvestigate.size() > 0) {
Block *Curr = ToInvestigate.front();
ToInvestigate.pop_front();
if (Live.find(Curr) != Live.end()) continue;
Live.insert(Curr);
for (BlockBranchMap::iterator iter = Curr->BranchesOut.begin(); iter != Curr->BranchesOut.end(); iter++) {
ToInvestigate.push_back(iter->first);
}
}
}
示例3: Solipsize
// Converts/processes all branchings to a specific target
void Solipsize(Block *Target, Branch::FlowType Type, Shape *Ancestor, BlockSet &From) {
PrintDebug("Solipsizing branches into %d\n", Target->Id);
DebugDump(From, " relevant to solipsize: ");
for (BlockSet::iterator iter = Target->BranchesIn.begin(); iter != Target->BranchesIn.end();) {
Block *Prior = *iter;
if (From.find(Prior) == From.end()) {
iter++;
continue;
}
Branch *PriorOut = Prior->BranchesOut[Target];
PriorOut->Ancestor = Ancestor;
PriorOut->Type = Type;
if (MultipleShape *Multiple = Shape::IsMultiple(Ancestor)) {
Multiple->NeedLoop++; // We are breaking out of this Multiple, so need a loop
}
iter++; // carefully increment iter before erasing
Target->BranchesIn.erase(Prior);
Target->ProcessedBranchesIn.insert(Prior);
Prior->BranchesOut.erase(Target);
Prior->ProcessedBranchesOut[Target] = PriorOut;
PrintDebug(" eliminated branch from %d\n", Prior->Id);
}
}