Re: Holub on getters/setters again

From: Daniel Parker (danielaparker_at_spam?nothanks.windupbird.com)
Date: 01/25/04


Date: Sun, 25 Jan 2004 02:19:40 -0500


"Daniel T." <postmaster@eathlink.net> wrote in message
news:postmaster-889604.01461125012004@news05.east.earthlink.net...
> "Daniel Parker" <danielaparker@spam?nothanks.windupbird.com> wrote:
>
> > Note that even if we return a clone of an array list, if the entries in
the
> > array list are mutable, the client code may still be able to violate
> > conditions for the set, by making member wise changes such that two
entries
> > now evaluate as equal. The tradition in Java and C# seems to be not to
> > worry about these things too much. We don't see deep copies very much.
>
> I guess the question here is how do we decide what should go in the set?
> The code as origionally presented would certanly allow two object with
> the same state (ie two different but equal object) to be contained in
> the set,

I'm not so sure about that.

> so I don't think that is much of an issue.

The code for Add is

 public void Add(object o) {
      if (this.Includes(o)) return;
      contents.Add(o);
    }

I don't see the source for Includes, but presumably it would do equality
comparisons for each element in the array, until it found a match. C#
allows overloading of the equality operator, which can depend on state
rather than reference identity, string comparison, for example, is
overloaded to comparing the content of the two strings. So in particular I
don't think the Add method would allow two strings with the same state.

Regards,
Daniel Parker



Relevant Pages

  • Re: [2.6.35-rc3] select useful number of entries for DMA debugging...
    ... debugging out of memory - disabling'. ... Increase number of entries to allow DMA debugging again. ... Daniel> system is better, let me know and I'll quickly respin. ...
    (Linux-Kernel)
  • Re: [2.6.35-rc5] select useful number of entries for DMA debugging v3...
    ... debugging out of memory - disabling'. ... Increase number of entries to allow DMA debugging again. ... Daniel> system is better, let me know and I'll quickly respin. ...
    (Linux-Kernel)
  • Re: Poker hand evaluator
    ... Objects with strings as access keys, ... It is no longer ~49k entries, by the way, rather 55 - I have added the ... suit, and O for any rank without a card in the suit. ...
    (comp.lang.javascript)
  • Re: Why does it take up so much memory
    ... Next do you actually know the total length of the strings you are reading into ... lot of heap fragmentation and other problems with memory allocation if you ... The data from this will occupy 25 bytes on disk and the whole thing will only ... Even with a data file of 30,000 entries your string data will occupy exactly ...
    (comp.lang.pascal.delphi.misc)
  • INSERT Delay
    ... I have a VB program using ADO that makes entries using INSERT in a SQL 2000 ... All entries are made in pairs. ... The two strings are then sent to the server using connection.Execute ... INSERTS that are executed between the two sent as a batch. ...
    (microsoft.public.sqlserver.programming)