Skip to content

drop is_not_empty from TreeSet/TreeMap #4586

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

Merged
merged 1 commit into from
Jan 23, 2013
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
8 changes: 1 addition & 7 deletions src/libstd/treemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ impl <K: Ord, V> TreeMap<K, V> {
/// Create an empty TreeMap
static pure fn new() -> TreeMap<K, V> { TreeMap{root: None, length: 0} }

/// Return true if the map contains some elements
pure fn is_not_empty(&self) -> bool { self.root.is_some() }

/// Visit all key-value pairs in reverse order
pure fn each_reverse(&self, f: fn(&K, &V) -> bool) {
Expand Down Expand Up @@ -176,7 +174,7 @@ impl <K: Ord, V> TreeMapIterator<K, V> {
/// tuple with a reference to the key and value. If there are no
/// more nodes, return `None`.
fn next(&mut self) -> Option<(&self/K, &self/V)> {
while self.stack.is_not_empty() || self.node.is_some() {
while !self.stack.is_empty() || self.node.is_some() {
match *self.node {
Some(ref x) => {
self.stack.push(x);
Expand Down Expand Up @@ -240,9 +238,6 @@ impl <T: Ord> TreeSet<T> {
/// Create an empty TreeSet
static pure fn new() -> TreeSet<T> { TreeSet{map: TreeMap::new()} }

/// Return true if the set contains some elements
pure fn is_not_empty(&self) -> bool { self.map.is_not_empty() }

/// Visit all values in reverse order
pure fn each_reverse(&self, f: fn(&T) -> bool) {
self.map.each_key_reverse(f)
Expand Down Expand Up @@ -675,7 +670,6 @@ mod test_treemap {

fn check_equal<K: Eq Ord, V: Eq>(ctrl: &[(K, V)], map: &TreeMap<K, V>) {
assert ctrl.is_empty() == map.is_empty();
assert ctrl.is_not_empty() == map.is_not_empty();
for ctrl.each |x| {
let &(k, v) = x;
assert map.find(&k).unwrap() == &v
Expand Down