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

📄 holder.java

📁 一个简单的数据库
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package bufferedManager;/** * * @author outlaw */public class Holder {    boolean[] holds;    int size;    int availableNumber;        public Holder(int size)    {        this.size=size;        holds=new boolean[size];        for(int i=0;i<size;i++)            holds[i]=false;        availableNumber=size;    }    public int getAvailableNumber()    {        return availableNumber;    }    public boolean isFull()    {        if(getAvailableNumber()==0)            return true;        return false;    }    public void setHold(int index)    {        holds[index]=true;        availableNumber--;    }    public void setNotHold(int index)    {        holds[index]=false;        availableNumber++;    }    public boolean isHold(int index)    {        return holds[index];    }    public int[] getAvailablePos()    {        int[] pos=new int[availableNumber];        for(int i=0,j=0;i<size;i++)        {            if(holds[i]==false)                pos[j++]=i;        }        return pos;    }    public int[] getNotAvailablePos()    {        int[] pos=new int[size-availableNumber];        for(int i=0,j=0;i<size;i++)        {            if(holds[i])                pos[j++]=i;        }        return pos;    }    public boolean[] getHolders()    {        return holds;    }    public int getFirstAvailablePos()    {        for(int i=0;i<holds.length;i++)        {            if(!holds[i])                return i;        }        return -1;    }}

⌨️ 快捷键说明

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