0
点赞
收藏
分享

微信扫一扫

数据结构44-链表update方法实现

LinkList.prototype.update = function (position,newData) {
if (position < 0 || position >= this.length) return false;
//获取对应的data
var current = this.head;
var index = 0;
while (index++ < position) {
current = current.next;
}
//将数据替换
current.data=newData;
return true
};



举报

相关推荐

0 条评论