[PATCH] D151550: DirectedGraph: Add a constructor that takes a list of Nodes.
Johannes Reifferscheid via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 26 03:10:58 PDT 2023
jreiffers created this revision.
jreiffers added a reviewer: bkramer.
Herald added a project: All.
jreiffers requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This makes it possible to efficiently build a graph without repeatedly iterating
over the list of nodes.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151550
Files:
llvm/include/llvm/ADT/DirectedGraph.h
Index: llvm/include/llvm/ADT/DirectedGraph.h
===================================================================
--- llvm/include/llvm/ADT/DirectedGraph.h
+++ llvm/include/llvm/ADT/DirectedGraph.h
@@ -172,9 +172,9 @@
/// Each edge contains the target node it connects to.
template <class NodeType, class EdgeType> class DirectedGraph {
protected:
- using NodeListTy = SmallVector<NodeType *, 10>;
using EdgeListTy = SmallVector<EdgeType *, 10>;
public:
+ using NodeListTy = SmallVector<NodeType *, 10>;
using iterator = typename NodeListTy::iterator;
using const_iterator = typename NodeListTy::const_iterator;
using DGraphType = DirectedGraph<NodeType, EdgeType>;
@@ -183,6 +183,7 @@
explicit DirectedGraph(NodeType &N) : Nodes() { addNode(N); }
DirectedGraph(const DGraphType &G) : Nodes(G.Nodes) {}
DirectedGraph(DGraphType &&RHS) : Nodes(std::move(RHS.Nodes)) {}
+ DirectedGraph(NodeListTy Nodes) : Nodes(std::move(Nodes)) {}
DGraphType &operator=(const DGraphType &G) {
Nodes = G.Nodes;
return *this;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151550.526006.patch
Type: text/x-patch
Size: 1047 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230526/3db6689d/attachment.bin>
More information about the llvm-commits
mailing list