doublylinkedlist.java

来自「手机游戏」· Java 代码 · 共 55 行

JAVA
55
字号
// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   DoublyLinkedList.java

package matchit2;


// Referenced classes of package matchit2:
//            ListItem

class DoublyLinkedList
{

    DoublyLinkedList()
    {
    }

    boolean isEmpty()
    {
        return head.next == null;
    }

    ListItem getFirst()
    {
        return head.next;
    }

    ListItem getNext(ListItem li)
    {
        if(li.next == null && li.prev == null)
            throw new IllegalArgumentException("getNext from item not in list");
        else
            return li.next;
    }

    void remove(ListItem li)
    {
        li.remove();
    }

    void addFirst(ListItem li)
    {
        if(li.next != null || li.prev != null)
            throw new IllegalArgumentException("addFirst item already in list");
        li.next = head.next;
        if(li.next != null)
            li.next.prev = li;
        li.prev = head;
        head.next = li;
    }

    private final ListItem head = new ListItem();
}

⌨️ 快捷键说明

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