Macaulay2 Engine
Loading...
Searching...
No Matches

◆ patternLeavesWorker()

auto SuffixTree::patternLeavesWorker ( SuffixTreeNode * v) const->std::vector< SuffixTreeNode * >

Definition at line 407 of file SuffixTree.cpp.

408{
409 // TODO: the workers are still making a copy and returning it
410 // make change to allow for reference to be passed along.
411 // The workers also return the pointer to the node rather than the
412 // pattern number, as they probably should.
413 auto retval = std::vector<SuffixTreeNode*> {};
414 if (v->numChildren() == 0 && v->isFullPattern())
415 {
416 retval.push_back(v);
417 return retval;
418 }
419 if ((v->numChildren() == 0 && !v->isFullPattern()) || v->patternLeafCount() == 0)
420 {
421 return retval;
422 }
423 for (auto i = v->childrenBegin(); i != v->childrenEnd(); ++i)
424 {
425 auto tmp = patternLeavesWorker(i->second);
426 std::copy(tmp.begin(),tmp.end(),std::back_inserter(retval));
427 }
428 return retval;
429}
auto patternLeavesWorker(SuffixTreeNode *v) const -> std::vector< SuffixTreeNode * >
std::map< Label, SuffixTreeNode * >::iterator childrenEnd()
size_t numChildren() const
std::map< Label, SuffixTreeNode * >::iterator childrenBegin()
int patternLeafCount() const
bool isFullPattern() const

References patternLeavesWorker().

Referenced by patternLeaves(), and patternLeavesWorker().