Use Map instead directly using
This commit is contained in:
parent
3045e1a8e4
commit
904cb20387
1 changed files with 13 additions and 9 deletions
|
@ -274,15 +274,19 @@ RangeView(std::ranges::range auto&& range) -> RangeView<std::remove_reference_t<
|
||||||
|
|
||||||
template <utempl::ConstexprString... Names, utempl::Tuple... Dependencies>
|
template <utempl::ConstexprString... Names, utempl::Tuple... Dependencies>
|
||||||
consteval auto TopologicalSort(const DependencyGraph<DependencyGraphElement<Names, Dependencies>...>&) {
|
consteval auto TopologicalSort(const DependencyGraph<DependencyGraphElement<Names, Dependencies>...>&) {
|
||||||
const utempl::Tuple storage = {[&]<auto DDependencies>(utempl::Wrapper<DDependencies>) {
|
constexpr utempl::Tuple names = {Names...};
|
||||||
return [&]<std::size_t... Is>(std::index_sequence<Is...>) -> std::array<std::size_t, utempl::kTupleSize<decltype(DDependencies)>> {
|
constexpr utempl::Tuple storage = Map(utempl::Tuple{Dependencies...},
|
||||||
return {utempl::Find(utempl::Tuple{Names...}, Get<Is>(DDependencies))...};
|
[&]<utempl::TupleLike Tuple>(Tuple&& tuple){
|
||||||
}(std::make_index_sequence<utempl::kTupleSize<decltype(DDependencies)>>{});
|
static constexpr auto Size = utempl::kTupleSize<Tuple>;
|
||||||
}(utempl::Wrapper<Dependencies>{})...};
|
return [&]<std::size_t... Is>(std::index_sequence<Is...>) -> std::array<std::size_t, Size> {
|
||||||
|
return {Find(names, Get<Is>(std::forward<Tuple>(tuple)))...};
|
||||||
|
}(std::make_index_sequence<Size>());
|
||||||
|
});
|
||||||
constexpr auto Size = utempl::kTupleSize<decltype(storage)>;
|
constexpr auto Size = utempl::kTupleSize<decltype(storage)>;
|
||||||
const std::array adj = [&]<std::size_t... Is>(std::index_sequence<Is...>){
|
const std::array adj = utempl::Map(storage,
|
||||||
return std::array{impl::RangeView{Get<Is>(storage)}...};
|
[](std::ranges::range auto& arg){
|
||||||
}(std::make_index_sequence<Size>{});
|
return impl::RangeView{arg};
|
||||||
|
}, utempl::kType<std::array<std::size_t, 0>>);
|
||||||
std::array<bool, Size> visited{};
|
std::array<bool, Size> visited{};
|
||||||
constexpr auto ResultSize = sizeof...(Dependencies);
|
constexpr auto ResultSize = sizeof...(Dependencies);
|
||||||
impl::CompileTimeStack<std::size_t, ResultSize> response{};
|
impl::CompileTimeStack<std::size_t, ResultSize> response{};
|
||||||
|
@ -300,7 +304,7 @@ consteval auto TopologicalSort(const DependencyGraph<DependencyGraphElement<Name
|
||||||
response.Push(v);
|
response.Push(v);
|
||||||
}(i);
|
}(i);
|
||||||
};
|
};
|
||||||
return utempl::Transform(std::move(response.data), [](auto&& data){
|
return utempl::Map(std::move(response.data), [](auto&& data){
|
||||||
return *data;
|
return *data;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue