Skip to content

Update set operations documentation #39708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions src/libcollections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ impl<T: Ord> BTreeSet<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
///
Expand All @@ -315,7 +317,9 @@ impl<T: Ord> BTreeSet<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
///
Expand Down Expand Up @@ -343,7 +347,9 @@ impl<T: Ord> BTreeSet<T> {
}
}

/// 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
///
Expand All @@ -369,7 +375,9 @@ impl<T: Ord> BTreeSet<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
///
Expand Down Expand Up @@ -480,7 +488,7 @@ impl<T: Ord> BTreeSet<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
Expand All @@ -502,7 +510,8 @@ impl<T: Ord> BTreeSet<T> {
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
///
Expand Down Expand Up @@ -544,7 +553,8 @@ impl<T: Ord> BTreeSet<T> {
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
///
Expand Down
20 changes: 13 additions & 7 deletions src/libstd/collections/hash/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ impl<T, S> HashSet<T, S>
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
///
Expand Down Expand Up @@ -321,7 +322,8 @@ impl<T, S> HashSet<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
///
Expand All @@ -348,7 +350,8 @@ impl<T, S> HashSet<T, S>
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
///
Expand All @@ -373,7 +376,8 @@ impl<T, S> HashSet<T, S>
}
}

/// Visit the values representing the union.
/// Visit the values representing the union,
/// i.e. all the values in `self` or `other`, without duplicates.
///
/// # Examples
///
Expand Down Expand Up @@ -489,7 +493,7 @@ impl<T, S> HashSet<T, S>
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
Expand All @@ -511,7 +515,8 @@ impl<T, S> HashSet<T, S>
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
///
Expand All @@ -532,7 +537,8 @@ impl<T, S> HashSet<T, S>
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
///
Expand Down