linearlink.java
来自「基本数据结构」· Java 代码 · 共 37 行
JAVA
37 行
package LinearLink;
import DuoLink.*;
public class LinearLink extends DuoLinkList implements LinearLinkList
{
private DuoLinkItem Start=null;
private DuoLinkItem End=null;
private DuoLinkItem Current=null;
public LinearLink(Object item) {
super(item);
if(item!=null)
{
Current=Start=End=new DuoLinkItem(item);
}
}
public LinearLink linearization(LinearLink List)
{
Object temp;
Object[] newItems=new Object[List.getLength(List.getFirst())];
System.arraycopy(List.getItemArray(), 0, newItems, 0, List.getLength(List.getFirst()));
for(int i=0;i<List.getLength(List.getFirst());i++)
{
for(int j=i+1;j<List.getLength(List.getFirst());j++)
{
if(newItems[i]>newItems[j])
{
temp=newItems[i];
newItems[i]=newItems[j];
newItems[j]=temp;
}
}
}
LinearLink newList=new LinearLink(newItems[0]);
newList.intl(newItems);
return newList;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?