9template<
typename InElementType>
10struct TDiGraphTopologicalIterator_Base;
12template<
typename InElementType>
21 return _Nodes.Emplace(Item);
31 if (
ULANG_ENSUREF(_Nodes.IsValidIndex(From) && _Nodes.IsValidIndex(
To),
"Invalid edge indices."))
33 _Nodes[From]._Successors.Add(
To);
34 ++_Nodes[
To]._InDegree;
42 if (
ULANG_ENSUREF(_Nodes.IsValidIndex(From) && _Nodes.IsValidIndex(
To),
"Invalid edge indices."))
49 ++_Nodes[
To]._InDegree;
73 return _Nodes[
Index]._Item;
78 return _Nodes[
Index]._Item;
106template<
typename InElementType>
118 return !_NodesToVisit.IsEmpty();
124 return _NodesToVisit.Pop(
false);
135 if (_NodesToVisit.Num() > 0)
137 const int32_t NodeIndex = _NodesToVisit.Pop(
false);
139 const typename DiGraphType::SNode&
Node =
Container._Nodes[NodeIndex];
155 return _NodesToVisit.Top();
160 _NodesToVisit.Empty(
Container._Nodes.Num());
162 for (
int32_t NodeIndex = 0; NodeIndex <
Container._Nodes.Num(); ++NodeIndex)
164 if (
Container._Nodes[NodeIndex]._InDegree == 0)
166 _NodesToVisit.Add(NodeIndex);
170 _VisitCounters.Reset();
171 _VisitCounters.AddDefaulted(
Container._Nodes.Num());
180template<
typename InElementType>
217template<
typename InElementType>
253template<
typename InElementType>
263 return OutItems.Num() == ExpectedSize;
266template<
typename InElementType>
276 return OutItems.Num() == ExpectedSize;
279template<
typename InElementType>
289 return OutItems.Num() == ExpectedSize;
292template<
typename InElementType>
310 for (
int32_t RootNodeIndex = 0; RootNodeIndex < _Nodes.Num(); ++RootNodeIndex)
322 if (
StackTop._NextSuccessorIndex <
Node._Successors.Num())
338 for (
int32_t StackIndex = 0; StackIndex < Stack.
Num(); ++StackIndex)
373template<
typename InElementType>
394 template<
typename VisitorType>
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const bool
Definition NetworkReplayStreaming.h:178
#define ULANG_ENSUREF(expr, format,...)
Definition Common.h:292
void Reset(int32_t NewSize=0)
Definition Array.h:1303
ULANG_FORCEINLINE ElementType & Top()
Definition Array.h:513
ULANG_FORCEINLINE ElementType Pop(bool bAllowShrinking=true)
Definition Array.h:476
ULANG_FORCEINLINE int32_t Add(ElementType &&Item)
Definition Array.h:1587
ULANG_FORCEINLINE int32_t Num() const
Definition Array.h:402
Definition DirectedGraph.h:14
const InElementType & operator[](NodeId Index) const
Definition DirectedGraph.h:71
NodeId AddNode(const InElementType &Item)
Definition DirectedGraph.h:19
NodeId AddNode(InElementType &&Item)
Definition DirectedGraph.h:24
bool TopologicalSort(TArray< InElementType > &OutItems) const
Definition DirectedGraph.h:254
TArray< TArray< NodeId > > FindCycles() const
Definition DirectedGraph.h:293
static constexpr NodeId InvalidNodeId
Definition DirectedGraph.h:17
void Reserve(int32_t NodesSlack, int32_t EdgesSlack=0)
Definition DirectedGraph.h:56
bool AddDirectedEdge(const NodeId From, const NodeId To)
Definition DirectedGraph.h:29
InElementType & operator[](NodeId Index)
Definition DirectedGraph.h:76
int32_t NumNodes() const
Definition DirectedGraph.h:66
bool AddDirectedEdgeUnique(const NodeId From, const NodeId To)
Definition DirectedGraph.h:40
bool TopologicalSort_Pointers(TArray< const InElementType * > &OutItems) const
Definition DirectedGraph.h:267
int32_t NodeId
Definition DirectedGraph.h:16
void Empty(int32_t NodesSlack=0, int32_t EdgesSlack=0)
Definition DirectedGraph.h:61
Definition VVMEngineEnvironment.h:23
ULANG_FORCEINLINE TRemoveReference< T >::Type && MoveIfPossible(T &&Obj)
Definition References.h:104
@ IndexNone
Definition Common.h:381
ULANG_FORCEINLINE TRemoveReference< T >::Type && Move(T &&Obj)
Definition References.h:86
U16 Index
Definition radfft.cpp:71
Definition DirectedGraph.h:219
TDiGraphConstTopologicalIterator & operator++()
Definition DirectedGraph.h:228
TDiGraphConstTopologicalIterator(const DiGraphType &InContainer)
Definition DirectedGraph.h:223
typename Super::DiGraphType DiGraphType
Definition DirectedGraph.h:221
const InElementType & operator*()
Definition DirectedGraph.h:234
void Reset()
Definition DirectedGraph.h:244
const InElementType * operator->() const
Definition DirectedGraph.h:239
Definition DirectedGraph.h:108
void Enqueue(TArray< typename DiGraphType::NodeId > &&NodesToVisit)
Definition DirectedGraph.h:127
TDiGraphTopologicalIterator_Base(const DiGraphType &InContainer)
Definition DirectedGraph.h:111
void Reset(const DiGraphType &Container)
Definition DirectedGraph.h:158
void Increment(const DiGraphType &Container)
Definition DirectedGraph.h:133
DiGraphType::NodeId CurrentNodeIndex() const
Definition DirectedGraph.h:153
DiGraphType::NodeId SkipCurrent()
Definition DirectedGraph.h:122
TDirectedGraph< InElementType > DiGraphType
Definition DirectedGraph.h:109
Definition DirectedGraph.h:182
InElementType & operator*()
Definition DirectedGraph.h:197
typename Super::DiGraphType DiGraphType
Definition DirectedGraph.h:184
TDiGraphTopologicalIterator(DiGraphType &InContainer)
Definition DirectedGraph.h:186
InElementType * operator->() const
Definition DirectedGraph.h:202
void Reset()
Definition DirectedGraph.h:207
TDiGraphTopologicalIterator & operator++()
Definition DirectedGraph.h:191
Definition DirectedGraph.h:375
bool IsComplete() const
Definition DirectedGraph.h:417
bool Iterate(VisitorType Visitor)
Definition DirectedGraph.h:395
IteratorType _GraphIterator
Definition DirectedGraph.h:427
TDiGraphVisitor(DiGraphType &DiGraph)
Definition DirectedGraph.h:379
void Reset()
Definition DirectedGraph.h:422