Discussion Board
There are no previous messagesGo to the following message
Current Forum: 15-211 Main Forum
Date: Mon Sep 24 2001 1:21 pm
Author: Shi, Ying <shy@cmu.edu>
Subject: the implementation of Append() in (abstract)Class List

according to the lectures on List, the Append() method for class List is implemented in the following way illustrated by a psydo-code example:

List a: "a"->"b"->Empty
List b: "d"->"e"->Empty

after List c = a.Append(b);

we'll have such a graph:

"
a=> "a"->"b"->Empty

b (references at "d")
|
c=> "a"->"b"->"d"->"e"->Empty
"

my question is:
why implement the Append() in such way?
or why not make a copy of b as well if the purpose is to keep the original lists as later on b and c could accidentally alter each other's integrity(they share a common section)?
I would assume it's not just a lazy programming that left the other half uncopied.
by all means, I don't understand the benifits/advantages or maybe some tradeoffs that I can't picture out behind this implementation.

Thanks
Post response

There are no previous messagesGo to the following message
Current Thread Detail:
the implementation of Append() in (abs...      Shi, Ying      Mon Sep 24 2001 1:21 pm       
Re: the implementation of Append() ...      Shi, Ying      Mon Sep 24 2001 1:22 pm       
Re: the implementation of Append() ...      Lee, Peter      Mon Sep 24 2001 1:51 pm       
Re: the implementation of Append...      Scherlis, William L.      Mon Oct 1 2001 5:09 pm       

Back to previous screen