⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 indexrecord.java

📁 Disk simulation program. Simulates file-system with direct access.
💻 JAVA
字号:
public class IndexRecord
{
    public static final int SECTOR_NUMBER_LENGTH = 7;
    private int keyLength;
    private char[] key;
    private char[] sectorNumber;

    public IndexRecord(int keyLength, char[] data)
    {
        this.keyLength = keyLength;
        this.key = new char[this.keyLength];
        this.sectorNumber = new char[SECTOR_NUMBER_LENGTH];

        System.arraycopy(data, 0, this.key, 0, this.keyLength);
        System.arraycopy(data, this.keyLength, this.sectorNumber, 0, SECTOR_NUMBER_LENGTH);

        this.key[this.keyLength - 1] = '\0';
        this.sectorNumber[this.sectorNumber.length - 1] = '\0';

    }

    public IndexRecord(int keyLength, char[] key, char[] sectorNumber)
    {
        this.keyLength = keyLength;
        this.key = new char[this.keyLength];
        this.sectorNumber = new char[SECTOR_NUMBER_LENGTH];
        System.arraycopy(key, 0, this.key, 0, Math.min(this.keyLength, key.length));
        System.arraycopy(sectorNumber, 0, this.sectorNumber, 0, Math.min(SECTOR_NUMBER_LENGTH, sectorNumber.length));
        this.key[this.keyLength - 1] = '\0';
        this.sectorNumber[this.sectorNumber.length - 1] = '\0';
    }

    public char[] getKey()
    {
        return key;
    }

    public void setKey(char[] key)
    {
        this.key = key;
    }

    public char[] getSectorNumber()
    {
        return sectorNumber;
    }

    public void setSectorNumber(char[] sectorNumber)
    {
        this.sectorNumber = sectorNumber;
    }

    public char[] getData()
    {
        char[] data = new char[this.keyLength + SECTOR_NUMBER_LENGTH];
        System.arraycopy(this.key, 0, data, 0, this.keyLength);
        System.arraycopy(this.sectorNumber, 0, data, this.keyLength, SECTOR_NUMBER_LENGTH);
        return data;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -