[Mono-list] System.Collections intricacies
Andrew P. Wilson
apwilson@rogers.com
Thu, 29 Jan 2004 14:36:35 -0500
This is a multi-part message in MIME format.
------=_NextPart_000_0013_01C3E675.4BEEF720
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hello everyone:
=20
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.
=20
I was trying to implement some functionality to the ArrayList class in
System.Collections through the use of the ArrayLists indexers.
=20
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:
=20
/////////////// begin
ArrayList myAL;
myAL =3D new ArrayList();
=20
for(int i=3D0; i<100; i++)
myAL.Add(i); //(add a bunch of numbers to the array list)
=20
int sum =3D 0;
for(int i=3D0; i<100; i++)
sum =3D sum + (int)myAL[i];
/////////////// end
=20
=20
However, I am finding that the indexer is not called at all and from
disassembling the executable, the following instructions are occurring =
where
I would have thought the indexer would have been called:
.
. =20
IL_0099: callvirt instance object class
[mscorlib]'System.Collections.ArrayList'::'get_Item'(int32)
IL_009e: unbox [mscorlib]System.Int32
.
.
=20
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.
=20
Is there a situation where the ArrayList Indexer will be called? And do =
the
get_Item and set_Item functions exist somewhere in the source code?
=20
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 =
and
set_Item functions. Any information about any of these things would be =
much
appreciated.
=20
Thank you for your time,
=20
Andrew P. Wilson
Electrical and Computer Engineering Department
University of Toronto
=20
------=_NextPart_000_0013_01C3E675.4BEEF720
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 10 (filtered)">
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
span.EmailStyle17
{font-family:Arial;
color:windowtext;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
{page:Section1;}
-->
</style>
</head>
<body lang=3DEN-CA link=3Dblue vlink=3Dpurple>
<div class=3DSection1>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>Hello everyone:</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>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.</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>I was trying to implement some functionality =
to the ArrayList
class in System.Collections through the use of the ArrayLists =
indexers.</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>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:</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>/////////////// begin</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>ArrayList myAL;</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>myAL =3D new ArrayList();</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>for(int i=3D0; i<100; =
i++)</span></font></p>
<p class=3DMsoNormal style=3D'text-indent:36.0pt'><font size=3D2 =
face=3DArial><span
lang=3DEN-US style=3D'font-size:10.0pt;font-family:Arial'>myAL.Add(i); =
//(add a
bunch of numbers to the array list)</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>int sum =3D 0;</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>for(int i=3D0; i<100; =
i++)</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>  =
; sum
=3D sum + (int)myAL[i];</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>/////////////// end</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>However, I am finding that the indexer is not =
called
at all and from disassembling the executable, the following instructions =
are occurring
where I would have thought the indexer would have been =
called:</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>.</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>. &nbs=
p; </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>IL_0099: callvirt instance object class =
[mscorlib]'System.Collections.ArrayList'::'get_Item'(int32)</span></font>=
</p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>IL_009e: unbox =
[mscorlib]System.Int32</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>.</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>.</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>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.</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>Is there a situation where the ArrayList =
Indexer will
be called? And do the get_Item and set_Item functions exist =
somewhere in
the source code?</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>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 and set_Item functions. Any information about =
any of these
things would be much appreciated.</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>Thank you for your time,</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>Andrew P. Wilson</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>Electrical and Computer Engineering =
Department</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'>University</span></font><font size=3D2 =
face=3DArial><span
lang=3DEN-US style=3D'font-size:10.0pt;font-family:Arial'> of =
</span></font><font
size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:Arial'>Toronto</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Arial'> </span></font></p>
</div>
</body>
</html>
------=_NextPart_000_0013_01C3E675.4BEEF720--