bool Result::grow() { std::vector<bool> removeThis(lines_.size(), false); // Puts all the lines that pass the check on front. // LineList::iterator newEnd = partition(lines_.begin(), lines_.end(), // checker); int n = 0; int res = lines_.size(); for (LineList::iterator i = lines_.begin(); i != lines_.end(); ++i) { if (!CanGrow(*i, len_ + 1)) { removeThis[n]= true; res--; } n++; } // is this a trivial result? if (res < 2) { lines_.sort(); return false; } len_++; LineList::iterator itr = lines_.begin(); for (unsigned i = 0; i < removeThis.size(); i++) { if (removeThis[i]) { LineList::iterator old = itr; itr++; lines_.erase(old); } else ++itr; } return true; }
LinkListBase::NodeBase::~NodeBase() { removeThis(); }
void Node::addChild(Node* node, int local_z /*= 0*/) { removeThis(); GMASSERT(m_parent == nullptr); m_childList.push_back(node); }