?? linkedlistclass.java
字號:
public abstract class LinkedListClass {
//definition of the node
protected class LinkedListNode
{
DataElement info;
LinkedListNode link;
}
//實例變量
protected LinkedListNode first;
protected LinkedListNode last;
protected int count;
//構造函數和方法
public LinkedListClass() {
first=null;
last=null;
count=0;
}
public LinkedListClass(LinkedListClass otherList) {
first=otherList.first;
last=otherList.last;
count=otherList.count;
}
public void initializeList()
{
first=null;
last=null;
count=0;
}
public boolean isEmpty()
{
return(first==null);
}
public void print()
{
LinkedListNode current;
current=first;
while(current!=null)
{
System.out.print(current.info+" ");
current=current.link;
}
}
public int length()
{
return count;
}
public DataElement front()
{
DataElement temp=first.info;
return temp;
}
public DataElement back()
{
DataElement temp=last.info;
return temp;
}
public abstract boolean search(DataElement searchItem);
public void insertFirst(DataElement newItem){
LinkedListNode newNode;
newNode=new LinkedListNode();
newNode.info=newItem;
}
public void insertLast(DataElement newItem)
{
LinkedListNode newNode;
newNode=new LinkedListNode();
newNode.info=newItem;
newNode.link=null;
if(first==null)
{
first=newNode;
last=newNode;
}
else
{
last.link=newNode;
last=newNode;
}
count++;
}
public abstract void deleteNode(DataElement deleteItem);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -