TAILIEUCHUNG - HandBooks Professional Java-C-Scrip-SQL part 55

Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 55', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | defines operator . It implements this operator in a generic fashion by using operator for the parameterizing type. Then the class some_class wishing to utilize the services of equivalent derives from it and passes itself as equivalent s template parameter. Therefore the resulting operator is defined for the type some_class implemented in terms of some_class s operator . That s all there is to the Barton-Nackmann trick. This is a simple yet immensely useful pattern quite beautiful in its elegance. Strict Weak Ordering I have already mentioned strict weak orderings twice in this book and if you re not familiar with what they are this brief digression should help. A strict weak ordering is a relation between two objects. First let s get a bit theoretical and then we can make it more concrete. For a function f a b that implements a strict weak ordering with a and b being two objects of the same type we say that a and b are equivalent if f a b is false and f b a is false. This means that a does not precede b and b does not precede a. We can thus consider them to be equivalent. Furthermore f a a must always yield false 5 and if f a b is true then f b a must be false. 6 Also if f a b and f b c is true then so is f a c . 7 Finally if f a b is false and f b a is false and if f b c is false and f c b is false then f a c is false and f c a is false. 8 5 This is irreflexivity. 6 This is antisymmetry. 7 This is transitivity. 8 This is transitivity of equivalence. Applying the preceding to our previous example with the class thing can help clarify the theory. The less than comparison for things is implemented in terms of less than for std string. This in turn is a lexicographical comparison. So given a thing a containing the string First a thing b containing the string Second and a thing c containing the string Third let s assert the earlier definitions and axioms. include cassert include string include boost Definition of class thing omitted int main thing a First

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.