public class SqeList{
/* 初始空间为10 */
private static final int LIST_SIZE = 10;
/* 数组data用来存放元素 */
private int[] data;
/* 当前表长,实际存储元素的个数 */
private int length;
}
public void insertElem(SeqList list, int i, int node) {
if (i < 1 || i > list.length + 1) {
System.out.println("position error");
return;
}
if (list.length >= LIST_SIZE) {
System.out.println("overflow");
return;
}
for (int j = list.length - 1; j >= i - 1; j --) {
/* 从最后一个元素开始逐一后移 */
list.data[j+1] = list.data[j];
}
/* 插入新元素 */
list.data[i-1] = node;
/* 表长加1 */
list.length ++;
}
public void delElem(SqeList list, int i){
if(i<0 || i>list.length()){return error}
for(int j =i;j<list.length,j++)
{list.data[j-1]=list.data[j]}
list.ength--:
}
public int getElem(SqeList list, int i){
if(i<0 || i>list.length()){return error}
return list.data[i]
}