测试类
package jsj.hhtc.ds.ILinearlist.test;
import jsj.hhtc.ds.ILinearlist.SeqList;
public class TestSeqList2 {
public static void main(String[] args) {
SeqList<Integer> seqlist = new SeqList<Integer>(Integer.class, 10);
printseq(seqlist);
seqlist.insert(1,10);
seqlist.insert(3,20);
seqlist.insert(1,30);
seqlist.insert(1,40);
seqlist.insert(4,50);
printseq(seqlist);
}
private static void printseq(SeqList<Integer> seqlist) {
if(seqlist.getSize()<1){
System.out.println("没有任何元素");
return;
}
System.out.println("顺序线性表中的元素如下:");
for(int i=1;i<=seqlist.getSize();i++){
Integer e = seqlist.getData()[i-1];
System.out.print(e+" ");
}
System.out.println();
}
}

package jsj.hhtc.ds.ILinearlist.test;
import jsj.hhtc.ds.ILinearlist.SeqList;
public class TestSeqList2 {
public static void main(String[] args) {
SeqList<Integer> seqlist = new SeqList<Integer>(Integer.class, 10);
printseq(seqlist);
seqlist.insert(1,10);
seqlist.insert(3,20);
seqlist.insert(1,30);
seqlist.insert(1,40);
seqlist.insert(4,50);
printseq(seqlist);
}
private static void printseq(SeqList<Integer> seqlist) {
if(seqlist.getSize()<1){
System.out.println("没有任何元素");
return;
}
System.out.println("顺序线性表中的元素如下:");
for(int i=1;i<=seqlist.getSize();i++){
Integer e = seqlist.getData()[i-1];
System.out.print(e+" ");
}
System.out.println();
}
}