首页 > 其他分享 >数据结构55-append方法实现代码

数据结构55-append方法实现代码

时间:2023-02-10 14:34:07浏览次数:41  
标签:function head 数据结构 55 next current null data append


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>双向链表</title>
</head>
<body>
<script>
function doubleList(){
this.head=null
this.tail=null
this.length=0

function Node(data){
this.data=data
this.prev=null
this.next=null
}

linkedList.prototype.append=function(data){
var newNode=new Node(data)
if(this.length==0){

this.head=newNode
}else{

var current=this.head
while(current.next){
current=current.next
}
current.next=newNode
}
this.length+=1
}

}
</script>
</body>
</html>

标签:function,head,数据结构,55,next,current,null,data,append
From: https://blog.51cto.com/u_15460007/6049344

相关文章