[Mono-list] System.Collections intricacies

Andrew P. Wilson apwilson@rogers.com
Fri, 30 Jan 2004 10:19:30 -0500


So if the get_Item or set_Item functions are called, control should pass =
to
the indexer defined in the ArrayList source code; specifically to the =
get or
set subsections, respectively?

I added some code to the indexer specified in ArrayList.cs to tell me if =
and
when a program uses an ArrayList via indexers.  I noticed numerous gets =
and
sets to ArrayLists because of this code when I was doing a make install =
with
the mcs source code. But when I ran the actual program I wanted to see =
this
info for, I did not receive any output.

I suppose I could have instrumented the wrong indexer, there are a bunch =
of
them.  But just as confirmation, a get_Item or set_Item call *will* =
transfer
control to the appropriate class's indexer?

-andrew

=20


-----Original Message-----
From: mono-list-admin@lists.ximian.com
[mailto:mono-list-admin@lists.ximian.com] On Behalf Of A Rafael D =
Teixeira
Sent: January 30, 2004 8:46 AM
To: apwilson@rogers.com; mono-list@ximian.com
Subject: RE: [Mono-list] System.Collections intricacies

Well, the getItem/setITem pair IS the indexer.
C# Indexer creation and usage syntax is just a shorthand form., like =
what we

have for properties.

I recommend you to read the common language runtime spec, to understand =
what

the different compilers must do when transforming such constructs.

Best regards,

Rafael Teixeira
Brazilian Polymath
Mono Hacker since 16 Jul 2001
MonoBrasil Founding Member - Membro Fundador do MonoBrasil
English Blog: http://monoblog.blogspot.com/
Brazilian Portuguese Blog: http://monoblog.weblogger.terra.com.br/



>From: "Andrew P. Wilson" <apwilson@rogers.com>
>To: <mono-list@ximian.com>
>Subject: [Mono-list] System.Collections intricacies
>Date: Thu, 29 Jan 2004 14:36:35 -0500
>
>Hello everyone:
>
>
>
>I was hoping someone would be able to help me out with some details =
about
>indexers and collections and how they are used in mono.
>
>
>
>I was trying to implement some functionality to the ArrayList class in
>System.Collections through the use of the ArrayLists indexers.
>
>
>
>I had thought that if you wrote the code snippet the ArrayList's =
indexer
>function would be invoked 100 times because of the second for loop:
>
>
>
>/////////////// begin
>
>ArrayList myAL;
>
>myAL =3D new ArrayList();
>
>
>
>for(int i=3D0; i<100; i++)
>
>myAL.Add(i); //(add a bunch of numbers to the array list)
>
>
>
>int sum =3D 0;
>
>for(int i=3D0; i<100; i++)
>
>             sum =3D sum + (int)myAL[i];
>
>/////////////// end
>
>
>
>
>
>However, I am finding that the indexer is not called at all and from
>disassembling the executable, the following instructions are occurring=20
>where
>I would have thought the indexer would have been called:
>
>.
>
>.
>
>IL_0099:  callvirt instance object class
>[mscorlib]'System.Collections.ArrayList'::'get_Item'(int32)
>
>IL_009e:  unbox [mscorlib]System.Int32
>
>.
>
>.
>
>
>
>Normally, this wouldn't be a problem for me.  However, I cannot find =
this
>"get_Item" function anywhere in the mcs or mono source code.  There is =
also
>a corresponding "set_Item" function that is called as well, but again, =
I
>cannot find it in the source code.
>
>
>
>Is there a situation where the ArrayList Indexer will be called?  And =
do=20
>the
>get_Item and set_Item functions exist somewhere in the source code?
>
>
>
>Basically, all I want to be able to do is monitor accesses to an =
ArrayList
>through some predefined interface, whether the indexer or these =
get_Item=20
>and
>set_Item functions.  Any information about any of these things would be =

>much
>appreciated.
>
>
>
>Thank you for your time,
>
>
>
>Andrew P. Wilson
>
>Electrical and Computer Engineering Department
>
>University of Toronto
>
>
>

_________________________________________________________________
MSN Messenger: instale gr=E1tis e converse com seus amigos.=20
http://messenger.msn.com.br

_______________________________________________
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list