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

📄 unorderedlinkedlist.java

📁 这是有关java的应用 通过事例对java数据结构的链表的应用
💻 JAVA
字号:


package 音像店;


public class UnorderedLinkedList extends LinkedListClass {
    
    public UnorderedLinkedList(UnorderedLinkedList otherList) 
    {
        super(otherList);
    }
    public UnorderedLinkedList() 
    {
        super();
    }
    public boolean search(DataElement searchItem)//搜索链表
    {
        LinkedListNode current;
        boolean found;
        current=first;
        found=false;
        while(current !=null && !found)
           if(current.info.equals(searchItem)) found=true;
           else
               current=current.link;
        return found;
    }
    public void deleteNode(DataElement deleteItem)
    {
        LinkedListNode current;
        LinkedListNode trailCurrent;
        boolean found;
        if(first==null) System.err.println("Cannot delete from an empty list. ");
        else
        {
            if(first.info.equals(deleteItem))
            {
                first=first.link;
                if(first==null) last=null;
                count--;
            }
            else
            {
                found=false;
                trailCurrent=first;
                current=first.link;
                while(current!=null && !found)
                {
                    if(current.info.equals(deleteItem)) found=true;
                    else
                    {
                        trailCurrent=current;
                        current=current.link;
                    }
                }//end while
                if(found)
                {
                    count--;
                    trailCurrent.link=current.link;
                    if(last==current) last=trailCurrent;
                }
                else System.out.println("Item to be deleted is not in the list");
            }
        }
    }
}

⌨️ 快捷键说明

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