Re: Array comparison
From: Jamie (jamie_5_not_valid_after_5_Please_at_charter.net)
Date: 10/09/04
- Next message: Jamie: "Re: How hash tables work"
- Previous message: Peter Piper: "How hash tables work"
- In reply to: Nicolai Hansen: "Re: Array comparison"
- Next in thread: Rob Kennedy: "Re: Array comparison"
- Reply: Rob Kennedy: "Re: Array comparison"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 09 Oct 2004 12:40:25 -0700
the problem with arrays is this.
you can perform a memory compare scan how ever, you
must be aware that things like Class Objects and
pointers are only going to compare their object pointers
and memory pointers, not the actual content of what the
pointer is referring too.
and of course the arrays must hold the same type of
members to start with.
for example
doing an array of string is miss leading in 2 ways.
1. if they are ansi and not short strings you are only comparing the
pointers and not the contents of the strings.
2. for short strings it would work how ever, you may have left over
garbage that is not being referenced in the short strings that do not
match and thus the compare would fail even though the strings that
have the valid info matches.
in this case one should always do a Fillchar on a string or Record
that holds Short strings to insure that left over garbage is not in there .
etc.,.
if you were doing things that did not involve these such types then
you would have no problem doing a complete memory compare.
things like array of Char, bytes, words, dword, int64's etc..
and yes. the dynamic arrays can be memory compared also.
Nicolai Hansen wrote:
> *snip*
>
>
>>I think I understand. You're saying that if arrays and records are
>>comparable, then objects should also be comparable -- more than just by
>>reference -- right?
>
>
> Yes :) There should be no difference if you has an array type, or
> encapsulate that array type in an object. [if I want to make my
> strings type TStr=object length: byte; str: array of char; end; I
> should be able to compare these two...]
>
>
>>But if objects are going to be compared deeply, then they should be
>>assigned deeply, and that will break everything. Everything.
>
>
> Yes. In Pascal it would :) Because Pascal got the major weakness that
> objects are ALWAYS references - and what I am trying to say is that
> this might be the whole reason array types are not comparable.
- Next message: Jamie: "Re: How hash tables work"
- Previous message: Peter Piper: "How hash tables work"
- In reply to: Nicolai Hansen: "Re: Array comparison"
- Next in thread: Rob Kennedy: "Re: Array comparison"
- Reply: Rob Kennedy: "Re: Array comparison"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|