Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.basic.visual.misc > #1795

Re: VB6 use of For Each with Collections

From vincent.belaiche@gmail.com (Vincent Belaïche)
Newsgroups comp.lang.basic.visual.misc
Subject Re: VB6 use of For Each with Collections
Date 2013-07-05 06:30 +0200
Organization Gegeweb News Server
Message-ID <80k3l5632h.fsf@gmail.com> (permalink)
References <e741101c-d3c7-4193-9fb3-b5543f9d33f6@googlegroups.com> <tg6jo85e8g9pfkiintb6as2f306fuvks21@4ax.com> <kmd1r5$c1p$1@speranza.aioe.org> <kqqn4s$nl7$1@speranza.aioe.org> <kqr9gi$rsr$1@speranza.aioe.org>

Show all headers | View raw


"Eduardo" <mm@mm.com> writes:

> "Eduardo" <mm@mm.com> escribió en el mensaje 
> news:kqqn4s$nl7$1@speranza.aioe.org...
>>
>> "Deanna Earley" <dee.earley@icode.co.uk> escribió en el mensaje 
>> news:kmd1r5$c1p$1@speranza.aioe.org...
>>
>>> Note that the key in the collection is normally hashed so only an extra 
>>> few bytes per entry is used.
>>
>> (to different keys pointing to the same element).
>
> I meant two or more different keys producing the same hash.
>
> In the link https://en.wikipedia.org/wiki/Hash_function there is an image 
> illustrating this (the first figure at the top right)
>
> So, to be sure that two "input" keys are the same, it's not enough to 
> compare it's hashes, because two different keys can produce the same hash, 
> so the key must be stored, perhaps not exactly as it is but compressed in a 
> lossless way.

Just one question: isn't the root cause why you cannot get the key that
you do some "Let" assignment to a Variant object like this:

Dim vElement As Variant, oCollection As Collection
....
Let vElement = oCollection.Item(1)

and not a Set assignment to an Object object like this:

Dim oElement As Object, oCollection As Collection
....
Set oElement = oCollection.Item(1)

I must say that I cannot check the code above because I have not any VB
other than VBScript installed on my WindowsXP machine --- can you
install some VB6 for free ?

I am meaning that when you do the let assignment there is some type cast
which makes you loose some of the information in the indiced object. I
do not know how Collections are implemented, but I fully share what
Eduardo has written: the key needs to be stored somewhere in a lossless
way for a hash table to work.

BR,
  Vincent.

Back to comp.lang.basic.visual.misc | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

VB6 use of For Each with Collections stevegdula@yahoo.com - 2013-05-07 14:22 -0700
  Re: VB6 use of For Each with Collections Michael Cole <invalid@microsoft.com> - 2013-05-08 10:21 +1000
  Re: VB6 use of For Each with Collections ralph <nt_consulting@yahoo.com> - 2013-05-07 19:39 -0500
    Re: VB6 use of For Each with Collections Michael Cole <invalid@microsoft.com> - 2013-05-08 11:48 +1000
      Re: VB6 use of For Each with Collections GS <gs@somewhere.net> - 2013-05-07 23:55 -0400
    Re: VB6 use of For Each with Collections Deanna Earley <dee.earley@icode.co.uk> - 2013-05-08 09:19 +0100
      Re: VB6 use of For Each with Collections stevegdula@yahoo.com - 2013-05-08 08:27 -0700
        Re: VB6 use of For Each with Collections ralph <nt_consulting@yahoo.com> - 2013-05-08 11:25 -0500
          Re: VB6 use of For Each with Collections ralph <nt_consulting@yahoo.com> - 2013-05-08 11:52 -0500
            Re: VB6 use of For Each with Collections stevegdula@yahoo.com - 2013-05-08 12:00 -0700
      Re: VB6 use of For Each with Collections "Eduardo" <mm@mm.com> - 2013-06-30 22:48 -0300
        Re: VB6 use of For Each with Collections ralph <nt_consulting@yahoo.com> - 2013-06-30 22:09 -0500
          Re: VB6 use of For Each with Collections Schmidt <ng@vbRichClient.com> - 2013-07-01 07:58 +0200
            Re: VB6 use of For Each with Collections "Eduardo" <mm@mm.com> - 2013-07-01 03:47 -0300
          Re: VB6 use of For Each with Collections "Eduardo" <mm@mm.com> - 2013-07-01 04:08 -0300
        Re: VB6 use of For Each with Collections "Eduardo" <mm@mm.com> - 2013-07-01 04:01 -0300
          Re: VB6 use of For Each with Collections vincent.belaiche@gmail.com (Vincent Belaïche) - 2013-07-05 06:30 +0200
            Re: VB6 use of For Each with Collections "Eduardo" <mm@mm.com> - 2013-07-05 03:31 -0300

csiph-web