MCPcopy Create free account
hub / github.com/Dobiasd/FunctionalPlus / trees_from_sequence

Function trees_from_sequence

include/fplus/tree.hpp:89–103  ·  view source on GitHub ↗

todo: name?

Source from the content-addressed store, hash-verified

87// Converts the sequence into a tree considering the given binary predicate.
88template <typename BinaryPredicate, typename Container> // todo: name?
89std::vector<tree<typename Container::value_type>> trees_from_sequence(
90 BinaryPredicate is_child_of, const Container& xs)
91{
92 internal::check_binary_predicate_for_container<BinaryPredicate, Container>();
93 typedef typename Container::value_type T;
94 typedef tree<T> Tree;
95 const auto singletons = transform_convert<std::vector<Tree>>(
96 internal::make_singleton_tree<T>, xs);
97 const auto tree_is_child_of =
98 [is_child_of](const tree<T>& a, const tree<T>& b) -> bool {
99 return is_child_of(a.value_, b.value_);
100 };
101 return internal::trees_from_sequence_helper(
102 tree_is_child_of, std::move(singletons));
103}
104
105namespace internal {
106

Callers 1

tree_test.cppFile · 0.50

Calls 1

Tested by

no test coverage detected