summary refs log tree commit diff
path: root/src/librustc_data_structures
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-03-14 16:29:45 +0800
committerkennytm <kennytm@gmail.com>2018-03-15 00:15:46 +0800
commitb5f102c7aee92fb3559a5ed0a207ffaf287f496f (patch)
tree996cf64585aaf6f418d82fd92a96035ba3b591dd /src/librustc_data_structures
parentc65ee94365b3a3545b9eb77d4f528c56f19a23bd (diff)
parentf69a0999e742a6fc45fd4b962c30c56d04c2245c (diff)
downloadrust-b5f102c7aee92fb3559a5ed0a207ffaf287f496f.tar.gz
rust-b5f102c7aee92fb3559a5ed0a207ffaf287f496f.zip
Rollup merge of #48840 - varkor:idxset-cleanup, r=pnkfelix
Remove some unnecessary IdxSet methods

This replaces `IdxSet:: reset_to_empty` with `IdxSet:: clear`, and `IdxSet::elems`/`IdxSet::each_bit` with `IdxSet::iter`. Based on some [comments on #rustc](https://botbot.me/mozilla/rustc/2018-01-23/?msg=96063396).

r? @pnkfelix
Diffstat (limited to 'src/librustc_data_structures')
-rw-r--r--src/librustc_data_structures/indexed_set.rs64
1 files changed, 0 insertions, 64 deletions
diff --git a/src/librustc_data_structures/indexed_set.rs b/src/librustc_data_structures/indexed_set.rs
index 223e08de826..7ab6a269148 100644
--- a/src/librustc_data_structures/indexed_set.rs
+++ b/src/librustc_data_structures/indexed_set.rs
@@ -224,70 +224,6 @@ impl<T: Idx> IdxSet<T> {
             _pd: PhantomData,
         }
     }
-
-    /// Calls `f` on each index value held in this set, up to the
-    /// bound `max_bits` on the size of universe of indexes.
-    pub fn each_bit<F>(&self, max_bits: usize, f: F) where F: FnMut(T) {
-        each_bit(self, max_bits, f)
-    }
-
-    /// Removes all elements from this set.
-    pub fn reset_to_empty(&mut self) {
-        for word in self.words_mut() { *word = 0; }
-    }
-
-    pub fn elems(&self, universe_size: usize) -> Elems<T> {
-        Elems { i: 0, set: self, universe_size: universe_size }
-    }
-}
-
-pub struct Elems<'a, T: Idx> { i: usize, set: &'a IdxSet<T>, universe_size: usize }
-
-impl<'a, T: Idx> Iterator for Elems<'a, T> {
-    type Item = T;
-    fn next(&mut self) -> Option<T> {
-        if self.i >= self.universe_size { return None; }
-        let mut i = self.i;
-        loop {
-            if i >= self.universe_size {
-                self.i = i; // (mark iteration as complete.)
-                return None;
-            }
-            if self.set.contains(&T::new(i)) {
-                self.i = i + 1; // (next element to start at.)
-                return Some(T::new(i));
-            }
-            i = i + 1;
-        }
-    }
-}
-
-fn each_bit<T: Idx, F>(words: &IdxSet<T>, max_bits: usize, mut f: F) where F: FnMut(T) {
-    let usize_bits: usize = mem::size_of::<usize>() * 8;
-
-    for (word_index, &word) in words.words().iter().enumerate() {
-        if word != 0 {
-            let base_index = word_index * usize_bits;
-            for offset in 0..usize_bits {
-                let bit = 1 << offset;
-                if (word & bit) != 0 {
-                    // NB: we round up the total number of bits
-                    // that we store in any given bit set so that
-                    // it is an even multiple of usize::BITS. This
-                    // means that there may be some stray bits at
-                    // the end that do not correspond to any
-                    // actual value; that's why we first check
-                    // that we are in range of bits_per_block.
-                    let bit_index = base_index + offset as usize;
-                    if bit_index >= max_bits {
-                        return;
-                    } else {
-                        f(Idx::new(bit_index));
-                    }
-                }
-            }
-        }
-    }
 }
 
 pub struct Iter<'a, T: Idx> {