/** * Reverse lookup the dependencies of (direct) parents over a given child. * @param parents list to store all parents in (is not cleared) * @param child the child to search the parents' dependencies for */ void ClientNetworkContentSocketHandler::ReverseLookupDependency(ConstContentVector &parents, const ContentInfo *child) const { for (ConstContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) { const ContentInfo *ci = *iter; if (ci == child) continue; for (uint i = 0; i < ci->dependency_count; i++) { if (ci->dependencies[i] == child->id) { *parents.Append() = ci; break; } } } }
/** * Reverse lookup the dependencies of all parents over a given child. * @param tree list to store all parents in (is not cleared) * @param child the child to search the parents' dependencies for */ void ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(ConstContentVector &tree, const ContentInfo *child) const { *tree.Append() = child; /* First find all direct parents */ for (ConstContentIterator iter = tree.Begin(); iter != tree.End(); iter++) { ConstContentVector parents; this->ReverseLookupDependency(parents, *iter); for (ConstContentIterator piter = parents.Begin(); piter != parents.End(); piter++) { tree.Include(*piter); } } }
/** * Reverse lookup the dependencies of all parents over a given child. * @param tree list to store all parents in (is not cleared) * @param child the child to search the parents' dependencies for */ void ClientNetworkContentSocketHandler::ReverseLookupTreeDependency(ConstContentVector &tree, const ContentInfo *child) const { *tree.Append() = child; /* First find all direct parents. We can't use the "normal" iterator as * we are including stuff into the vector and as such the vector's data * store can be reallocated (and thus move), which means out iterating * pointer gets invalid. So fall back to the indices. */ for (uint i = 0; i < tree.Length(); i++) { ConstContentVector parents; this->ReverseLookupDependency(parents, tree[i]); for (ConstContentIterator piter = parents.Begin(); piter != parents.End(); piter++) { tree.Include(*piter); } } }