partial-ordering

Generate a DAG from a poset using stricly functional programming

南笙酒味 提交于 2019-12-09 08:33:50
问题 Here is my problem: I have a sequence S of (nonempty but possibly not distinct) sets s_i, and for each s_i need to know how many sets s_j in S (i ≠ j) are subsets of s_i. I also need incremental performance: once I have all my counts, I may replace one set s_i by some subset of s_i and update the counts incrementally. Performing all this using purely functional code would be a huge plus (I code in Scala). As set inclusion is a partial ordering, I thought the best way to solve my problem would

When is a template more specialized than the other? 'And'/'Or' confusion with logics.

瘦欲@ 提交于 2019-12-03 16:21:10
问题 In 14.8.2.4p10 of the C++11 draft, there is written If for each type being considered a given template is at least as specialized for all types and more specialized for some set of types and the other template is not more specialized for any types or is not at least as specialized for any types, then the given template is more specialized than the other template. Why is there a "or is not at least as specialized for any types"? As far as I can see, if we have a list of types T1, T2, T3 U1, U2

What is the best way to sort a partially ordered list?

这一生的挚爱 提交于 2019-12-03 14:00:00
Probably best illustrated with a small example. Given the relations A < B < C A < P < Q Correct outputs would be ABCPQ or APQBC or APBCQ ... etc. In other words, any ordering is valid in which the given relationships hold. I am most interested in the solution that is easiest to implement, but the best O(n) in speed and time is interesting as well. This is called topological sorting . The standard algorithm is to output a minimal element, then remove it and repeat until done. Do several sorts. First sort according to the first rule, then according to the second one and so on. Should work,

Why is a C++ template accepting an array not more specialized than one accepting a pointer according to GCC 5.3 and Clang 4.0?

此生再无相见时 提交于 2019-12-03 12:27:53
问题 Why are the next two template declarations ambiguous (so neither is more specialized than the other)? I know this question has been raised many times on Stack Overflow, but usually, people answer how to resolve ambiguity, not why it's happened. I. template <class T> void func(char* buf, T size) {} II. template <std::size_t N> void func(char (&buf)[N], std::size_t size) {} Trying to pass steps of the C++14 standard to resolve partial function template ordering (14.5.6.2): To produce the

Generate a DAG from a poset using stricly functional programming

試著忘記壹切 提交于 2019-12-03 10:55:16
Here is my problem: I have a sequence S of (nonempty but possibly not distinct) sets s_i, and for each s_i need to know how many sets s_j in S (i ≠ j) are subsets of s_i. I also need incremental performance: once I have all my counts, I may replace one set s_i by some subset of s_i and update the counts incrementally. Performing all this using purely functional code would be a huge plus (I code in Scala). As set inclusion is a partial ordering, I thought the best way to solve my problem would be to build a DAG that would represent the Hasse diagram of the sets, with edges representing

When is a template more specialized than the other? 'And'/'Or' confusion with logics.

旧街凉风 提交于 2019-12-03 05:38:27
In 14.8.2.4p10 of the C++11 draft, there is written If for each type being considered a given template is at least as specialized for all types and more specialized for some set of types and the other template is not more specialized for any types or is not at least as specialized for any types, then the given template is more specialized than the other template. Why is there a "or is not at least as specialized for any types"? As far as I can see, if we have a list of types T1, T2, T3 U1, U2, U3 And if all Ts are at least as specialized and some are more specialized. And none of the Us are

Why is a C++ template accepting an array not more specialized than one accepting a pointer according to GCC 5.3 and Clang 4.0?

我与影子孤独终老i 提交于 2019-12-03 02:02:09
Why are the next two template declarations ambiguous (so neither is more specialized than the other)? I know this question has been raised many times on Stack Overflow, but usually, people answer how to resolve ambiguity, not why it's happened. I. template <class T> void func(char* buf, T size) {} II. template <std::size_t N> void func(char (&buf)[N], std::size_t size) {} Trying to pass steps of the C++14 standard to resolve partial function template ordering (14.5.6.2): To produce the transformed template, for each type, non-type, or template template parameter (including template parameter

PartialOrdering, StrictWeakOrdering, TotalOrdering, what's the main difference in application

孤者浪人 提交于 2019-12-01 06:47:47
[SGI official document] Because of irreflexivity and transitivity, operator< always satisfies the definition of a partial ordering. The definition of a strict weak ordering is stricter, and the definition of a total ordering is stricter still. And I also read the definition of strict weak ordering in the document: StrictWeakOrdering The first three axioms, irreflexivity, antisymmetry, and transitivity, are the definition of a partial ordering; transitivity of equivalence is required by the definition of a strict weak ordering. A total ordering is one that satisfies an even stronger condition:

Merging two partial (jointly overdetermined) sets of ordering information

只愿长相守 提交于 2019-11-30 17:20:59
问题 I have a web app with data in a grid. The user can reorder the columns, and the server can change which columns exist. I would like to save the user's column order in a cookie and restore it on page load. More formally, I have two arrays of unique IDs (strings) called user_columns and server_columns . I would like to reorder server_columns such that I respect all of the ordering information from user_columns , and as much from server_columns as possible. How do I do this? What's a reasonable

Class template specialization partial ordering and function synthesis

微笑、不失礼 提交于 2019-11-30 06:20:36
问题 The rules for picking which class template specialization is preferred involve rewriting the specializations into function templates and determining which function template is more specialized via the ordering rules for function templates [temp.class.order]. Consider this example, then: #include <iostream> template <class T> struct voider { using type = void; }; template <class T> using void_t = typename voider<T>::type; template <class T, class U> struct A { }; template <class T> int foo(A<T