Re: Roll your own std::vector ???
- From: "Peter Olcott" <NoSpam@xxxxxxxxxxxxx>
- Date: Sun, 17 Dec 2006 16:36:37 -0600
"Joanna Carter [TeamB]" <joanna@xxxxxxxxxxxx> wrote in message
news:eJ9oimiIHHA.1124@xxxxxxxxxxxxxxxxxxxxxxx
"Peter Olcott" <NoSpam@xxxxxxxxxxxxx> a écrit dans le message de news:
pVihh.19892$Rj.19203@xxxxxxxxxxxxxxx
| The commonly understood basic principle where an array name is
| one-and-the-same-thing as an array address.
In that case, that would appear to be the principle for all .NET types. The
variable that you see *is* the object that the variable points to. There is
no indirection on the surface, even though the underlying framework may
involve such.
I think the thing that you are having trouble with is this lack of
indirection; when it comes to C#, you need to try to forget about ->, & and
* and simply think of variables as being one and the same as the object
which they hold. For the sake of your comprehension, forget about pointers
and addresses :-)
One can't forget about this completely otherwise ones makes the mistake of
taking a shallow copy to be one-and-the-same-thing as a deep copy. I think that
..NET may have simplified this somewhat in some ways, I am currently not sure of
exactly how they did this. The way that this problem is typically simplified is
to always provide all of the overhead of a deep copy just in case that is what
was wanted.
| Yes that is what I was talking about, they are both pointers within the
| underlying architecture.
Maybe but that should not concern you; forget pointers :-)).
Yet then one must still wonder about the shallow versus deep copy problem, and
avoiding the overhead of the deep copy, when it is not needed. The best solution
at this point in time for applications programming might be to simply always do
a deep copy, and make doing a shallow copy syntactically impossible. There are
cases on systems programming where this would be unacceptable.
| > As I said in my previous post, the contents of value types are copied on
| > assignment, but those of reference types are simply "pointed to" by the
| > second reference.
|
| Array.Copy(ia, temp, ia.Length);
| ia = temp;
|
| So the last statement contains two reference types, even though the
underlying
| type of array element may be a value type or a reference type ???
Array is a reference type, regardless of the type that it holds. See Jon's
post as well.
Joanna
--
Joanna Carter [TeamB]
Consultant Software Engineer
.
- Follow-Ups:
- Re: Roll your own std::vector ???
- From: Joanna Carter [TeamB]
- Re: Roll your own std::vector ???
- References:
- Roll your own std::vector ???
- From: Peter Olcott
- Re: Roll your own std::vector ???
- From: Joanna Carter [TeamB]
- Re: Roll your own std::vector ???
- From: Joanna Carter [TeamB]
- Re: Roll your own std::vector ???
- From: Peter Olcott
- Re: Roll your own std::vector ???
- From: Joanna Carter [TeamB]
- Re: Roll your own std::vector ???
- From: Peter Olcott
- Re: Roll your own std::vector ???
- From: Joanna Carter [TeamB]
- Re: Roll your own std::vector ???
- From: Peter Olcott
- Re: Roll your own std::vector ???
- From: Joanna Carter [TeamB]
- Roll your own std::vector ???
- Prev by Date: Re: Roll your own std::vector ???
- Next by Date: Re: Roll your own std::vector ???
- Previous by thread: Re: Roll your own std::vector ???
- Next by thread: Re: Roll your own std::vector ???
- Index(es):
Relevant Pages
|