- // Now put the indices of the unused directory entries in the array.
- if num_used == 0 {
- for i in 0..NUM_SECTORS {
- iter.indices[i] = i as u16;
- }
- } else {
- let latest_used = iter.indices[0] as usize;
- let mut offset_unused = num_used;
-
- // First put the entries that come after the latest one in use...
- for i in (latest_used + 1)..NUM_SECTORS {
- let sector_header = &iter.sector_header[i];
-
- if !sector_header.is_in_use() {
- iter.indices[offset_unused] = i as u16;
- offset_unused += 1;
- }
- }
-
- // ... then wrap around if necessary.
- for i in 0..latest_used {
- let sector_header = &iter.sector_header[i];
+ for i in (1..num_elts_to_sort).rev() {
+ self.indices.swap(0, i);