From 99eb4ddddd68e9ffa86eb8df264934925e27d737 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Tue, 29 Jan 2013 19:30:26 -0500 Subject: add difference and symmetric_difference to Set --- src/libstd/treemap.rs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index b1c22f86c96..235db263542 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -29,10 +29,10 @@ use core::prelude::*; // range search - O(log n) retrieval of an iterator from some key // (possibly) implement the overloads Python does for sets: -// * union: | // * intersection: & // * difference: - // * symmetric difference: ^ +// * union: | // These would be convenient since the methods work like `each` pub struct TreeMap { @@ -355,22 +355,6 @@ impl TreeSet: Set { } true } -} - -impl TreeSet { - /// Create an empty TreeSet - static pure fn new() -> TreeSet { TreeSet{map: TreeMap::new()} } - - /// Visit all values in reverse order - pure fn each_reverse(&self, f: fn(&T) -> bool) { - self.map.each_key_reverse(f) - } - - /// Get a lazy iterator over the values in the set. - /// Requires that it be frozen (immutable). - pure fn iter(&self) -> TreeSetIterator/&self { - TreeSetIterator{iter: self.map.iter()} - } /// Visit the values (in-order) representing the difference pure fn difference(&self, other: &TreeSet, f: fn(&T) -> bool) { @@ -448,6 +432,22 @@ impl TreeSet { } } } +} + +impl TreeSet { + /// Create an empty TreeSet + static pure fn new() -> TreeSet { TreeSet{map: TreeMap::new()} } + + /// Visit all values in reverse order + pure fn each_reverse(&self, f: fn(&T) -> bool) { + self.map.each_key_reverse(f) + } + + /// Get a lazy iterator over the values in the set. + /// Requires that it be frozen (immutable). + pure fn iter(&self) -> TreeSetIterator/&self { + TreeSetIterator{iter: self.map.iter()} + } /// Visit the values (in-order) representing the intersection pure fn intersection(&self, other: &TreeSet, f: fn(&T) -> bool) { -- cgit 1.4.1-3-g733a5