linkedbasiclistwithrecclone.java
来自「国外的数据结构与算法分析用书」· Java 代码 · 共 28 行
JAVA
28 行
import dslib.list.*;
/** A variation of LinkedBasicListUos with a recursive implementation of listClone(). */
public class LinkedBasicListWithRecClone extends LinkedBasicListUos
{
/** Construct an empty list. <br>
Analysis: Time = O(1) */
public LinkedBasicListWithRecClone()
{
super();
}
/** Return a list clone of this list. <br>
Analysis: Time = O(k), k = number of items in the list */
public SimpleListUos listClone()
{
if (isEmpty())
return (SimpleListUos) clone();
else
{
SimpleListUos result = ((LinkedBasicListWithRecClone) firstRemainder()).listClone();
result.insertFirst(firstItem());
return result;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?