Skip to content

Commit 330d478

Browse files
author
blake2-ppc
committed
---
yaml --- r: 67523 b: refs/heads/master c: e5a64f2 h: refs/heads/master i: 67521: f6df366 67519: 0f5de4e v: v3
1 parent 6475623 commit 330d478

File tree

5 files changed

+72
-104
lines changed

5 files changed

+72
-104
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 310e0b6e92e2a5c48a96a0b5c0951d77e402dd75
2+
refs/heads/master: e5a64f2adddd1ed2ec8e92ec94658b24ece4dbfc
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/src/libextra/bitv.rs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,41 @@ impl BitvSet {
717717
pub fn iter<'a>(&'a self) -> BitvSetIterator<'a> {
718718
BitvSetIterator {set: self, next_idx: 0}
719719
}
720+
721+
pub fn difference(&self, other: &BitvSet, f: &fn(&uint) -> bool) -> bool {
722+
for self.common_iter(other).advance |(i, w1, w2)| {
723+
if !iterate_bits(i, w1 & !w2, |b| f(&b)) {
724+
return false;
725+
}
726+
}
727+
/* everything we have that they don't also shows up */
728+
self.outlier_iter(other).advance(|(mine, i, w)|
729+
!mine || iterate_bits(i, w, |b| f(&b))
730+
)
731+
}
732+
733+
pub fn symmetric_difference(&self, other: &BitvSet,
734+
f: &fn(&uint) -> bool) -> bool {
735+
for self.common_iter(other).advance |(i, w1, w2)| {
736+
if !iterate_bits(i, w1 ^ w2, |b| f(&b)) {
737+
return false;
738+
}
739+
}
740+
self.outlier_iter(other).advance(|(_, i, w)| iterate_bits(i, w, |b| f(&b)))
741+
}
742+
743+
pub fn intersection(&self, other: &BitvSet, f: &fn(&uint) -> bool) -> bool {
744+
self.common_iter(other).advance(|(i, w1, w2)| iterate_bits(i, w1 & w2, |b| f(&b)))
745+
}
746+
747+
pub fn union(&self, other: &BitvSet, f: &fn(&uint) -> bool) -> bool {
748+
for self.common_iter(other).advance |(i, w1, w2)| {
749+
if !iterate_bits(i, w1 | w2, |b| f(&b)) {
750+
return false;
751+
}
752+
}
753+
self.outlier_iter(other).advance(|(_, i, w)| iterate_bits(i, w, |b| f(&b)))
754+
}
720755
}
721756

722757
impl cmp::Eq for BitvSet {
@@ -785,41 +820,6 @@ impl Set<uint> for BitvSet {
785820
fn is_superset(&self, other: &BitvSet) -> bool {
786821
other.is_subset(self)
787822
}
788-
789-
fn difference(&self, other: &BitvSet, f: &fn(&uint) -> bool) -> bool {
790-
for self.common_iter(other).advance |(i, w1, w2)| {
791-
if !iterate_bits(i, w1 & !w2, |b| f(&b)) {
792-
return false;
793-
}
794-
}
795-
/* everything we have that they don't also shows up */
796-
self.outlier_iter(other).advance(|(mine, i, w)|
797-
!mine || iterate_bits(i, w, |b| f(&b))
798-
)
799-
}
800-
801-
fn symmetric_difference(&self, other: &BitvSet,
802-
f: &fn(&uint) -> bool) -> bool {
803-
for self.common_iter(other).advance |(i, w1, w2)| {
804-
if !iterate_bits(i, w1 ^ w2, |b| f(&b)) {
805-
return false;
806-
}
807-
}
808-
self.outlier_iter(other).advance(|(_, i, w)| iterate_bits(i, w, |b| f(&b)))
809-
}
810-
811-
fn intersection(&self, other: &BitvSet, f: &fn(&uint) -> bool) -> bool {
812-
self.common_iter(other).advance(|(i, w1, w2)| iterate_bits(i, w1 & w2, |b| f(&b)))
813-
}
814-
815-
fn union(&self, other: &BitvSet, f: &fn(&uint) -> bool) -> bool {
816-
for self.common_iter(other).advance |(i, w1, w2)| {
817-
if !iterate_bits(i, w1 | w2, |b| f(&b)) {
818-
return false;
819-
}
820-
}
821-
self.outlier_iter(other).advance(|(_, i, w)| iterate_bits(i, w, |b| f(&b)))
822-
}
823823
}
824824

825825
impl MutableSet<uint> for BitvSet {

trunk/src/libextra/treemap.rs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,40 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
396396
}
397397
true
398398
}
399+
}
400+
401+
impl<T: TotalOrd> MutableSet<T> for TreeSet<T> {
402+
/// Add a value to the set. Return true if the value was not already
403+
/// present in the set.
404+
#[inline]
405+
fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()) }
406+
407+
/// Remove a value from the set. Return true if the value was
408+
/// present in the set.
409+
#[inline]
410+
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
411+
}
412+
413+
impl<T: TotalOrd> TreeSet<T> {
414+
/// Create an empty TreeSet
415+
#[inline]
416+
pub fn new() -> TreeSet<T> { TreeSet{map: TreeMap::new()} }
417+
418+
/// Get a lazy iterator over the values in the set.
419+
/// Requires that it be frozen (immutable).
420+
#[inline]
421+
pub fn iter<'a>(&'a self) -> TreeSetIterator<'a, T> {
422+
TreeSetIterator{iter: self.map.iter()}
423+
}
424+
425+
/// Visit all values in reverse order
426+
#[inline]
427+
pub fn each_reverse(&self, f: &fn(&T) -> bool) -> bool {
428+
self.map.each_key_reverse(f)
429+
}
399430

