ArrayList help (strange behavior) 
Author Message
 ArrayList help (strange behavior)

Are the last two lines of this code valid? Is it legal to "overwrite" one
arrayList with another via an assignment? I'm noticing some strange
side-effects: after the assignment, arrayList2 will have a count of 0
whereas before the assignment it had a count > 0 ... as though the
assignment were happening sooner than the Clear.

Dim  arrayList1 as New ArrayList()
Dim arrayList2 as New ArrayList()

arrayList1.Add("cat")
arrayList1.Add("dog")
arrayList2.Add("mouse")
arrayList2.Add("rat")
arrayList2.Add("mole")
arrayList2.Add("vole")

arrayList1.Clear()
arrayList1 = arrayList2

Thanks

Tim



Mon, 21 Feb 2005 21:21:33 GMT  
 ArrayList help (strange behavior)
The last line simply makes the handle arrayList1 point at the same object
arrayList2 points at.

--
Regards,

http://4space.org.uk
GPG Key Fingerprint : 78C6 D057 EAB8 1E70
                                   5365 F561 C38A C88D
                                   DDA9 119B


Quote:
> Are the last two lines of this code valid? Is it legal to "overwrite" one
> arrayList with another via an assignment? I'm noticing some strange
> side-effects: after the assignment, arrayList2 will have a count of 0
> whereas before the assignment it had a count > 0 ... as though the
> assignment were happening sooner than the Clear.

> Dim  arrayList1 as New ArrayList()
> Dim arrayList2 as New ArrayList()

> arrayList1.Add("cat")
> arrayList1.Add("dog")
> arrayList2.Add("mouse")
> arrayList2.Add("rat")
> arrayList2.Add("mole")
> arrayList2.Add("vole")

> arrayList1.Clear()
> arrayList1 = arrayList2

> Thanks

> Tim



Mon, 21 Feb 2005 21:42:59 GMT  
 ArrayList help (strange behavior)
That's what I would expect.  But then the Clear method will (sometime) clear
arrayList2 as well! At least that's the intermittent behavior I'm seeing.

arrayList1.Clear
arrayList1 = arrayList2

Tim


Quote:
> The last line simply makes the handle arrayList1 point at the same object
> arrayList2 points at.

> --
> Regards,

> http://4space.org.uk
> GPG Key Fingerprint : 78C6 D057 EAB8 1E70
>                                    5365 F561 C38A C88D
>                                    DDA9 119B



> > Are the last two lines of this code valid? Is it legal to "overwrite"
one
> > arrayList with another via an assignment? I'm noticing some strange
> > side-effects: after the assignment, arrayList2 will have a count of 0
> > whereas before the assignment it had a count > 0 ... as though the
> > assignment were happening sooner than the Clear.

> > Dim  arrayList1 as New ArrayList()
> > Dim arrayList2 as New ArrayList()

> > arrayList1.Add("cat")
> > arrayList1.Add("dog")
> > arrayList2.Add("mouse")
> > arrayList2.Add("rat")
> > arrayList2.Add("mole")
> > arrayList2.Add("vole")

> > arrayList1.Clear()
> > arrayList1 = arrayList2

> > Thanks

> > Tim



Mon, 21 Feb 2005 23:28:24 GMT  
 ArrayList help (strange behavior)
Assuming you're not writing a multi threaded application, that is very
confusing.

The call to Clear() on the object pointed to by arrayList1 should have
completed before the reassignment of the handle. Have a butchers at the
intermediate code and make sure the compilers not doing anything unusual.

--
Regards,

http://4space.org.uk
GPG Key Fingerprint : 78C6 D057 EAB8 1E70
                                   5365 F561 C38A C88D
                                   DDA9 119B


Quote:
> That's what I would expect.  But then the Clear method will (sometime)
clear
> arrayList2 as well! At least that's the intermittent behavior I'm seeing.

> arrayList1.Clear
> arrayList1 = arrayList2



Tue, 22 Feb 2005 14:52:22 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Strange, very strange OnGetMinMaxInfo() behavior

2. Strange, very strange OnGetMinMaxInfo() behavior

3. Help with strange behavior in the Load event

4. help: strange free() behavior!

5. HELP : sizeof operator strange behavior.

6. strange SetFocus() behavior, need help

7. Help! Strange multithreaded app behavior

8. Strange behavior of app help

9. Strange "ArrayList" Behaviour

10. Strange constant behavior - why?

11. Asynchronous CallBack strange behavior

12. Strange behavior in program

 

 
Powered by phpBB® Forum Software