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

📄 intdllist.java

📁 数据结构与算法Java语言版(美)Adam Drozdek著
💻 JAVA
字号:
//************************  IntDLList.java  ***************************/public class IntDLList {    private IntDLLNode head, tail;    public IntDLList() {        head = tail = null;    }    public boolean isEmpty() {        return head == null;    }    public void setToNull() {        head = tail = null;    }    public int firstEl() {        if (!isEmpty())             return head.info;        else return 0;    }    public void addToDLListHead(int el) {        if (!isEmpty()) {             head = new IntDLLNode(el,head,null);             head.next.prev = head;        }        else head = tail = new IntDLLNode(el);    }    public void addToDLListTail(int el) {        if (!isEmpty()) {             tail = new IntDLLNode(el,null,tail);             tail.prev.next = tail;        }        else head = tail = new IntDLLNode(el);    }    public int deleteFromDLListHead() {        if (!isEmpty()) {        // if at least one node in the list;             int el = head.info;             if (head == tail)   // if only one node in the list;                  head = tail = null;             else {              // if more than one node in the list;                  head = head.next;                  head.prev = null;             }             return el;        }        else return 0;    }    public int deleteFromDLListTail() {        if (!isEmpty()) {             int el = tail.info;             if (head == tail)   // if only one node on the list;                  head = tail = null;             else {              // if more than one node in the list;                  tail = tail.prev;                  tail.next = null;             }             return el;        }        else return 0;    }    public void printAll() { //OutputStream Out) {        for (IntDLLNode tmp = head; tmp != null; tmp = tmp.next)             System.out.print(tmp.info + " ");    }    public int find(int el) {        IntDLLNode tmp;        for (tmp = head; tmp != null && tmp.info != el; tmp = tmp.next);        if (tmp == null)             return 0;        else return tmp.info;    }}

⌨️ 快捷键说明

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