400431
/// Visit the values (in-order) representing the difference
401-
fn difference(&self, other: &TreeSet<T>, f: &fn(&T) -> bool) -> bool {
432+
pub fn difference(&self, other: &TreeSet<T>, f: &fn(&T) -> bool) -> bool {
402433
let mut x = self.iter();
403434
let mut y = other.iter();
404435

@@ -427,7 +458,7 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
427458
}
428459

429460
/// Visit the values (in-order) representing the symmetric difference
430-
fn symmetric_difference(&self, other: &TreeSet<T>,
461+
pub fn symmetric_difference(&self, other: &TreeSet<T>,
431462
f: &fn(&T) -> bool) -> bool {
432463
let mut x = self.iter();
433464
let mut y = other.iter();
@@ -461,7 +492,7 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
461492
}
462493

463494
/// Visit the values (in-order) representing the intersection
464-
fn intersection(&self, other: &TreeSet<T>, f: &fn(&T) -> bool) -> bool {
495+
pub fn intersection(&self, other: &TreeSet<T>, f: &fn(&T) -> bool) -> bool {
465496
let mut x = self.iter();
466497
let mut y = other.iter();
467498

@@ -487,7 +518,7 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
487518
}
488519

489520
/// Visit the values (in-order) representing the union
490-
fn union(&self, other: &TreeSet<T>, f: &fn(&T) -> bool) -> bool {
521+
pub fn union(&self, other: &TreeSet<T>, f: &fn(&T) -> bool) -> bool {
491522
let mut x = self.iter();
492523
let mut y = other.iter();
493524

@@ -519,37 +550,6 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
519550
}
520551
}
521552

522-
impl<T: TotalOrd> MutableSet<T> for TreeSet<T> {
523-
/// Add a value to the set. Return true if the value was not already
524-
/// present in the set.
525-
#[inline]
526-
fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()) }
527-
528-
/// Remove a value from the set. Return true if the value was
529-
/// present in the set.
530-
#[inline]
531-
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
532-
}
533-
534-
impl<T: TotalOrd> TreeSet<T> {
535-
/// Create an empty TreeSet
536-
#[inline]
537-
pub fn new() -> TreeSet<T> { TreeSet{map: TreeMap::new()} }
538-
539-
/// Get a lazy iterator over the values in the set.
540-
/// Requires that it be frozen (immutable).
541-
#[inline]
542-
pub fn iter<'a>(&'a self) -> TreeSetIterator<'a, T> {
543-
TreeSetIterator{iter: self.map.iter()}
544-
}
545-
546-
/// Visit all values in reverse order
547-
#[inline]
548-
pub fn each_reverse(&self, f: &fn(&T) -> bool) -> bool {
549-
self.map.each_key_reverse(f)
550-
}
551-
}
552-
553553
/// Lazy forward iterator over a set
554554
pub struct TreeSetIterator<'self, T> {
555555
priv iter: TreeMapIterator<'self, T, ()>

trunk/src/libstd/container.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,7 @@ pub trait Set<T>: Container {
8787
/// Return true if the set is a superset of another
8888
fn is_superset(&self, other: &Self) -> bool;
8989

90-
/// Visit the values representing the difference
91-
fn difference(&self, other: &Self, f: &fn(&T) -> bool) -> bool;
92-
93-
/// Visit the values representing the symmetric difference
94-
fn symmetric_difference(&self, other: &Self, f: &fn(&T) -> bool) -> bool;
95-
96-
/// Visit the values representing the intersection
97-
fn intersection(&self, other: &Self, f: &fn(&T) -> bool) -> bool;
98-
99-
/// Visit the values representing the union
100-
fn union(&self, other: &Self, f: &fn(&T) -> bool) -> bool;
90+
// FIXME #8154: Add difference, sym. difference, intersection and union iterators
10191
}
10292

10393
/// This trait represents actions which can be performed on sets to mutate

trunk/src/libstd/hashmap.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -672,28 +672,6 @@ impl<T:Hash + Eq> Set<T> for HashSet<T> {
672672
fn is_superset(&self, other: &HashSet<T>) -> bool {
673673
other.is_subset(self)
674674
}
675-
676-
/// Visit the values representing the difference
677-
fn difference(&self, other: &HashSet<T>, f: &fn(&T) -> bool) -> bool {
678-
self.difference_iter(other).advance(f)
679-
}
680-
681-
/// Visit the values representing the symmetric difference
682-
fn symmetric_difference(&self,
683-
other: &HashSet<T>,
684-
f: &fn(&T) -> bool) -> bool {
685-
self.symmetric_difference_iter(other).advance(f)
686-
}
687-
688-
/// Visit the values representing the intersection
689-
fn intersection(&self, other: &HashSet<T>, f: &fn(&T) -> bool) -> bool {
690-
self.intersection_iter(other).advance(f)
691-
}
692-
693-
/// Visit the values representing the union
694-
fn union(&self, other: &HashSet<T>, f: &fn(&T) -> bool) -> bool {
695-
self.union_iter(other).advance(f)
696-
}
697675
}
698676

699677
impl<T:Hash + Eq> MutableSet<T> for HashSet<T> {

0 commit comments

Comments
 (0)