From: Vincent Celier <vcelier@direct.ca>
Subject: Re: HELP : linked lists in ADA
Date: 1996/11/30
Date: 1996-11-30T00:00:00+00:00 [thread overview]
Message-ID: <32A0CF21.533E@direct.ca> (raw)
In-Reply-To: 57fpgl$9au@arcturus.ciril.fr
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
prev parent reply other threads:[~1996-11-30 0:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-11-26 0:00 HELP : linked lists in ADA Richard Clavelier
1996-11-30 0:00 ` Vincent Celier [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox