/ * -------------- 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
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))