if num_elts_to_sort != 0 {
// Sort the used directory entries.
- for i in (1..((num_elts_to_sort + 1) / 2) + 1).rev() {
- downheap(&mut iter.indices, i - 1, num_elts_to_sort - 1,
- iter.sector_header);
- }
-
- for i in (1..num_elts_to_sort).rev() {
- let t = iter.indices[0];
- iter.indices[0] = iter.indices[i];
- iter.indices[i] = t;
-
- downheap(&mut iter.indices, 0, i - 1, iter.sector_header);
- }
+ iter.sort(num_elts_to_sort);
}
// Now put the indices of the unused directory entries in the array.
iter
}
+
+ fn sort(&mut self, num_elts_to_sort: usize) {
+ for i in (1..((num_elts_to_sort + 1) / 2) + 1).rev() {
+ downheap(&mut self.indices, i - 1, num_elts_to_sort - 1,
+ self.sector_header);
+ }
+
+ for i in (1..num_elts_to_sort).rev() {
+ let t = self.indices[0];
+ self.indices[0] = self.indices[i];
+ self.indices[i] = t;
+
+ downheap(&mut self.indices, 0, i - 1, self.sector_header);
+ }
+ }
}
impl<'a> Iterator for SectorHeaderIter<'a> {