]> git.lizzy.rs Git - rust.git/commitdiff
Update set operations documentation
authorJethro Beekman <jethro@jbeekman.nl>
Thu, 9 Feb 2017 22:16:16 +0000 (14:16 -0800)
committerJethro Beekman <jethro@jbeekman.nl>
Thu, 9 Feb 2017 22:16:16 +0000 (14:16 -0800)
Reminding people of set terminology.

src/libcollections/btree/set.rs
src/libstd/collections/hash/set.rs

index bfffa0b8efa1cb074168f78c6217055e5371caed..e3c990c80decfc9ce7a075a0d4305a2b241454f6 100644 (file)
@@ -289,7 +289,9 @@ pub fn range<K: ?Sized, R>(&self, range: R) -> Range<T>
 }
 
 impl<T: Ord> BTreeSet<T> {
-    /// Visits the values representing the difference, in ascending order.
+    /// Visits the values representing the difference,
+    /// i.e. the values that are in `self` but not in `other`,
+    /// in ascending order.
     ///
     /// # Examples
     ///
@@ -315,7 +317,9 @@ pub fn difference<'a>(&'a self, other: &'a BTreeSet<T>) -> Difference<'a, T> {
         }
     }
 
-    /// Visits the values representing the symmetric difference, in ascending order.
+    /// Visits the values representing the symmetric difference,
+    /// i.e. the values that are in `self` or in `other` but not in both,
+    /// in ascending order.
     ///
     /// # Examples
     ///
@@ -343,7 +347,9 @@ pub fn symmetric_difference<'a>(&'a self,
         }
     }
 
-    /// Visits the values representing the intersection, in ascending order.
+    /// Visits the values representing the intersection,
+    /// i.e. the values that are both in `self` and `other`,
+    /// in ascending order.
     ///
     /// # Examples
     ///
@@ -369,7 +375,9 @@ pub fn intersection<'a>(&'a self, other: &'a BTreeSet<T>) -> Intersection<'a, T>
         }
     }
 
-    /// Visits the values representing the union, in ascending order.
+    /// Visits the values representing the union,
+    /// i.e. all the values in `self` or `other`, without duplicates,
+    /// in ascending order.
     ///
     /// # Examples
     ///
@@ -480,7 +488,7 @@ pub fn get<Q: ?Sized>(&self, value: &Q) -> Option<&T>
         Recover::get(&self.map, value)
     }
 
-    /// Returns `true` if the set has no elements in common with `other`.
+    /// Returns `true` if `self` has no elements in common with `other`.
     /// This is equivalent to checking for an empty intersection.
     ///
     /// # Examples
@@ -502,7 +510,8 @@ pub fn is_disjoint(&self, other: &BTreeSet<T>) -> bool {
         self.intersection(other).next().is_none()
     }
 
-    /// Returns `true` if the set is a subset of another.
+    /// Returns `true` if the set is a subset of another,
+    /// i.e. `other` contains at least all the values in `self`.
     ///
     /// # Examples
     ///
@@ -544,7 +553,8 @@ pub fn is_subset(&self, other: &BTreeSet<T>) -> bool {
         true
     }
 
-    /// Returns `true` if the set is a superset of another.
+    /// Returns `true` if the set is a superset of another,
+    /// i.e. `self` contains at least all the values in `other`.
     ///
     /// # Examples
     ///
index a3f7e13bbf9131615f369a5ee328947e1cdfc8b2..d438aa8b3ac9cf53b2c9278f839eaa14d221296c 100644 (file)
@@ -291,7 +291,8 @@ pub fn iter(&self) -> Iter<T> {
         Iter { iter: self.map.keys() }
     }
 
-    /// Visit the values representing the difference.
+    /// Visit the values representing the difference,
+    /// i.e. the values that are in `self` but not in `other`.
     ///
     /// # Examples
     ///
@@ -321,7 +322,8 @@ pub fn difference<'a>(&'a self, other: &'a HashSet<T, S>) -> Difference<'a, T, S
         }
     }
 
-    /// Visit the values representing the symmetric difference.
+    /// Visit the values representing the symmetric difference,
+    /// i.e. the values that are in `self` or in `other` but not in both.
     ///
     /// # Examples
     ///
@@ -348,7 +350,8 @@ pub fn symmetric_difference<'a>(&'a self,
         SymmetricDifference { iter: self.difference(other).chain(other.difference(self)) }
     }
 
-    /// Visit the values representing the intersection.
+    /// Visit the values representing the intersection,
+    /// i.e. the values that are both in `self` and `other`.
     ///
     /// # Examples
     ///
@@ -373,7 +376,8 @@ pub fn intersection<'a>(&'a self, other: &'a HashSet<T, S>) -> Intersection<'a,
         }
     }
 
-    /// Visit the values representing the union.
+    /// Visit the values representing the union,
+    /// i.e. all the values in `self` or `other`, without duplicates.
     ///
     /// # Examples
     ///
@@ -489,7 +493,7 @@ pub fn get<Q: ?Sized>(&self, value: &Q) -> Option<&T>
         Recover::get(&self.map, value)
     }
 
-    /// Returns `true` if the set has no elements in common with `other`.
+    /// Returns `true` if `self` has no elements in common with `other`.
     /// This is equivalent to checking for an empty intersection.
     ///
     /// # Examples
@@ -511,7 +515,8 @@ pub fn is_disjoint(&self, other: &HashSet<T, S>) -> bool {
         self.iter().all(|v| !other.contains(v))
     }
 
-    /// Returns `true` if the set is a subset of another.
+    /// Returns `true` if the set is a subset of another,
+    /// i.e. `other` contains at least all the values in `self`.
     ///
     /// # Examples
     ///
@@ -532,7 +537,8 @@ pub fn is_subset(&self, other: &HashSet<T, S>) -> bool {
         self.iter().all(|v| other.contains(v))
     }
 
-    /// Returns `true` if the set is a superset of another.
+    /// Returns `true` if the set is a superset of another,
+    /// i.e. `self` contains at least all the values in `other`.
     ///
     /// # Examples
     ///