<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Generics Algorithms</title><link>http://blogs.msdn.com/ericgu/archive/2003/11/14/52852.aspx</link><description>A few weeks ago, Anders walked into the C# design meeting and said, "I think I have a way to get generic algorithms to work with our current support", and then proceeded to outline a scheme on the whiteboard. I dutifully copied it into our design notes</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>RE: Generics Algorithms</title><link>http://blogs.msdn.com/ericgu/archive/2003/11/14/52852.aspx#52853</link><pubDate>Fri, 14 Nov 2003 12:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:52853</guid><dc:creator>Olivier</dc:creator><description>You can avoid virtual with:
public interface ICalculator&amp;lt;T&amp;gt;
{
    T Add(T a, T b); 
} 

class AlgorithmLibrary&amp;lt;T, IC&amp;gt;
	where T: new() 
	where CT: ICalculator&amp;lt;T&amp;gt; 
{
    CT calculator;

    public AlgorithmLibrary(CT calculator)
    {
         this.calculator = calculator;
    } 

    public T Sum(List&amp;lt;T&amp;gt; items)
    {
        T sum = new T(); 

        for (int i = 0; i &amp;lt; items.Count; i++)
       {
           sum = calculator.Add(sum, items[i]);
       } 

       return sum;
    }
} 
namespace Int32
{
	public class Calculator: ICalculator&amp;lt;int&amp;gt;
	{
		public int Add(int a, int b)
		{
			return a + b;
		}
	} 
} 
but i don't yet have received Whidbey to compare performance.</description></item><item><title>RE: Generics Algorithms</title><link>http://blogs.msdn.com/ericgu/archive/2003/11/14/52852.aspx#52854</link><pubDate>Fri, 14 Nov 2003 16:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:52854</guid><dc:creator>Nicholas Paldino</dc:creator><description>While the solution does not strike me as anything incredibly new (think STL), the only way you will get it to work (and I mean work in the sense of acceptance) is if you create your own algorithm library, with skeletons required (abstract classes and interfaces) to inject our own custom types into the algorithms.

I don't remember if it was you or someone else from MS, but it was said that the only way that something like this is effective is if there is universal coverage, which has more potential to lead to universal adoption.

Based on that, my question would be, are you going to create such an algorithm library, along the lines of STL, and if so, what kinds of algorithms are you going to create?</description></item><item><title>RE: Generics Algorithms</title><link>http://blogs.msdn.com/ericgu/archive/2003/11/14/52852.aspx#52855</link><pubDate>Fri, 14 Nov 2003 19:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:52855</guid><dc:creator>Eric</dc:creator><description>Thanks, Olivier. I had thought about trying interfaces, but hadn't gotten around to it yet. </description></item><item><title>RE: Generics Algorithms</title><link>http://blogs.msdn.com/ericgu/archive/2003/11/14/52852.aspx#52856</link><pubDate>Sat, 15 Nov 2003 03:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:52856</guid><dc:creator>Dilip</dc:creator><description>http://weblog.ikvm.net/permalink.aspx/94eed5a8-6c9c-4d1d-a001-321344a2d2f6</description></item><item><title>RE: Generics Algorithms</title><link>http://blogs.msdn.com/ericgu/archive/2003/11/14/52852.aspx#52857</link><pubDate>Tue, 18 Nov 2003 05:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:52857</guid><dc:creator>(luKa)</dc:creator><description>Wouldn't  be possible to have a constraints for a type parameter  to specifie  a required  member  (a method, an operator, ecc) just like this?

 namespace Int32
{
    public class Calculator&amp;lt;T&amp;gt;
         where T:  T Add(T, T)
    {
        public  T Add(T a, T b)
        {
            return a + b;
        }
    }
}

TIA (luKa)</description></item><item><title>RE: Generics Algorithms</title><link>http://blogs.msdn.com/ericgu/archive/2003/11/14/52852.aspx#52858</link><pubDate>Tue, 18 Nov 2003 05:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:52858</guid><dc:creator>(luKa)</dc:creator><description>Ops... I was meaning this

class AlgorithmLibrary&amp;lt;T&amp;gt; 
....where T: new(),  T Add(T, T)
{
....//  ...
}</description></item><item><title>RE: Generics Algorithms</title><link>http://blogs.msdn.com/ericgu/archive/2003/11/14/52852.aspx#52859</link><pubDate>Tue, 18 Nov 2003 19:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:52859</guid><dc:creator>Anonymous</dc:creator><description /></item><item><title>RE: Generics Algorithms</title><link>http://blogs.msdn.com/ericgu/archive/2003/11/14/52852.aspx#52860</link><pubDate>Tue, 18 Nov 2003 19:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:52860</guid><dc:creator>andrew queisser</dc:creator><description>luKa, I think you're pointing out the fundamental problem with generic algorithms in C#. There's no way to do anything inside a generic algorithm unless you specify an exact type or interface. That puts the burden on the caller of the generic algorithm to pass in a the type needed by the algorithm. That's the exact oppositie of a &amp;quot;generic&amp;quot; algorithm. Looks like several people are thinking about how to get around this problem (see Eric's post above). 

