Bidirectional Links && Stack

zhaozj2021-02-16  43

/ * -------------- Bidirectional Links && Stack -------------- * / Function LinkList () {var Olist, OLENGTH, ORESULT; this. append = dListAppend; this.Length = dListLength; this.GetAt = dListGetAt; this.SetAt = dListSetAt; this.DeleteAt = dListDeleteAt; this.InsertAt = dListInsertAt; this.GetHead = dListGetHead; this.GetTail = dListGetTail; this.ClearAll = DinitLinkList; this.version = DListVersion;

this.push this.pop

DinitLinkList ();} function linklistdata () {this.data = null; this.next = null; this.prev = null;} {if (bbool) {Alert (olist.data);} return olist .data;} function dInitLinkList () {var ver = "doubly linked list 1.0 / n / n of: Lu printed just /n/n2002.9.3/n/n Copyright" oList = new LinkListData (); oList.data = Ver; Olist.Prev = Olist; Olist.next = Olist; OLENGTH = -1;} Function DlistAppend (m) {var temp = olist.prev; Temp.next = New LinkListData (); Temp.next.data = m; temp.next.prev = temp; temp.next.next = oList; oList.prev = temp.next; oLength = 1; oResult = m; return oResult;} function dListLength () {return oLength;} function dListGetHead () {Return Olist.next.data;} Function DlistGettail ()} Function DList.Prev.data;} Function DListGetPosition (D, I) {VAR POS = 0; IF (i = i) {d = D.PREV; POS- = 1;} Return D;}} Function DListGeta T (i) {if (i> OLENGTH) {i = OLENGTH;} var temp =}; temp = dlistgetposition (TEMP, I); oresult = Temp.data; return ores;} function DlistSetat (i, m) {IF (i> olength) {i = OLIST; TEMP = = olist; temp = dlistgetPosition (TEMP, I); TEMP.DATA = m; oresult = temp.data; return ores;} function DListDelete (i) {ix (i) > OLENGTH) {i = OLENGTH;} var temp = ilist; temp = dlistgetposition (temp, i); temp.prev.next = temp.next; oresult = temp.data; delete temp; OLENGTH- = 1; Return Oresult; } Function DlistIrtat (i, m) {if (i>

OLENGTH) {i = OLENGTH;} var temp = olist; temp = dlistgetPosition (TEMP, I-1); var d = new linelistdata (); d.data = m; D.PREV = TEMP; D.NEXT = TEMP. Next; temp.next.prev = d; Temp.next = D; OLENGTH = 1; oresult = m; return oresult;} / * -------------- Bidirectional Link Label && Stack - ------------*//*------------------application--------------- ----- * / var list = new linklist (); var temp = new array ("king", "love", "you", "me", "hello"); for (var i = 0; i

Alert (List.getat (2))

转载请注明原文地址:https://www.9cbs.com/read-26467.html

New Post(0)