Java数据结构---基于数组的表__教程 |
|
日期:2007-5-20 0:37:03 人气:88 [大 中 小] |
|
|
|
System.err.println("Can't insert in a full list!!"); } else{ list[length]=insertItem.getCopy(); length++; } } public void removeAt(int location){ if(location<0||location>=length){ System.err.println("The location you want to remove is out of range!!"); } else{ for(int i=location;i list[i]=list[i+1]; } list[length]=null; length--; } } public DataElement retrieveAt(int location){ if(location<0||location>=length){ System.err.println("The location of item to be retrieved is out of range!!"); return null; } else{ return list[location].getCopy(); } } public void replacAt(int location,DataElement repItem){ if(location<0||location>=length) System.out.println("The position of item to be replaced is out of range!!"); else list[location]=repItem.getCopy(); } public void clearList(){ for(int i=0;i list[i]=null; } length=0; System.gc(); } public void copyList(ArrayListClass otherList){ if(this!=otherList){ for(int i=0;i list[i]=null; System.gc(); maxSize=otherList.maxSize; length=otherList.length; list=new DataElement[maxSize]; for(int j=0;j list[j]=otherList.list[j].getCopy(); } } |
|
出处:本站原创 作者:佚名 |
|
|