Andrew Queisser
</description></item><item><title>Re:</title><link>http://blogs.msdn.com/ericgu/archive/2003/11/14/52852.aspx#333547</link><pubDate>Tue, 28 Dec 2004 12:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:333547</guid><dc:creator>RebelGeekz </dc:creator><description>[&lt;a target="_new" href="http://itpeixun.51.net/"&gt;http://itpeixun.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://aissl.51.net/"&gt;http://aissl.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz003.freewebpage.org/"&gt;http://kukuxz003.freewebpage.org/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz001.51.net/"&gt;http://kukuxz001.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz003.51.net/"&gt;http://kukuxz003.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz005.51.net/"&gt;http://kukuxz005.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz002.51.net/"&gt;http://kukuxz002.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz004.freewebpage.org/"&gt;http://kukuxz004.freewebpage.org/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz007.51.net/"&gt;http://kukuxz007.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz001.freewebpage.org/"&gt;http://kukuxz001.freewebpage.org/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz006.51.net/"&gt;http://kukuxz006.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz002.freewebpage.org/"&gt;http://kukuxz002.freewebpage.org/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz004.51.net/"&gt;http://kukuxz004.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz008.51.net/"&gt;http://kukuxz008.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz009.51.net/"&gt;http://kukuxz009.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz005.freewebpage.org/"&gt;http://kukuxz005.freewebpage.org/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz006.freewebpage.org/"&gt;http://kukuxz006.freewebpage.org/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz007.freewebpage.org/"&gt;http://kukuxz007.freewebpage.org/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz009.freewebpage.org/"&gt;http://kukuxz009.freewebpage.org/&lt;/a&gt;]</description></item><item><title>Generic Algorithms in C# &amp;laquo; The Wandering Glitch 2</title><link>http://blogs.msdn.com/ericgu/archive/2003/11/14/52852.aspx#792879</link><pubDate>Thu, 05 Oct 2006 08:21:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:792879</guid><dc:creator>Generic Algorithms in C# « The Wandering Glitch 2</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://aabs.wordpress.com/2006/10/05/generic-algorithms-in-c/"&gt;http://aabs.wordpress.com/2006/10/05/generic-algorithms-in-c/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>在计算程序中使用泛型</title><link>http://blogs.msdn.com/ericgu/archive/2003/11/14/52852.aspx#3999562</link><pubDate>Sun, 22 Jul 2007 18:19:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3999562</guid><dc:creator>Snapping</dc:creator><description>&lt;p&gt;Ref:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://www.codeproject.com/csharp/genericnumerics.asp"&gt;http://www.codeproject.com/csharp/genericnumerics.asp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Introduction&lt;/p&gt;
&lt;p&gt;Thecurrentimplementatio...&lt;/p&gt;
</description></item><item><title>Employment Wages &amp;raquo; Eric Gunnerson&amp;#8217;s C# Compendium : Generics Algorithms</title><link>http://blogs.msdn.com/ericgu/archive/2003/11/14/52852.aspx#8341348</link><pubDate>Fri, 28 Mar 2008 12:59:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8341348</guid><dc:creator>Employment Wages » Eric Gunnerson’s C# Compendium : Generics Algorithms</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://employmentwagesblog.info/eric-gunnersons-c-compendium-generics-algorithms/"&gt;http://employmentwagesblog.info/eric-gunnersons-c-compendium-generics-algorithms/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title> Eric Gunnerson s C Compendium Generics Algorithms | Weak Bladder</title><link>http://blogs.msdn.com/ericgu/archive/2003/11/14/52852.aspx#9716876</link><pubDate>Tue, 09 Jun 2009 21:21:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9716876</guid><dc:creator> Eric Gunnerson s C Compendium Generics Algorithms | Weak Bladder</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://weakbladder.info/story.php?id=6808"&gt;http://weakbladder.info/story.php?id=6808&lt;/a&gt;&lt;/p&gt;
</description></item><item><title> Eric Gunnerson s C Compendium Generics Algorithms | Quick Diets</title><link>http://blogs.msdn.com/ericgu/archive/2003/11/14/52852.aspx#9723287</link><pubDate>Wed, 10 Jun 2009 06:46:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9723287</guid><dc:creator> Eric Gunnerson s C Compendium Generics Algorithms | Quick Diets</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://quickdietsite.info/story.php?id=14591"&gt;http://quickdietsite.info/story.php?id=14591&lt;/a&gt;&lt;/p&gt;
</description></item><item><title> Eric Gunnerson s C Compendium Generics Algorithms | internet marketing tools</title><link>http://blogs.msdn.com/ericgu/archive/2003/11/14/52852.aspx#9758413</link><pubDate>Tue, 16 Jun 2009 07:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9758413</guid><dc:creator> Eric Gunnerson s C Compendium Generics Algorithms | internet marketing tools</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://einternetmarketingtools.info/story.php?id=23635"&gt;http://einternetmarketingtools.info/story.php?id=23635&lt;/a&gt;&lt;/p&gt;
</description></item></channel></rss>