赞
踩
function DoubleLinkedList(){ //内部类:节点类 function Node(data){ this.data = data; this.pre = null; this.next = null; } //属性 this.head = null; this.tail = null; this.length = 0 ; //1.append() DoubleLinkedList.prototype.append = function(data){ var newNode = new Node(data); if(this.length === 0){ this.head = newNode; this.tail = newNode; }else{ newNode.pre = this.tail; this.tail.next = newNode; this.tail = newNode; } this.length += 1; } //2.insert() DoubleLinkedList.prototype.insert = function(position,data){ //越界判断 if(position < 0 || position > this.lengh) return false
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。