public class Test{
public Status insert(int i , Object o){ //i是插入位置的索引
//先判断数组是否为空引入空指针、i索引是否合法、插入后会不会越界
if(myList == null || i<0 || i>myList.length ||( myList.MAX_LENGTH ==myList.length) return Status.WRONG;
for( int j = myList.length +1 ; j> i ; j -- ) {
myList[j] = myList[j-1];
}
myList[i] = o ;
++myList.length ;
return Status.OK;
}
}
数组实现顺序结构链表的insert
最新推荐文章于 2022-12-13 15:09:10 发布