17template<std::equality_comparable T>
31 template<
class T1,
class T2>
32 [[nodiscard]]
bool addOrder(T1 a, T2 b);
35 bool anyLeft(
const T2 &R)
const;
38 void clear() { m_Relation.clear(); }
41 bool empty()
const {
return m_Relation.empty(); }
42 template<
class T2,
class F>
43 void getRelated(T2 L, F R, std::size_t maxDepth = 0) const requires std::constructible_from<T,T2> && std::invocable<F,T>;
45 void getRelated(
C_ValList L, F R, std::
size_t maxDepth = 0) const requires std::invocable<F,T>;
46 template<class F, class T2>
47 void getRelated(F L, T2 R, std::
size_t maxDepth = 0) const requires std::constructible_from<T,T2> && std::invocable<F,T>;
49 void getRelated(F L,
C_ValList R, std::
size_t maxDepth = 0) const requires std::invocable<F,T>;
52 bool related(const T &a, const T &b) const;
57 std::list<std::pair<T,T>> m_Relation;
60 bool find(const
C_ValList &src, T t) const;
67template<class C, class T>
74 c.emplace_back(std::forward<T>(value));
80template<std::equality_comparable T>
81template<
class T1,
class T2>
91 for (
auto &i: m_Relation)
92 if (a == i.first && b == i.second)
96 m_Relation.emplace_back(a, b);
100template<std::equality_comparable T>
104 for (
auto &i: m_Relation)
114template<std::equality_comparable T>
124template<std::equality_comparable T>
128 for (
auto &i: m_Relation)
135template<std::equality_comparable T>
139 for (
auto &i: m_Relation)
146template<std::equality_comparable T>
147template<
class T2,
class F>
150 getRelated({1, std::forward<T2>(L)}, R, maxDepth);
153template<std::equality_comparable T>
154template<
class F,
class T2>
157 getRelated(L, {1, std::forward<T2>(R)}, maxDepth);
160template<std::equality_comparable T>
164 std::size_t oldSize = 0;
166 for (std::size_t depth = 0; !maxDepth || depth < maxDepth; ++depth)
168 for (
auto &i: m_Relation)
173 if (oldSize == dst.size())
176 auto iDst = dst.begin();
177 std::advance(iDst, oldSize);
178 L.assign(iDst, dst.end());
179 oldSize = dst.size();
185template<std::equality_comparable T>
189 std::size_t oldSize = 0;
191 for (std::size_t depth = 0; !maxDepth || depth < maxDepth; ++depth)
193 for (
auto &i: m_Relation)
198 if (oldSize == dst.size())
201 auto iDst = dst.begin();
202 std::advance(iDst, oldSize);
203 R.assign(iDst, dst.end());
204 oldSize = dst.size();
210template<std::equality_comparable T>
238 auto mapping = m_Relation;
239 for (
auto &i: mapping)
248 const T t =q.front();
254 for (
auto i = mapping.begin(), end = mapping.end(); i != end;)
259 i = mapping.erase(i);
272 q.splice(q.end(), l);
275 q.splice(q.begin(), l);
281template<std::equality_comparable T>
284 for (
auto i = l.begin(), end = l.end(); i != end;)
293template<std::equality_comparable T>
296 for (
auto &i: m_Relation)
void makeLinear(F apply, E_MakeLinearPolicy policy=MLP_BREADTH_FIRST) const
bool anyLeft(const T2 &R) const
void getRelated(T2 L, F R, std::size_t maxDepth=0) const
std::size_t depthToLeft(T t) const
bool related(const T &a, const T &b) const
bool anyRight(const T2 &L) const
bool addOrder(T1 a, T2 b)
THE common namespace of bux library.
void addUnique(C &c, T &&value)