Skip to content
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

Document that BTreeMap iteration is in order #31136

Merged
merged 1 commit into from
Jan 23, 2016
Merged
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
20 changes: 10 additions & 10 deletions src/libcollections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1194,17 +1194,17 @@ unsafe fn unwrap_unchecked<T>(val: Option<T>) -> T {
}

impl<K, V> BTreeMap<K, V> {
/// Gets an iterator over the entries of the map.
/// Gets an iterator over the entries of the map, sorted by key.
///
/// # Examples
///
/// ```
/// use std::collections::BTreeMap;
///
/// let mut map = BTreeMap::new();
/// map.insert(1, "a");
/// map.insert(2, "b");
/// map.insert(3, "c");
/// map.insert(2, "b");
/// map.insert(1, "a");
///
/// for (key, value) in map.iter() {
/// println!("{}: {}", key, value);
Expand All @@ -1224,7 +1224,7 @@ impl<K, V> BTreeMap<K, V> {
}
}

/// Gets a mutable iterator over the entries of the map.
/// Gets a mutable iterator over the entries of the map, sorted by key.
///
/// # Examples
///
Expand Down Expand Up @@ -1257,16 +1257,16 @@ impl<K, V> BTreeMap<K, V> {
}
}

/// Gets an iterator over the keys of the map.
/// Gets an iterator over the keys of the map, in sorted order.
///
/// # Examples
///
/// ```
/// use std::collections::BTreeMap;
///
/// let mut a = BTreeMap::new();
/// a.insert(1, "a");
/// a.insert(2, "b");
/// a.insert(1, "a");
///
/// let keys: Vec<_> = a.keys().cloned().collect();
/// assert_eq!(keys, [1, 2]);
Expand All @@ -1276,19 +1276,19 @@ impl<K, V> BTreeMap<K, V> {
Keys { inner: self.iter() }
}

/// Gets an iterator over the values of the map.
/// Gets an iterator over the values of the map, in order by key.
///
/// # Examples
///
/// ```
/// use std::collections::BTreeMap;
///
/// let mut a = BTreeMap::new();
/// a.insert(1, "a");
/// a.insert(2, "b");
/// a.insert(1, "hello");
/// a.insert(2, "goodbye");
///
/// let values: Vec<&str> = a.values().cloned().collect();
/// assert_eq!(values, ["a", "b"]);
/// assert_eq!(values, ["hello", "goodbye"]);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn values<'a>(&'a self) -> Values<'a, K, V> {
Expand Down