-
Notifications
You must be signed in to change notification settings - Fork 43
Revise Hashset impl and doc #22
Conversation
Signed-off-by: Weihang Lo <[email protected]>
Signed-off-by: Weihang Lo <[email protected]>
Signed-off-by: Weihang Lo <[email protected]>
Signed-off-by: Weihang Lo <[email protected]>
Signed-off-by: Weihang Lo <[email protected]>
Signed-off-by: Weihang Lo <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍👍👍👍
|
|
||
| let subset: HashSet<_> = ["cat"].iter().cloned().collect(); | ||
| assert_eq!(set.partial_cmp(&subset), Some(Ordering::Greater)); | ||
| assert_eq!(&set > &subset, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
怎麼感覺這邊漏兩個 XD
assert_eq!(&set >= &subset, true);
assert_eq!(&set <= &subset, false);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
因為 line 770 已經闡明一切
(反正都一樣跑 partial_cmp XD)
| 與相等關係相同,Rust 的排序關係同樣有理論依據,`Ord` 是數學上的 [Total order][wiki-total-ord],符合反對稱性、傳遞性,以及 [connex relation][wiki-connex-relation];而 `ParitalOrd` 則接近數學上的 partial order,Rust 的文件中描述該 trait 須符合反對稱性與傳遞性。 | ||
| > Connex relation:在集合 X 下,所有 (x, y) pair 都會符合 x ∼ y 或 y ∼ x 的關係。在排序關係上,意指不是 x ≥ y 就是 y ≥ x。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不是 x ≥ y 就是 y ≥ x
不太確定可能是我理解錯> < 不過這邊是要說「 不是 x > y 就是 y > x 」嗎,因為 x y 相等時這不是就會同時發生嗎?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
以白話文來說,connex relation 要表達的是在集合 X 下所有元素都可以相互比較,必定有一邊關係成立,不論 x 是否等於 y。定義如下:
∀x∀y (x ∈ X ∧ y ∈ X) ⇒(xRy ∨ yRx )
把「大於等於」抽象為「全序關係」,應該會比較好理解。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
哦哦好像有點懂了~ xRy ﹀ yRx 是 xRy 或 yRx 至少有一個成立,所以你的意思應該是 x ≧ y 或 y ≧ x 至少有一個成立?或是「如果 x 跟 y 的大於等於『關係』 x ≧ y 不成立, y 跟 x 的大於等於『關係』 y ≧ x 就會成立」(而不是 either ... or)
Co-Authored-By: choznerol <[email protected]> Co-Authored-By: weihanglo <[email protected]>
Close #20
HashSet.is_superset,is_subsetandis_disjoint.PartialOrd.I've continue doing on your previous work. Please review these code and documentation. You can read the tutorial directly from here.