Skip to content

Commit 3e6d4cf

Browse files
sfackleralexcrichton
authored andcommitted
---
yaml --- r: 150821 b: refs/heads/try2 c: c7325bd h: refs/heads/master i: 150819: 9562106 v: v3
1 parent 5c72d3e commit 3e6d4cf

File tree

4 files changed

+12
-45
lines changed

4 files changed

+12
-45
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 54ec04f1c12c7fb4dbe5f01fdeb73d1079fef53d
8+
refs/heads/try2: c7325bdd8e29d57e7bc971b86accfb352c4262bc
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcollections/hashmap.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,43 +1424,28 @@ impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Eq for HashSet<T, H> {
14241424
}
14251425

14261426
impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Container for HashSet<T, H> {
1427-
/// Return the number of elements in the set
14281427
fn len(&self) -> uint { self.map.len() }
14291428
}
14301429

14311430
impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Mutable for HashSet<T, H> {
1432-
/// Clear the set, removing all values.
14331431
fn clear(&mut self) { self.map.clear() }
14341432
}
14351433

14361434
impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Set<T> for HashSet<T, H> {
1437-
/// Return true if the set contains a value
14381435
fn contains(&self, value: &T) -> bool { self.map.search(value).is_some() }
14391436

1440-
/// Return true if the set has no elements in common with `other`.
1441-
/// This is equivalent to checking for an empty intersection.
14421437
fn is_disjoint(&self, other: &HashSet<T, H>) -> bool {
14431438
self.iter().all(|v| !other.contains(v))
14441439
}
14451440

1446-
/// Return true if the set is a subset of another
14471441
fn is_subset(&self, other: &HashSet<T, H>) -> bool {
14481442
self.iter().all(|v| other.contains(v))
14491443
}
1450-
1451-
/// Return true if the set is a superset of another
1452-
fn is_superset(&self, other: &HashSet<T, H>) -> bool {
1453-
other.is_subset(self)
1454-
}
14551444
}
14561445

14571446
impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> MutableSet<T> for HashSet<T, H> {
1458-
/// Add a value to the set. Return true if the value was not already
1459-
/// present in the set.
14601447
fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()) }
14611448

1462-
/// Remove a value from the set. Return true if the value was
1463-
/// present in the set.
14641449
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
14651450
}
14661451

branches/try2/src/libcollections/treemap.rs

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -573,74 +573,54 @@ impl<T: Ord + TotalOrd> Ord for TreeSet<T> {
573573
}
574574

575575
impl<T: TotalOrd> Container for TreeSet<T> {
576-
/// Return the number of elements in the set
577576
#[inline]
578577
fn len(&self) -> uint { self.map.len() }
579-
580-
/// Return true if the set contains no elements
581-
#[inline]
582-
fn is_empty(&self) -> bool { self.map.is_empty() }
583578
}
584579

585580
impl<T: TotalOrd> Mutable for TreeSet<T> {
586-
/// Clear the set, removing all values.
587581
#[inline]
588582
fn clear(&mut self) { self.map.clear() }
589583
}
590584

591585
impl<T: TotalOrd> Set<T> for TreeSet<T> {
592-
/// Return true if the set contains a value
593586
#[inline]
594587
fn contains(&self, value: &T) -> bool {
595588
self.map.contains_key(value)
596589
}
597590

598-
/// Return true if the set has no elements in common with `other`.
599-
/// This is equivalent to checking for an empty intersection.
600591
fn is_disjoint(&self, other: &TreeSet<T>) -> bool {
601592
self.intersection(other).next().is_none()
602593
}
603594

604-
/// Return true if the set is a subset of another
605-
#[inline]
606595
fn is_subset(&self, other: &TreeSet<T>) -> bool {
607-
other.is_superset(self)
608-
}
609-
610-
/// Return true if the set is a superset of another
611-
fn is_superset(&self, other: &TreeSet<T>) -> bool {
612596
let mut x = self.iter();
613597
let mut y = other.iter();
614598
let mut a = x.next();
615599
let mut b = y.next();
616-
while b.is_some() {
617-
if a.is_none() {
618-
return false
600+
while a.is_some() {
601+
if b.is_none() {
602+
return false;
619603
}
620604

621605
let a1 = a.unwrap();
622606
let b1 = b.unwrap();
623607

624-
match a1.cmp(b1) {
625-
Less => (),
626-
Greater => return false,
627-
Equal => b = y.next(),
608+
match b1.cmp(a1) {
609+
Less => (),
610+
Greater => return false,
611+
Equal => a = x.next(),
628612
}
629613

630-
a = x.next();
614+
b = y.next();
631615
}
632616
true
633617
}
634618
}
635619

636620
impl<T: TotalOrd> MutableSet<T> for TreeSet<T> {
637-
/// Add a value to the set. Return true if the value was not already
638-
/// present in the set.
639621
#[inline]
640622
fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()) }
641623

642-
/// Remove a value from the set. Return true if the value was
643-
/// present in the set.
644624
#[inline]
645625
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
646626
}

branches/try2/src/libstd/container.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ pub trait Set<T>: Container {
8888
fn is_subset(&self, other: &Self) -> bool;
8989

9090
/// Return true if the set is a superset of another
91-
fn is_superset(&self, other: &Self) -> bool;
91+
fn is_superset(&self, other: &Self) -> bool {
92+
other.is_subset(self)
93+
}
9294

9395
// FIXME #8154: Add difference, sym. difference, intersection and union iterators
9496
}

0 commit comments

Comments
 (0)