<?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>All About Iterators</title><link>http://blogs.msdn.com/wesdyer/archive/2007/03/23/all-about-iterators.aspx</link><description>Design patterns have been all of the rage for a number of years now. We have design patterns for concurrency, user interfaces, data access, object creation, and so many other things. The seminal work on the topic is the Gang of Four 's book, Design Patterns</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: All About Iterators</title><link>http://blogs.msdn.com/wesdyer/archive/2007/03/23/all-about-iterators.aspx#1936167</link><pubDate>Fri, 23 Mar 2007 12:15:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1936167</guid><dc:creator>kfarmer</dc:creator><description>&lt;p&gt;In the LINQ forums way-back, I'd suggested &amp;quot;yield enumerable&amp;quot; instead of &amp;quot;yield foreach&amp;quot;, with the same behavior, but I think I like the foreach version better.&lt;/p&gt;
</description></item><item><title>re: All About Iterators</title><link>http://blogs.msdn.com/wesdyer/archive/2007/03/23/all-about-iterators.aspx#1936927</link><pubDate>Fri, 23 Mar 2007 14:38:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1936927</guid><dc:creator>Sean</dc:creator><description>&lt;p&gt;Hey, another great post.&lt;/p&gt;
&lt;p&gt;I find that a very large amount of my time is spent iterating over items in a list, so the introduction of templates to C# was definitely a major advantage to me.&lt;/p&gt;
&lt;p&gt;Another great article on custom iterators that I highly recommend is one written by Bill Wagner:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://msdn2.microsoft.com/en-us/vcsharp/bb264519.aspx"&gt;http://msdn2.microsoft.com/en-us/vcsharp/bb264519.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And the article that originally introduced me to the idea (and I always carry a copy of the MSDN magazine it was in to use as a reference):&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/msdnmag/issues/06/00/c20/default.aspx"&gt;http://msdn.microsoft.com/msdnmag/issues/06/00/c20/default.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;By the way, completely offtopic, but I noticed that code in your &amp;lt;pre&amp;gt; tags are causing some font issues with Firefox. &amp;nbsp;I didn't dig into it too much, but the code is extremely small and hard to read. &amp;nbsp;My guess would be that it's inheriting from its parent with a font-style of something like 0.8em.&lt;/p&gt;</description></item><item><title>re: All About Iterators</title><link>http://blogs.msdn.com/wesdyer/archive/2007/03/23/all-about-iterators.aspx#1937832</link><pubDate>Fri, 23 Mar 2007 18:18:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1937832</guid><dc:creator>wesdyer</dc:creator><description>&lt;p&gt;Sean:&lt;/p&gt;
&lt;p&gt;Thanks for the heads up about the size of the code. &amp;nbsp;I guess now it's out that I don't use Firefox, I'll fix it.&lt;/p&gt;
</description></item><item><title>re: All About Iterators</title><link>http://blogs.msdn.com/wesdyer/archive/2007/03/23/all-about-iterators.aspx#1938085</link><pubDate>Fri, 23 Mar 2007 18:57:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1938085</guid><dc:creator>wesdyer</dc:creator><description>&lt;p&gt;I've updated the page based on Sean's feedback.&lt;/p&gt;
&lt;p&gt;I guess when I was copying and pasting code from Reflector into Windows Live Writer that it didn't work as well as I would have liked ;). &amp;nbsp;Thanks again Sean.&lt;/p&gt;
</description></item><item><title>re: All About Iterators</title><link>http://blogs.msdn.com/wesdyer/archive/2007/03/23/all-about-iterators.aspx#1938893</link><pubDate>Fri, 23 Mar 2007 22:52:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1938893</guid><dc:creator>Sean</dc:creator><description>&lt;p&gt;Any time! &amp;nbsp;You've helped me a ton. &amp;nbsp;That's why I subscribe to your blog. ;-)&lt;/p&gt;
&lt;p&gt;By the way, looks great now.&lt;/p&gt;
</description></item><item><title>re: All About Iterators</title><link>http://blogs.msdn.com/wesdyer/archive/2007/03/23/all-about-iterators.aspx#2046166</link><pubDate>Sat, 07 Apr 2007 19:56:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2046166</guid><dc:creator>Christopher Diggins</dc:creator><description>&lt;p&gt;Hi Wes, &lt;/p&gt;
&lt;p&gt;I was wondering how you would compare IEnumerable to implementing an abstract ForEach method in a base class? For example: &lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://functional-lists.googlecode.com/svn/trunk/FunctionalList.cs"&gt;http://functional-lists.googlecode.com/svn/trunk/FunctionalList.cs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Which one is likely to have better performance? What reasons would you choose one over the other?&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Christopher Diggins&lt;/p&gt;
</description></item><item><title>Community Convergence XXIV</title><link>http://blogs.msdn.com/wesdyer/archive/2007/03/23/all-about-iterators.aspx#2058481</link><pubDate>Mon, 09 Apr 2007 09:48:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2058481</guid><dc:creator>Charlie Calvert's Community Blog</dc:creator><description>&lt;p&gt;Recently my time has been taken up with a series of internal issues involving Beta1, C# Samples and various&lt;/p&gt;
</description></item><item><title>re: All About Iterators</title><link>http://blogs.msdn.com/wesdyer/archive/2007/03/23/all-about-iterators.aspx#2077177</link><pubDate>Tue, 10 Apr 2007 23:47:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2077177</guid><dc:creator>wesdyer</dc:creator><description>&lt;p&gt;Hi Christopher,&lt;/p&gt;
&lt;p&gt;Hope everything is going well. &amp;nbsp;I expect that the typical IEnumerable + static Foreach will do better in performance. &amp;nbsp;But try it out and tell me. &amp;nbsp;Specifically, try out the performance of your code against the latest LINQ CTP or Beta 1. &amp;nbsp;Also, you might want to consider making your code generic (add some Ts and Us).&lt;/p&gt;
</description></item><item><title>re: All About Iterators</title><link>http://blogs.msdn.com/wesdyer/archive/2007/03/23/all-about-iterators.aspx#2096031</link><pubDate>Thu, 12 Apr 2007 09:04:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2096031</guid><dc:creator>Peter Mullen</dc:creator><description>&lt;p&gt;Hi Wes,&lt;/p&gt;
&lt;p&gt;Your code for MoveNext() assigns this.current from an element in this.list. Your comments claim that MoveNext() only computes enough to realize the next element. But hasn't this.list been filled before the first call to MoveNext()?&lt;/p&gt;
&lt;p&gt;thanks,&lt;/p&gt;
&lt;p&gt;peter&lt;/p&gt;
</description></item><item><title>re: All About Iterators</title><link>http://blogs.msdn.com/wesdyer/archive/2007/03/23/all-about-iterators.aspx#2096129</link><pubDate>Thu, 12 Apr 2007 09:20:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2096129</guid><dc:creator>Peter Mullen</dc:creator><description>&lt;p&gt;Now I get it. The compiler generates different versions of MoveNext() based on the code that was in the original GetElements() method. Just like you said in the text.&lt;/p&gt;
&lt;p&gt;thanks,&lt;/p&gt;
</description></item><item><title>re: All About Iterators</title><link>http://blogs.msdn.com/wesdyer/archive/2007/03/23/all-about-iterators.aspx#2673112</link><pubDate>Wed, 16 May 2007 16:52:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2673112</guid><dc:creator>Joost Morsink</dc:creator><description>&lt;p&gt;When is your next article going to be posted? I'm checking this site daily for almost two months now :)&lt;/p&gt;
</description></item><item><title>re: All About Iterators</title><link>http://blogs.msdn.com/wesdyer/archive/2007/03/23/all-about-iterators.aspx#3355534</link><pubDate>Sun, 17 Jun 2007 12:28:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3355534</guid><dc:creator>Fduch</dc:creator><description>&lt;p&gt;It's fun. I &amp;quot;invented&amp;quot; the concept of iterators some time ago not knowing about this feature.&lt;/p&gt;
&lt;p&gt;Will VB ever have it?&lt;/p&gt;
</description></item><item><title>Immutability in C# Part Seven: More on Binary Trees</title><link>http://blogs.msdn.com/wesdyer/archive/2007/03/23/all-about-iterators.aspx#6809317</link><pubDate>Wed, 19 Dec 2007 23:01:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6809317</guid><dc:creator>Fabulous Adventures In Coding</dc:creator><description>&lt;p&gt;Lots of good comments on my previous post. To briefly follow up: One of the downsides of immutable tree&lt;/p&gt;
</description></item><item><title>Immutability in C# Part Seven: More on Binary Trees</title><link>http://blogs.msdn.com/wesdyer/archive/2007/03/23/all-about-iterators.aspx#6809668</link><pubDate>Wed, 19 Dec 2007 23:52:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6809668</guid><dc:creator>Noticias externas</dc:creator><description>&lt;p&gt;Lots of good comments on my previous post. To briefly follow up: One of the downsides of immutable tree&lt;/p&gt;</description></item><item><title>re: All About Iterators</title><link>http://blogs.msdn.com/wesdyer/archive/2007/03/23/all-about-iterators.aspx#6969930</link><pubDate>Thu, 03 Jan 2008 20:25:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6969930</guid><dc:creator>matthew</dc:creator><description>&lt;p&gt;&amp;gt; Will VB ever have it?&lt;/p&gt;
&lt;p&gt;do you mean vb.net or vb6?&lt;/p&gt;
</description></item><item><title>re: All About Iterators</title><link>http://blogs.msdn.com/wesdyer/archive/2007/03/23/all-about-iterators.aspx#7079115</link><pubDate>Fri, 11 Jan 2008 23:37:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7079115</guid><dc:creator>richard_deeming</dc:creator><description>&lt;p&gt;The performance of the Concat method for multiple chained iterators could be greatly improved with a fairly trivial tweak. Simply create a container class to hold all of the concatenated iterators, and iterate over them all in sequence:&lt;/p&gt;
&lt;p&gt;foreach (IEnumerable&amp;lt;T&amp;gt; iterator in iterators)&lt;/p&gt;
&lt;p&gt;foreach (T item in iterator)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;yield return item;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;On my system, using your test code, the built-in Concat method for 10000 items takes 4807629 ticks, whereas my version takes 4472 ticks.&lt;/p&gt;</description></item></channel></rss>