function Lian(data,pre,next){
    this.data = data;
    this.preNode = pre;
    if(this.preNode ){
      pre.nextNode = this;
    }
    this.nextNode = next;
}
//输入链表
 Lian.prototype.aaa = function(){

       if(this.nextNode){
              return this.data.name + this.nextNode.aaa();
         }else{
              return this.data.name;
          }
    };
 //插入节点
 Lian.prototype.bbb = function(node){
     if(this.nextNode && this.nextNode.preNode){
         this.nextNode.preNode = node;
     }
   node.nextNode = this.nextNode;
     node.preNode = this;
   this.nextNode = node;
 };
//删除节点
 Lian.prototype.ccc = function(){
        this.nextNode.preNode = this.preNode;
        this.preNode.nextNode = this.nextNode;
    };
var q = new Lian({"name": "1"}, null, null);
var w = new Lian({"name": "2"}, q, null);
var e = new Lian({"name": "3"}, w, null);
 var Head = q;
 console.log(Head.aaa());

hdu_bomb
28 声望0 粉丝

« 上一篇
网易内推笔试