Re: C# 2.0 Generics and collections
For ValueTypes, a specialized type class is created. For RefTypes, only one
is created and it's reused. This solves the boxing issue (preliminary
results tell me it's at least 5 times faster in a tight loop that woult
otherwise box and unbox).
-mike
MVP
"Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
news:MPG.1a1b18 2f87021faa989a8 0@msnews.micros oft.com...[color=blue]
> Keith Patrick <richard_keith_ patrick@hotmail .com> wrote:[color=green]
> > A generic wouldn't solve the problem of the speed of boxing, would it?[/color][/color]
I[color=blue][color=green]
> > haven't read about how they are implemented, but I would think that[/color][/color]
integers[color=blue][color=green]
> > would still have to be treated a objects by the generic.[/color]
>
> I don't believe so. I believe each generic class is compiled into a
> type-specific class when it's first used, and that can take advantage
> of anything type-specific such as size. (Note that this *isn't* the way
> generics will be working in Java, AFAIK.)
>
> --
> Jon Skeet - <skeet@pobox.co m>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too[/color]
For ValueTypes, a specialized type class is created. For RefTypes, only one
is created and it's reused. This solves the boxing issue (preliminary
results tell me it's at least 5 times faster in a tight loop that woult
otherwise box and unbox).
-mike
MVP
"Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
news:MPG.1a1b18 2f87021faa989a8 0@msnews.micros oft.com...[color=blue]
> Keith Patrick <richard_keith_ patrick@hotmail .com> wrote:[color=green]
> > A generic wouldn't solve the problem of the speed of boxing, would it?[/color][/color]
I[color=blue][color=green]
> > haven't read about how they are implemented, but I would think that[/color][/color]
integers[color=blue][color=green]
> > would still have to be treated a objects by the generic.[/color]
>
> I don't believe so. I believe each generic class is compiled into a
> type-specific class when it's first used, and that can take advantage
> of anything type-specific such as size. (Note that this *isn't* the way
> generics will be working in Java, AFAIK.)
>
> --
> Jon Skeet - <skeet@pobox.co m>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too[/color]
Comment