?? linklist.java
字號:
/*
* LinkList.java
*
* Created on 2007年11月14日, 下午3:13
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package idcarda;
/**
*
* @author Administrator
*/
public class LinkList {
private Node head;
/** Creates a new instance of LinkList */
public LinkList() {
head=null;
}
public void insertNode(Node temp){
Node p;
if(head==null)
head=temp;
else{
p=head;
while(p.getNext()!=null){
p=p.getNext();
}
p.setNext(temp);
}
}
public void deleteNode(Node temp){
Node p;
p=preNode(temp);
if(p!=null)
p.setNext(p.getNext().getNext());
else{
if(temp==head)
head=temp.getNext();
else
return;
}
}
public int getLength(){
Node p=null;
int i=0;
p=head;
while(p!=null){
i++;
p=p.getNext();
}
return i;
}
public boolean isEmpty(){
if(getLength()==0)
return true;
else
return false;
}
public Node preNode(Node temp){
Node p=head;
if(getLength()<=1)
return null;
else{
while(p.getNext()!=null){
if(p.getNext()==temp)
return p;
else
p=p.getNext();
}
if(p.getNext()==null)
return null;
}
return null;
}
public String toString(){
Node p=head;
String a="";
while(p!=null){
a=a+p;
p=p.getNext();
}
return a;
}
public Node getHead(){
return head;
}
public Node searchByname(String name){
Node p;
p=head;
while(p!=null&&!p.getData().getName().equals(name)){
p=p.getNext();
}
return p;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -