From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: ** X-Spam-Status: No, score=2.9 required=5.0 tests=BAYES_50,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,92269a4e820b8fde X-Google-Attributes: gid103376,public From: Vincent Celier Subject: Re: HELP : linked lists in ADA Date: 1996/11/30 Message-ID: <32A0CF21.533E@direct.ca>#1/1 X-Deja-AN: 201627874 references: <57fpgl$9au@arcturus.ciril.fr> content-type: text/plain; charset=us-ascii organization: Canada Internet Direct, Inc. mime-version: 1.0 reply-to: vcelier@direct.ca newsgroups: comp.lang.ada x-mailer: Mozilla 3.01Gold (WinNT; I) Date: 1996-11-30T00:00:00+00:00 List-Id: Richard Clavelier wrote: > > Hello, I believe you may be one of these students that posts to the whole earth for getting help on an assignment. However, the problem is interesting for other people: how to make a double linked list of tasks. > We have to create a forward and backward linked list in Ada. > > We have the following program (simplified here) : > --------------------------------------------------------------------------- -- added declarations type CELLULE; type CELLPOINTER is access CELLULE; > > task type CELL is -- added entry entry GET_LINKS (MYSELF : in CELLPOINTER; PREVIOUS : in CELLPOINTER); > entry X_IN (in_v : in INTEGER); > entry Y_OUT; > end CELL; > > type CELLULE is > record > T : CELL; > end record; > -- remove the following declaration > type CELLPOINTER is access CELLULE; > > task body CELL is -- add the following declaration currentLink : CELLPOINTER; > forwardLink : CELLPOINTER; > backwardLink : CELLPOINTER; > begin -- Add the following statements at the beginning accept GET_LINKS (MYSELF : in CELLPOINTER; PREVIOUS : in CELLPOINTER) do currentLink := MYSELF; backwardLink := PREVIOUS; end; > [...] > forwardLink := new CELLULE; -- add the following statement forwardLink.T.GET_BACKWARD_LINK (MYSELF => ForwardLink, PREVIOUS => currentLink); > -- we should give the new cell a pointer to "this" > -- backwardLink := a pointer to the previous cell > [...] > end CELL; > --------------------------------------------------------------------------- > > We have no problem for the forward link, but for the backward link, we > need to know the reference of the current > task ("Current" in Eiffel, "this" in C++), to be able to pass it to the task > that we create... > > Does anyone know the solution ? HELP !!! > > Richard > > PS: We don't want an object oriented solution. The solution I just exposed is not OO at all! -- Vincent Celier, -- 9100 McCutcheon Place, RICHMOND, B.C. -- CANADA, V7A 5A5 -- +1 (604) 241-9811