การใช้งาน JavaScript ของรายการที่เชื่อมโยงเดียว (LinkedList)
ห้องสมุดที่เกี่ยวข้องกับ NPMJS:
รายการที่ซับซ้อนรายการอัจฉริยะ
แนวคิดการเขียนโปรแกรม:
การใช้งานของคุณเอง:
singlenode.js
(function () {"ใช้อย่างเข้มงวด"; ฟังก์ชันโหนด (องค์ประกอบ) {this.element = element; this.next = null;} module.exports = node;}) ();linkedList.js
(function () {"ใช้อย่างเข้มงวด"; var node = ต้องการ ("./ lib/singlenode"); ฟังก์ชั่น linkedList () {this._head = โหนดใหม่ ("นี่คือโหนดหัว"); this._size = 0; ฟังก์ชั่น () {return this._size; LinkedList.prototype.remove = ฟังก์ชั่น (รายการ) {ถ้ารายการ) {var prenode = this.findpre (รายการ); ฟังก์ชั่น (รายการ this.insert (รายการ); finder.next; currnode.next; ฟังก์ชั่น (รายการ) {ถ้ารายการ == null) null;การใช้งาน JavaScript ของ DoubleLinkedList
ห้องสมุดที่เกี่ยวข้องกับ NPMJS:
รายการที่ซับซ้อนรายการอัจฉริยะ
แนวคิดการเขียนโปรแกรม:
การใช้งานของคุณเอง
doublenode.js
(function () {"ใช้อย่างเข้มงวด"; ฟังก์ชันโหนด (องค์ประกอบ) {this.element = element; this.next = null; this.previous = null;} module.exports = node;}) ();doublelinkedlist.js
(function () {"ใช้อย่างเข้มงวด"; var node = ต้องการ ("./ lib/doublenode"); ฟังก์ชั่น doublelinkedList () {this._head = โหนดใหม่ ("นี่คือโหนดหัว"); this._size = 0; DoublelinkedList.prototype.iseMpty = function () {return this._size === 0; currnode = currnode.next; return; DoublelinkedList.prototype.find = ฟังก์ชั่น (รายการ) {ถ้า (รายการ == null) null; newNode = newElement); Newnode;} this._size ++; DoublelinkedList.prototype.display = function () {var currnode = this.gethead (). ถัดไป;