Skip to content
Closed
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
15 changes: 14 additions & 1 deletion src/libstd/collections/hashmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
//! Unordered containers, implemented as hash-tables (`HashSet` and `HashMap` types)

use clone::Clone;
use cmp::{max, Eq, Equiv, PartialEq};
use cmp;
use cmp::{max, Eq, Equiv, PartialEq, PartialOrd, Ordering};
use collections::{Collection, Mutable, Set, MutableSet, Map, MutableMap};
use default::Default;
use fmt::Show;
Expand Down Expand Up @@ -1499,6 +1500,18 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> PartialEq for HashSet<T, H> {

impl<T: Eq + Hash<S>, S, H: Hasher<S>> Eq for HashSet<T, H> {}

impl<T: Eq + Hash<S>, S, H: Hasher<S>> PartialOrd for HashSet<T, H> {
#[inline]
fn partial_cmp(&self, other: &HashSet<T, H>) -> Option<Ordering> {
match (self.is_subset(other), other.is_subset(self)) {
(true, true) => Some(cmp::Equal),
(true, false) => Some(cmp::Less),
(false, true) => Some(cmp::Greater),
(false, false) => None
}
}
}

impl<T: Eq + Hash<S>, S, H: Hasher<S>> Collection for HashSet<T, H> {
fn len(&self) -> uint { self.map.len() }
}
Expand Down