0

所以我正在尝试使用数组编写一种磁盘碎片整理方法,一个数组是文件分配表,它充当数据块的链表,另一个是指实际数据,尽管其中没有数据,只是整数值。我目前的想法是将所有值复制到 ArrayList 中,然后写回数组以将“块”打乱,这是我目前所拥有的:

import java.util.ArrayList;
public class Main {
    static int FAT[]            = new int[16]; // File allocation table
    static int dataBlocks[]     = new int[16]; // Datablocks although these represent random values
    static int diskBlocks = 16; // amount of disblocks
    static int dataEnd    = -5;
    static ArrayList<Integer> t = new ArrayList<Integer>(); // temporary array
    public static void main(String args[]){
        for( int i = 0; i< 16; i++){
            FAT[i]  = i+1;  // this referes to the next value in the list
            dataBlocks[i] = i;
            t.add(FAT[i]);  //add the values to a temporary array
            if(i == 10){
                FAT[i + 1] = dataEnd;
                t.set(i, dataEnd);
            }
        }
    }
}

到目前为止,我只是将值添加到我想用来复制它们的 Arrays/Arraylist 中,现在我只需要对它们进行洗牌以制作磁盘碎片整理方法。

4

0 回答 0