📄 list.java
字号:
import java.awt.*;
import java.awt.event.*;
import asd.Inform;
class ListNode {
Inform data;
ListNode next;
ListNode( Inform idata , ListNode nextNode )
{
data = idata;
next = nextNode;
}
}
public class List {
private ListNode head;
private ListNode tail;
private String name;
public List( String s )
{
name = s;
head = tail = null;
}
public List()
{
this( "List" );
}
public void insertAtFront( Inform insertItem )
{
if ( isEmpty() )
head = tail = new ListNode( insertItem , null );
else
head = new ListNode( insertItem ,head );
}
public void insertAtBack ( Inform insertItem )
{
if ( isEmpty() )
head = tail = new ListNode( insertItem , null );
else
tail = tail.next = new ListNode( insertItem ,null );
}
public Inform removeFromFront()
{
Inform removeItem = null;
removeItem = head.data;
if ( head.equals(tail) )
head = tail = null;
else
head = head.next;
return removeItem;
}
public Inform Remove ( Inform item )
{
Inform removeItem = null;
if( head.equals(tail ) )
head = tail = null;
else{
ListNode current = head;
while (current.data != item )
current = current.next;
removeItem = current.data;
}
return removeItem;
}
public boolean isEmpty()
{ return head == null;}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -