<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Comment Feed for Channel 9 - C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n/RSS"></atom:link>
	<image>
		<url>http://ecn.channel9.msdn.com/o9/ch9/43f4/eddf1fd3-8f54-4942-9cf6-9df400b943f4/C9LecturesSTLonSTLp4_100_ch9.jpg</url>
		<title>Channel 9 - C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<link></link>
	</image>
	<description>Welcome to another installment of C9 Lectures covering the powerful general C&amp;#43;&amp;#43; library, STL. Joining us once again is the great Stephan T. Lavavej, Microsoft&#39;s keeper of the STL cloth (this means he manages the partnership between the owners of STL (dinkumware) and Microsoft, including, of course, bug fixes and enhancements to the STL that ships as part of Visual C&amp;#43;&amp;#43;). Simply, Stephan is a C&amp;#43;&amp;#43; library developer.As is Stephan&#39;s nature, he elaborates on technical details in very substantive way. The Standard Template Library, orSTL, is a C&amp;#43;&amp;#43; library of container classes, algorithms, and iterators. STL provides many fundamental algorithms and data structures. Furthermore, the STL is a general-purpose library: its components are heavily parameterized, such that almost every component in the STL is a template. In part 4, Stephan explains his solution to writing a solver for the&amp;nbsp;Nurikabe puzzle using the STL (of course...). You will be introduced to some new concepts as well as use some of the things you have already learned.&amp;nbsp;Get the&amp;nbsp;output and&amp;nbsp;source code (v1) for Stephan&#39;s Nurikabe solver.Get the optimized output and source code(v1.2) for Stephan&#39;s Nurikabe solver. 1.2 adds new test cases, improves the output, and significantly speeds up certain test cases.&amp;nbsp;1.2 is a better foundation for the performance exploration that Stephan suggested for the homework assignment. You&#39;re doing your homework, right? Enjoy! Learn!Books mentioned by Stephen: The C&amp;#43;&amp;#43; Standard Library: A Tutorial And Reference by Nicolai M. JosuttisEffective STL by Scott Meyers [STL Introduction lecture links] Part 1 (sequence containers) Part 2 (associative containers) Part 3 (smart pointers) Part 4 (Nurikabe solver) - see Wikipedia&#39;s article and Stephan&#39;s updated source code Part 5 (Nurikabe solver, continued) Part 6 (algorithms and functors) Part 7 (algorithms and functors, continued) Part 8 (regular expressions) Part 9 (rvalue references) Part 10 (type traits) </description>
	<link></link>
	<language>en</language>
	<pubDate>Mon, 20 May 2013 05:22:12 GMT</pubDate>
	<lastBuildDate>Mon, 20 May 2013 05:22:12 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>Another awesome video from Stephen <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-2.gif' alt='Big Smile' /> </p>
<p>I'm still quite new to the STL, though I do like C&#43;&#43;.</p>
<p>I was wondering if theres a C&#43;&#43; class that handles HTTPRequest without using .NET.</p>
<p>I was thinking about a writing a RSS Reader that checks a RSS feed every few hours/days/minutes whatever,</p>
<p>and if it finds what I'm looking for, it notifies me using a notifer icon.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>posted by Tominator2005</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634194977030000000</link>
		<pubDate>Tue, 07 Sep 2010 23:08:23 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634194977030000000</guid>
		<dc:creator>Tominator2005</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>So, I opened the source file, saw a nearly 400 line solve function with minimal &quot;island&quot; comments and pretty much lost all interest in what the program does. Just my two cents worth... Does it really have to be this unstructured to perform? Can it be any
 less structured and still be instructive (/sarcasm)? Was it necessary to cram it all into one .cpp file, given that it was part of a zip&nbsp;archive?</p>
<p>&nbsp;</p>
<p>Just my 2 cents...</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>posted by Corrector2</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634194981380000000</link>
		<pubDate>Tue, 07 Sep 2010 23:15:38 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634194981380000000</guid>
		<dc:creator>Corrector2</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>The commentary is in the video. Play the video, listen, watch, open the sources (v1) and follow along <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /> Yes, the time algorithm isn't as efficient as you'd like, but knowledge requires real time. There is no getting around it. Well, there's virtual time,
 but what's the delivery vehicle, exactly? Better would be&nbsp;synching viewers' VS editors with Stephan's presentation.
</p>
<p>&nbsp;</p>
<p>Hmm.</p>
<p>&nbsp;</p>
<p>C</p>
<p>posted by Charles</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634195073470000000</link>
		<pubDate>Wed, 08 Sep 2010 01:49:07 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634195073470000000</guid>
		<dc:creator>Charles</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>Well, he does state that the solve function, the meat of this application,&nbsp;will be covered in the next video, so I suppose we can take a wait and see approach. However, basic OO/structured programming tenets&nbsp;do not condone the use of 400 line &quot;super-do-everything&quot;
 functions, of which solve() is one. Bottom line is&nbsp;that we'll have to give&nbsp;Stephan the benefit of the doubt and let him elaborate in the next episode...</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>posted by Corrector2</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634195123430000000</link>
		<pubDate>Wed, 08 Sep 2010 03:12:23 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634195123430000000</guid>
		<dc:creator>Corrector2</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>[Tominator2005]<br />&gt; I was wondering if theres a C&#43;&#43; class that handles HTTPRequest without using .NET.</p>
<p>If you want to do anything with networking, I suggest looking at Boost.Asio, documented at
<a href="http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio.html">http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio.html</a> . (Asio stands for Asynchronous I/O.) In particular, their examples at
<a href="http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio/examples.html">
http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio/examples.html</a> demonstrate HTTP. I have not yet used Asio myself, but I was extremely impressed with it at BoostCon 2010.</p>
<p>[Corrector2]<br />&gt; So, I opened the source file, saw a nearly 400 line solve function with<br />&gt; minimal &quot;island&quot; comments and pretty much lost all interest in what the program does.</p>
<p>My apologies. Please give it a second chance - it is not nearly as complicated as its length suggests.</p>
<p>I'm not sure what you mean by &quot;island comments&quot;. I assume you're referring to big comment blocks. I carefully commented most of the file, especially the data structures, with short comments. As I mentioned in either Part 4 or 5, typically I let my code speak
 for itself, and I reserve comments for inherently complicated code (for example, I usually don't include comments like &quot;Validate width and height.&quot; or &quot;Parse the string.&quot;). In this case, though, I included almost as many comments as possible without overcommenting
 (&quot;&#43;&#43;i; // Increment i&quot; being an obvious example of a comment that should not exist). The short comments do tend to thin out in the complicated functions like unreachable(), which assume an increasing level of familiarity with the STL, the problem domain, and
 the algorithm. However, I did include two gigantic comment blocks, for the complicated analysis steps. There's a big one explaining confinement that begins with &quot;A region would be &quot;confined&quot; if it could not be completed.&quot;, with a diagram (!)&nbsp;for the most subtle
 part, and another big one explaining unreachability that begins with &quot;The cell at (x_root, y_root) is unreachable if&quot;. Instead of explaining individual implementation steps, these big comment blocks explain concepts that are absolutely critical to understanding
 the following code.</p>
<p>Do you really want a big comment block for the step &quot;Look for complete islands.&quot;? The single-line comment explains what's going on, and the code explains how it's finding complete islands (it looks for numbered regions with sizes equal to their numbers -
 and the &quot;class Region&quot; comments explain how that's tracked). This is a perfect example of code that should NOT have a gigantic comment.</p>
<p>I did consider breaking solve() up into smaller member functions, which I mentioned in either Part 4 or 5 (they were filmed back-to-back; I suspect it was Part 5). I decided against it, because solve() simply performs one step after another, and the steps
 are essentially independent. Introducing smaller member functions would have increased the total amount of code, and I didn't feel that it would improve clarity. Perhaps this judgment was incorrect.</p>
<p>&gt; Does it really have to be this unstructured to perform?</p>
<p>No - solve()'s length is unrelated to its performance.</p>
<p>&gt; Was it necessary to cram it all into one .cpp file, given that it was part of a zip archive?</p>
<p>It's a single class, with a small nested class, and a main() function. Unlike solve(), which I thought about breaking up, I felt no urge to break this up into multiple headers and source files. It's a large and realistic example, but not production code.
 If it were production code, Grid's class definition would certainly appear in a header, with member function implementations in source files, and it might even be pimpled to reduce compile-time dependencies (observe that its public interface is extremely small,
 while its private interface is large and refers to many things - in this case all of those things are from the Standard Library, but when they're from other code that's actively changing, that's a motivation to pimpl).</p>
<p>I'll see about breaking up solve() in version 1.3. Although I don't think it's the end of the world, your points are valid, and I'm probably desensitized to long functions.</p>
<p>&gt; However, basic OO/structured programming tenets do not condone the<br />&gt; use of 400 line &quot;super-do-everything&quot; functions, of which solve() is one.</p>
<p>The most important lessons from structured programming are that complex behavior should be encapsulated in simple functions, and that for/while loops are the antidote to poisonous gotos. solve() encapsulates very complex behavior - it performs a step of
 grid analysis - in a very simple interface. (It has to be told whether to be verbose and whether guessing is permitted - both of which have defaults - and it returns whether more analysis is required, or if not, why not.) As far as the outside world is concerned,
 solve() is perfectly structured. Internally, you may argue that solve() could be further structured, by independently encapsulating its steps of analysis. That is reasonable, although my first reaction was that it would simply move blocks of code around, not
 make those blocks easier to understand, or avoid duplication. (unreachable(), confined(), and other helpers are called more than once, which is why they're separate member functions.) Hopefully you can agree that my original point of view was at least somewhat
 reasonable.</p>
<p>As for object-oriented programming, its most important lesson is that state and behavior should be encapsulated in classes. Grid perfectly satisifes that and there are absolutely no problems there. Region is not especially encapsulated, but as I explained
 in either Part 4 or 5, that's because it's internal to Grid, and Grid is ultimately responsible for maintaining Region's invariants.</p>
<p>(Some people think that &quot;object-oriented programming&quot; means that everything should live in inheritance hierarchies. I disagree extremely strongly. Fortunately, that doesn't appear to be an issue here.)</p>
<p>posted by STL</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634195189060000000</link>
		<pubDate>Wed, 08 Sep 2010 05:01:46 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634195189060000000</guid>
		<dc:creator>STL</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>Since most of the issues revolved around solve, let me be more clear in my argument:</p>
<p>&nbsp;</p>
<p>- A complex function, even if it is mostly one containing linear flow can be broken down into several simple functions in order to become more hierarchical and less linear. Let me give a simple example to elucidate my point:</p>
<p>&nbsp;</p>
<p>Instead of a long function such as:</p>
<p>&nbsp;</p>
<p><strong>void Car::Build()</strong></p>
<p><strong>{<br />&nbsp;&nbsp; // Build the frame</strong></p>
<p><strong>&nbsp;&nbsp; ... build the frame code</strong></p>
<p><strong>&nbsp;</strong></p>
<p><strong>&nbsp;&nbsp; // Add doors</strong></p>
<p><strong>&nbsp;&nbsp; ... add doors code</strong></p>
<p><strong>&nbsp;</strong></p>
<p><strong>&nbsp;&nbsp; // Insert engine</strong></p>
<p><strong>&nbsp;&nbsp; ... insert engine code</strong></p>
<p><strong>&nbsp;</strong></p>
<p><strong>&nbsp;&nbsp; // Insert transmission</strong></p>
<p><strong>&nbsp;&nbsp; ... insert&nbsp;transmission code</strong></p>
<p><strong>&nbsp;</strong></p>
<p><strong>&nbsp;&nbsp; // Insert upholstery</strong></p>
<p><strong>&nbsp;&nbsp; ... insert upholstery code</strong></p>
<p><strong>&nbsp;</strong></p>
<p><strong>&nbsp;&nbsp; // Paint the car</strong></p>
<p><strong>&nbsp;&nbsp; ... paint the car code</strong></p>
<p><strong>&nbsp;</strong></p>
<p><strong>&nbsp;&nbsp; // Whatever else needs to be done</strong></p>
<p><strong>&nbsp;&nbsp; ... whatever else needs to be done</strong></p>
<p><strong>}</strong></p>
<p>&nbsp;</p>
<p>It is much easier to see (the comments are not part of the code, I am just adding them to show what the functions being called do for the purpose of explaining my point):</p>
<p>&nbsp;</p>
<p><strong>void Car::Build()</strong></p>
<p><strong>{<br />&nbsp;&nbsp; BuildFrame(...); // Calls AddDoors()</strong></p>
<p><strong>&nbsp;&nbsp; AddInternalParts(...); // Calls AddEngine(), AddTransmission(), AddUphostery()?, etc...</strong></p>
<p><strong>&nbsp;&nbsp; AddBodyParts(...); // Calls AddDoors()</strong></p>
<p><strong>&nbsp;&nbsp; Paint(...);</strong></p>
<p><strong>}</strong></p>
<p>&nbsp;</p>
<p>Now the Build function is easy to eye over and&nbsp;comprehend. If the&nbsp;programmer wishes to look into detail and see how&nbsp;each step is actually implemented, he can go into each of the functions being called and examine them (or look at call graphs, etc...).</p>
<p>&nbsp;</p>
<p>By creating a deeper (rather than shallower) Build() function, it is much easier to comprehend in a top down (rather than bottom up) fashion. This is how most people solve and analyze problems - from an abstract&nbsp;problem statement&nbsp;to analyzing (i.e., &quot;sweating&quot;)
 the details.</p>
<p>&nbsp;</p>
<p>If you:</p>
<p>&nbsp;</p>
<ol>
<li>Break up your solve function into sub-tasks (functions) </li><li>Give them meaningful names </li><li>Only call these sub-tasks from within solve </li></ol>
<p>Then, it would be much easier to see what solve does as a whole and there would be no performance penalty in doing this, to boot, because these sub-tasks would probably still be gross tasks. If any of the sub-tasks are still complex, you can further decompose
 them into more sub-tasks.</p>
<p>&nbsp;</p>
<p>A developer reading solve would drill down to the level of interest to him, while seeing the big picture all along the way. Compare this to having to gloss over 400 lines of code, even if only looking for comments,&nbsp;in order to try to figure out what solve
 does.</p>
<p>&nbsp;</p>
<p>My two cents...</p>
<p>posted by Corrector2</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634195559680000000</link>
		<pubDate>Wed, 08 Sep 2010 15:19:28 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634195559680000000</guid>
		<dc:creator>Corrector2</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<div id="ctl00_MainPlaceHolder_EntryList_ctl05_EntryTemplate_ReplyTo_InReplyToContainer" class="inReplyTo">
<div class="inReplyToControls">
<div class="inReplyToLink"><a id="ctl00_MainPlaceHolder_EntryList_ctl05_EntryTemplate_ReplyTo_InReplyToHyperLink" class="expand" href="">In reply to {0}</a>
</div>
<div class="inReplyToGoToLink"></div>
</div>
<div id="ctl00_MainPlaceHolder_EntryList_ctl05_EntryTemplate_ReplyTo_InReplyToBody" class="inReplyToBody">
</div>
</div>
<div id="ctl00_MainPlaceHolder_EntryList_ctl05_EntryTemplate_AttachmentContainer" class="attachment">
<span id="ctl00_MainPlaceHolder_EntryList_ctl05_EntryTemplate_DownloadLabel" class="downloadLabel">Download:</span><span id="ctl00_MainPlaceHolder_EntryList_ctl05_EntryTemplate_PendingLabel" class="pendingLabel">[Pending]</span>
</div>
<p>[Tominator2005]<br />&gt; I was wondering if theres a C&#43;&#43; class that handles HTTPRequest without using .NET.</p>
<p>If you want to do anything with networking, I suggest looking at Boost.Asio, documented at
<a href="http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio.html">http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio.html</a> . (Asio stands for Asynchronous I/O.) In particular, their examples at
<a href="http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio/examples.html">
http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio/examples.html</a> demonstrate HTTP. I have not yet used Asio myself, but I was extremely impressed with it at BoostCon 2010.</p>
<p>&nbsp;</p>
<p>Thanks I'll take a look at that.</p>
<p>&nbsp;</p>
<p>Charles,</p>
<p>Any idea when's the next video will be uploaded?</p>
<p>posted by Tominator2005</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634195596350000000</link>
		<pubDate>Wed, 08 Sep 2010 16:20:35 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634195596350000000</guid>
		<dc:creator>Tominator2005</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>Yes. Next week.</p>
<p>C</p>
<p>posted by Charles</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634195614410000000</link>
		<pubDate>Wed, 08 Sep 2010 16:50:41 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634195614410000000</guid>
		<dc:creator>Charles</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>One other niggle, Stephen.</p>
<p>When is it best to use helper methods?</p>
<p>I've heard a lot of people say they're bad.</p>
<p>Tom</p>
<p>posted by Tominator2005</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634195821380000000</link>
		<pubDate>Wed, 08 Sep 2010 22:35:38 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634195821380000000</guid>
		<dc:creator>Tominator2005</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>Check out version 1.3 at <a href="http://cid-e66e02dc83efb165.office.live.com/browse.aspx/nurikabe">
http://cid-e66e02dc83efb165.office.live.com/browse.aspx/nurikabe</a></p>
<p>// 1.3 (9/8/2010) - Reorganized Grid::solve() into smaller member functions.</p>
<p>Thank you, Corrector2, for helping me to improve my code.</p>
<p>[Tominator2005]<br />&gt; When is it best to use helper methods?<br />&gt; I've heard a lot of people say they're bad.</p>
<p>Nonsense. (I've never even heard that before.) Helper functions (both free and member) are wonderful. They are absolutely necessary when called more than once, and as Corrector2 patiently explained, they are useful even when called exactly once.</p>
<p>If you look at my Grid, its public member functions are supported by its private member functions. This is how basically every well-designed class works. Whether you refer to the private member functions as &quot;helpers&quot; doesn't change the fact that you need
 them.</p>
<p>When I wrote my solver, I planned from the beginning to have Regions, and I knew that I'd need add_region(), fuse_region(), and so forth. As I wrote more code, I noticed that I was repeatedly looking at a cell, figuring out which of its neighbors were within
 the bounds of the grid, and doing something for each neighbor. I lifted that out into for_valid_neighbors(), and as I noticed common operations, I created insert_valid_neighbors() and insert_valid_unknown_neighbors() to remove code duplication.</p>
<p>posted by STL</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634196083410000000</link>
		<pubDate>Thu, 09 Sep 2010 05:52:21 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634196083410000000</guid>
		<dc:creator>STL</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>Looking much better in 1.3! I'd still do more refactoring on unreachable(), but it's a whole world better than before...</p>
<p>posted by Corrector2</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634196788420000000</link>
		<pubDate>Fri, 10 Sep 2010 01:27:22 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634196788420000000</guid>
		<dc:creator>Corrector2</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>I noted in case of errors exceptions are thrown in your code (e.g. throw runtime_error, throw logic_error...) with a proper error message.</p>
<p>The error message is an English string stored in a char-based string. In case of production-quality code there would be a need to localize error messages. But std::exception class seems to support only char* strings. How could this localization problem be
 solved? Should a new class be derived from std::exception, adding Unicode string supports or some form of string table? Should every library define its own custom localizable std::exception class?
</p>
<p>Thanks.</p>
<p>&nbsp;</p>
<p>posted by C64</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634197106630000000</link>
		<pubDate>Fri, 10 Sep 2010 10:17:43 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634197106630000000</guid>
		<dc:creator>C64</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>[C64]<br />&gt; In case of production-quality code there would be a need to localize error messages.</p>
<p>Yep!</p>
<p>&gt; But std::exception class seems to support only char* strings.</p>
<p>Correct. std::exception::what() is intended to be seen by developers and not by end users. You could put UTF-8 in there, but you only get one what().</p>
<p>&gt; How could this localization problem be solved?</p>
<p>Derive from std::exception (at a minimum; deriving from the &lt;stdexcept&gt; classes would be better), and tag your exceptions with string resource identifiers. Then you can load the appropriate string at runtime based on the user's language.</p>
<p>Also, see Boost.Exception: <a href="http://www.boost.org/doc/libs/1_44_0/libs/exception/doc/boost-exception.html">
http://www.boost.org/doc/libs/1_44_0/libs/exception/doc/boost-exception.html</a> The Standard Library's exceptions are just a starting point.</p>
<p>posted by STL</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634197497140000000</link>
		<pubDate>Fri, 10 Sep 2010 21:08:34 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634197497140000000</guid>
		<dc:creator>STL</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>Thanks STL,</p>
<p>&nbsp;</p>
<p>Ok, my bad. It wasn't helper functions but Helper Classes, as in classes with static functions,</p>
<p>it just came up on a Google Search for Helper functions, and I saw the word Helper and Evil,
</p>
<p>and totally misread and misconceived that the idea of helper functions were evil.</p>
<p>&nbsp;</p>
<p>Looking good btw. I might try Boost ASIO, but its not as simple as creating a instance</p>
<p>of HTTPRequest to get html from a web page or xml from a RSS feed.</p>
<p>posted by Tominator2005</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634198199140000000</link>
		<pubDate>Sat, 11 Sep 2010 16:38:34 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634198199140000000</guid>
		<dc:creator>Tominator2005</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>I do enjoy watching these STL videos and request a lot more please&nbsp; <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-13.gif' alt='Angel' /> </p>
<p>&nbsp;</p>
<p>But why does it take so long to release them ?</p>
<p>&nbsp;</p>
<p>Also i must ask: how blood hard is it to make videos without black&nbsp;stripes ?!</p>
<p>To me this is a very obvious sloppy mistake (there are other mistakes too but you get the point). The noob editing this video needs a go-back-to-school slap.</p>
<p>Seems to me that the stl videos get low priority, how come ? You (Charles) did say more C&#43;&#43; videos are coming and that they were
<strong>important </strong>to you and the community so was the 'important' part yet another microsoft PR lie ?</p>
<p>What is your time table with the other C&#43;&#43; videos, i'm craving C&#43;&#43; videos and my patience is running low after a few weeks..month of waiting.</p>
<p>&nbsp;</p>
<p>I'm trying to express my worry and concern here.</p>
<p>&nbsp;</p>
<p>Charles, give that sloppy noob video editor a friendly slap from me.&nbsp;</p>
<p>&nbsp;</p>
<p>posted by Mr Crash</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634200800550000000</link>
		<pubDate>Tue, 14 Sep 2010 16:54:15 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634200800550000000</guid>
		<dc:creator>Mr Crash</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>wow, Part 5 you managed to&nbsp;mess-up&nbsp;even more (out of sync, black stripes, etc), do you get paid to do it
<strong>wrong </strong>?!</p>
<p>posted by Mr Crash</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634200854390000000</link>
		<pubDate>Tue, 14 Sep 2010 18:23:59 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634200854390000000</guid>
		<dc:creator>Mr Crash</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>What's wrong with these videos, exactly?&nbsp; Parts 4 and 5 were encoded by somebody who is far from a noob... That said, I will pass along your feedback to him. Would be nice if you could remove your harshness and replace with useful feedback. Please do provide
 it.</p>
<p>&nbsp;</p>
<p>These release as soon as we can make them. Stephan has a <em>very</em> busy day job, so we get him into the studio when it's convenient for him. There is a lot of C&#43;&#43;content on C9 (and there has been for a long time....). New content in on the horizon including
 more lectures.</p>
<p>&nbsp;</p>
<p>Re: Part 5: this is being corrected. My apologies.<br />C</p>
<p>posted by Charles</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634200898760000000</link>
		<pubDate>Tue, 14 Sep 2010 19:37:56 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634200898760000000</guid>
		<dc:creator>Charles</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>[Tominator2005]<br />&gt; It wasn't helper functions but Helper Classes, as in classes with static functions,</p>
<p>Writing a class that contains only static member functions is usually silly. (Non-member functions in namespaces would be a better idea.) However, there's at least one case where such classes are definitely useful. Function templates cannot be partially
 specialized; they can be overloaded, which has the same effect 98% of the time. The rest of the time, when you really do need partial specialization, you can partially specialize a class with static member functions, and that'll get the job done.</p>
<p>[Mr Crash]<br />&gt; I do enjoy watching these STL videos and request a lot more please<br />&gt; But why does it take so long to release them ?</p>
<p>Glad you like them. Editing is a black box to me, but I know what determines my frequency of filming. As you're aware, I work with Dinkumware to maintain VC's implementation of the C&#43;&#43; Standard Library. Because&nbsp;this implementation is inherently very complex,
 and&nbsp;the C&#43;&#43;0x Working Paper has been a fast-moving target for the last several years, this is a lot of work! I try to write blog posts and film videos whenever I can, but this competes for time with my development work (i.e. making VC11's STL even more awesome
 than VC10's), so I have to balance them.</p>
<p>In terms of time, Parts 4 and 5 were even more expensive than 1, 2, and 3, because I wrote a large example program. I almost never get the chance to do that. Part 6 (which will cover algorithms and customizing them with functors, unless I think of a better
 idea) will go back to my (organized) stream of consciousness, which requires little advance preparation, but I'm on vacation this week, so I won't be able to film it immediately.</p>
<p>posted by STL</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634202574010000000</link>
		<pubDate>Thu, 16 Sep 2010 18:10:01 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634202574010000000</guid>
		<dc:creator>STL</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>@<a href="/Shows/Going&#43;Deep/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634202574010000000">STL</a>:</p>
<p>&gt; But why does it take so long to release them ?</p>
<p>I was unclear here, sorry. I meant the time between filming and release video to public</p>
<p>Does the video editing/encoding take that long ? Do you use some kind of queue system?</p>
<p>posted by Mr Crash</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634204158720000000</link>
		<pubDate>Sat, 18 Sep 2010 14:11:12 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634204158720000000</guid>
		<dc:creator>Mr Crash</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>@<a href="/Shows/Going&#43;Deep/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634200898760000000">Charles</a>:ok, i guess i could help with translating my feedback&nbsp; <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-5.gif' alt='Wink' />
<br />Do you have an e-mail address i can send the feedback to (i plan to include some pictures to better show what i mean)</p>
<p>posted by Mr Crash</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634204160570000000</link>
		<pubDate>Sat, 18 Sep 2010 14:14:17 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634204160570000000</guid>
		<dc:creator>Mr Crash</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>Mr_Crash!&nbsp; Have you ever used Windows Media Encoder?&nbsp; Do try, and in the meantime go visit your family in another state <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-4.gif' alt='Tongue Out' />
</p>
<p>Vector of vectors is appropriate for a text editor, less appropriate for relational data where you want to do things to rows, and totally inappropriate for a matrix, unless the matrix is so huge that you cannot keep it all in RAM --- but then, please explain
 the options for low RAM environments because STL is not an option for various reasons.&nbsp; And, even if you insist, the interface class should be called Matrix (or, in fact, Grid proper) and use a vector of vectors as an implementation detail.</p>
<p>And I do not think that explaining the viewers that the numbers count the fields in contiguous white areas would be such a waste of time.&nbsp; I am watching your videos in circumstances where I cannot type.</p>
<p>posted by giecrilj71pl</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634206539990000000</link>
		<pubDate>Tue, 21 Sep 2010 08:19:59 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634206539990000000</guid>
		<dc:creator>giecrilj71pl</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>[giecrilj71pl]<br />&gt; Vector of vectors is appropriate for a text editor, less appropriate for relational data where you want to do things to rows, and totally inappropriate for a matrix</p>
<p>It works fine for Nurikabe. (I agree with you that solutions should be chosen so that they're appropriate for the problem domain - and the problem domain in this example is Nurikabe.)</p>
<p>One of my todos is to investigate storing the cells in a 1D vector. I actually did that during my development (it makes parsing somewhat easier, as cells can be stored in input order), but I never thought about using 1D coordinates everywhere as well. I
 suspect that my reliance on pair&lt;int, int&gt; may affect performance.</p>
<p>&gt; but then, please explain the options for low RAM environments because STL is not an option for various reasons.</p>
<p>Actually, the STL is extremely good at conserving space.</p>
<p>&gt; And, even if you insist, the interface class should be called Matrix (or, in fact, Grid proper) and use a vector of vectors as an implementation detail.</p>
<p>My Nurikabe Grid class uses a vector of vectors as an implementation detail. It is strongly encapsulated and nobody outside of the Grid is aware of its presence. I saw, and continue to see, no reason to further encapsulate the Grid's storage. (On the other
 hand, Region is a nontrivial data structure, which benefits greatly from the partial encapsulation that I gave to it.)</p>
<p>&gt; And I do not think that explaining the viewers that the numbers<br />&gt; count the fields in contiguous white areas would be such a waste<br />&gt; of time.&nbsp; I am watching your videos in circumstances where I cannot type.</p>
<p>I'm sorry, I don't understand. Are you saying that I should have explained the meaning of the numbers in a Nurikabe grid? As I recall, I clearly stated in the video that Wikipedia's Nurikabe page was required reading. I also linked to it in the source code.</p>
<p>posted by STL</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634207193260000000</link>
		<pubDate>Wed, 22 Sep 2010 02:28:46 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634207193260000000</guid>
		<dc:creator>STL</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[Thanks for your great lectures, I appreciate how you got into the scaling factors of the STL&nbsp;containers. &nbsp;The O factors have never been explained in plain english before!<br />vector::reserve() can make populating a big list 100x faster! You should mention the performance improvement in future lectures. I use the following function, same as mentioned to check the time:<br />#include &lt;windows.h&gt;&nbsp;double CurrentTime (){ LARGE_INTEGER freq; LARGE_INTEGER time; QueryPerformanceFrequency( &amp;freq) ;&nbsp;&nbsp; QueryPerformanceCounter(&amp;time);&nbsp;&nbsp; double ct = (double)time.QuadPart / (double)freq.QuadPart;&nbsp;&nbsp; return ct;}<br />I am a Java programmer, using shared_ptr and STL containers, as well at std::string, the programming style has become intuitively very similar!<br />The nurikabe program is quite verbose for a puzzle that only needs to follow 8 simple rules. Can someone try to code this in F# and see how it compares?<br />&nbsp;<p>posted by Scott C</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634207330470000000</link>
		<pubDate>Wed, 22 Sep 2010 06:17:27 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634207330470000000</guid>
		<dc:creator>Scott C</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<blockquote>
<p><a class="permalink" title="Comment Permalink" href="/Shows/Going&#43;Deep/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634207193260000000">16 hours&nbsp;ago</a>,
<a href="/Niners/STL">STL</a> wrote</p>
<br /><p>&gt; but then, please explain the options for low RAM environments because STL is not an option for various reasons.</p>
<p>Actually, the STL is extremely good at conserving space.</p>
</blockquote>
<p>Your correctly observed in Installment 1 how the triple A-I-C saves us from having A*C implementations.&nbsp; However, this only applies to
<em>source code</em>, because the object code will contain (up to) A*C implementations (actually A*C*T).&nbsp; Of course, most code sets do not use all pairs; however, depending on the domain, the object size can skyrocket.&nbsp; This is not a big problem for algorithms
 like find, and any algorithms you would type inline off your head, but complex and long template algorithms do exist, e.g. sort.&nbsp; That was a significant problem for Adobe when they created their image manipulation library.</p>
<p>posted by giecrilj71pl</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634207803820000000</link>
		<pubDate>Wed, 22 Sep 2010 19:26:22 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634207803820000000</guid>
		<dc:creator>giecrilj71pl</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<blockquote>
<p><a class="permalink" title="Comment Permalink" href="/Shows/Going&#43;Deep/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634207193260000000">16 hours&nbsp;ago</a>,
<a href="/Niners/STL">STL</a> wrote</p>
<p>[giecrilj71pl]<br />&gt; And, even if you insist, the interface class should be called Matrix (or, in fact, Grid proper) and use a vector of vectors as an implementation detail.</p>
<p>My Nurikabe Grid class uses a vector of vectors as an implementation detail. It is strongly encapsulated and nobody outside of the Grid is aware of its presence. I saw, and continue to see, no reason to further encapsulate the Grid's storage. (On the other
 hand, Region is a nontrivial data structure, which benefits greatly from the partial encapsulation that I gave to it.)</p>
</blockquote>
<p>On the other hand, a Matrix is a fairly general data structure, and if you promoted your implementation to a separate component, you could use it elsewhere.&nbsp; But then my criticism at your implementation choice would be much more valid, so it was actually
 clever to hide it <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-13.gif' alt='Angel' /> </p>
<p>posted by giecrilj71pl</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634207809250000000</link>
		<pubDate>Wed, 22 Sep 2010 19:35:25 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634207809250000000</guid>
		<dc:creator>giecrilj71pl</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[
<p>[Scott C]<br />&gt; Thanks for your great lectures, I appreciate how you got into the scaling factors of the STL containers.<br />&gt; The O factors have never been explained in plain english before!</p>
<p>&nbsp;</p>
<p>I'm glad to be of service.</p>
<p>&nbsp;</p>
<p>&gt; vector::reserve() can make populating a big list 100x faster!<br />&gt; You should mention the performance improvement in future lectures.</p>
<p>&nbsp;</p>
<p>Actually, this is not true. Understanding why is enlightening.</p>
<p>&nbsp;</p>
<p>Imagine that you're using an STL implementation with a 2x growth factor for vector. Then you push_back() N = 2^20 &#43; 1 = 1048577 elements. (This is not a rigorous mathematical proof because I am not a mathematician, but the logic is sound, and insensitive<br />to my example N.) How many element copies during reallocation have been performed? (I have sneakily chosen N to maximize the number of element copies relative to the number of final elements; i.e. the worst-case ratio.) Well, look at the vector's capacity()<br />as it underwent reallocation. It was 0, 1, 2, 4, 8, 16, 32, ..., 1048576 (the capacity before pushing back the last element), 2097152 (the final capacity). The number of element copies performed was 1 &#43; 2 &#43; 4 &#43; 8 &#43; ... &#43; 1048576 = 2097151. So, with N elements,<br />the worst-case number of element copies during reallocation is almost exactly 2N. (This is what &quot;linear time&quot; means, and we've just discovered the constant factor associated with it.)</p>
<p>&nbsp;</p>
<p>Because reserve() eliminates unnecessary element copies during reallocation, when you use it, you'll construct exactly N elements. So, with a 2x growth factor STL (like GCC's libstdc&#43;&#43;), calling reserve() will improve your performance by at most 2x, ignoring<br />other factors (like the cost of an allocation itself). Not 100x.</p>
<p>&nbsp;</p>
<p>With a 1.5x growth factor STL, like VC's, the numbers change but the principles stay the same. Suppose you push_back() N elements, where N is just over a capacity boundary. (Because of the 1.5x growth factor and integer arithmetic, these boundaries aren't<br />convenient to exactly calculate, but 1049869 is the first boundary over a million, so you could use N = 1049870 as a concrete example.)</p>
<p>&nbsp;</p>
<p>The last reallocation copied N - 1 elements, and then pushed back 1 more. I'm going to call that approximately N copies (ignoring the &quot;- 1&quot; is okay). The reallocation before that copied N / 1.5 = (2/3) * N elements. The one before that copied (2/3)^2 * N<br />elements, and so forth. The total number of copies is approximately (ignoring the integer arithmetic is also okay)</p>
<p>&nbsp;</p>
<p>N &#43; (2/3) * N &#43; (2/3)^2 * N &#43; (2/3)^3 * N &#43; ...</p>
<p>&nbsp;</p>
<p><a href="http://en.wikipedia.org/wiki/Geometric_series#Sum">http://en.wikipedia.org/wiki/Geometric_series#Sum</a> explains that 1 &#43; r &#43; r^2 &#43; r^3 &#43; ... = 1 / (1 - r), so we've performed N * 1 / (1 - (2/3)) = N * 1 / (1/3) = 3N copies.</p>
<p>&nbsp;</p>
<p>So with VC's implementation, calling reserve() will improve your performance by at most 3x. Let's test this experimentally:</p>
<p>&nbsp;</p>
<p><pre class="brush: cpp">C:\Temp&gt;type meow.cpp
#include &lt;iostream&gt;
#include &lt;ostream&gt;
#include &lt;vector&gt;
#include &lt;windows.h&gt;
using namespace std;

long long counter() {
    LARGE_INTEGER li;
    QueryPerformanceCounter(&amp;li);
    return li.QuadPart;
}

long long frequency() {
    LARGE_INTEGER li;
    QueryPerformanceFrequency(&amp;li);
    return li.QuadPart;
}

void print_time(const long long start, const long long finish, const char * const s) {
    cout &lt;&lt; s &lt;&lt; &quot;: &quot; &lt;&lt; (finish - start) * 1000.0 / frequency() &lt;&lt; &quot; ms&quot; &lt;&lt; endl;
}

int main() {
    const int N = 60540697 &#43; 1;

    for (int k = 0; k &lt; 5; &#43;&#43;k) {
        {
            const long long start = counter();

            vector&lt;int&gt; v;

            for (int i = 0; i &lt; N; &#43;&#43;i) {
                v.push_back(1729);
            }

            const long long finish = counter();

            print_time(start, finish, &quot;Normal&quot;);
        }

        {
            const long long start = counter();

            vector&lt;int&gt; v;

            v.reserve(N);

            for (int i = 0; i &lt; N; &#43;&#43;i) {
                v.push_back(1729);
            }

            const long long finish = counter();

            print_time(start, finish, &quot;Reserve&quot;);
        }
    }
}

C:\Temp&gt;cl /EHsc /nologo /W4 /MT /O2 /GL meow.cpp
meow.cpp
Generating code
Finished generating code

C:\Temp&gt;meow
Normal: 1012.54 ms
Reserve: 311.053 ms
Normal: 908.927 ms
Reserve: 294.182 ms
Normal: 909.3 ms
Reserve: 316.129 ms
Normal: 890.19 ms
Reserve: 313.943 ms
Normal: 889.658 ms
Reserve: 314.778 ms</pre></p>
<p>&nbsp;</p>
<p>After the numbers stop bouncing around, the observed speedup is roughly 889.658/314.778 = 2.83x, which agrees with the theoretical calculation above.</p>
<p>&nbsp;</p>
<p>&gt; The nurikabe program is quite verbose for a puzzle that only needs to follow 8 simple rules.</p>
<p>&nbsp;</p>
<p>Simple rules don't imply simple solvers.</p>
<p>&nbsp;</p>
<p>[giecrilj71pl]<br />&gt; That was a significant problem for Adobe when they created their image manipulation library.</p>
<p>&nbsp;</p>
<p>&quot;Template code bloat&quot; can be an issue for other libraries, but it isn't a major problem for the STL itself, which has few truly large algorithms, and doesn't actually have that many containers.</p>
<p>&nbsp;</p>
<p>I'll also point out that /OPT:REF,ICF discards unreferenced functions and folds binary-identical functions, so binary-identical template instantiations (like for A *, B *, C *) are harmless. Binary-different template instantiations are maximizing runtime<br />perf at the (typically minor) cost of executable size. If you want to reduce the amount of generated code, you'll typically need something like type erasure, which has runtime costs.</p>
<p>&nbsp;</p>
<p>&gt; On the other hand, a Matrix is a fairly general data structure, and if you promoted your implementation to a separate component, you could use it elsewhere.</p>
<p>&nbsp;</p>
<p>The Nurikabe grid isn't a mathematical matrix.</p>
<p>posted by STL</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634207976340000000</link>
		<pubDate>Thu, 23 Sep 2010 00:13:54 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634207976340000000</guid>
		<dc:creator>STL</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[<blockquote><p><a class="permalink" title="Comment Permalink" href="/Shows/Going&#43;Deep/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634207976340000000">4 days&nbsp;ago</a>,<a href="/Niners/STL">STL</a> wrote</p>&gt; On the other hand, a Matrix is a fairly general data structure, and if you promoted your implementation to a separate component, you could use it elsewhere.<p>&nbsp;</p><p>The Nurikabe grid isn't a mathematical matrix.</p></blockquote><p>Why not?&nbsp; It is rectangular and it contains numbers and symbols in the cells.</p><p>posted by giecrilj71pl</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634211616400000000</link>
		<pubDate>Mon, 27 Sep 2010 05:20:40 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634211616400000000</guid>
		<dc:creator>giecrilj71pl</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[<p>Mathematical matrices undergo operations like addition, multiplication, and so forth. Nurikabe isn't linear algebra.</p><p>posted by STL</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634212195420000000</link>
		<pubDate>Mon, 27 Sep 2010 21:25:42 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634212195420000000</guid>
		<dc:creator>STL</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[I stand corrected, yes I understand and have retested that using vector.reserve() only increases performance by at best 3x, and actually become close to 1:1 at larger sizes.<br />Also, a few authors have mentioned its best to keep objects in STL containers for safer memory management, rather than using STL to hold pointers to object in the heap. &nbsp;Any suggestions how one can push objects into an STL container and use them efficiently? &nbsp;Most of the STL documentation deals with data structures rather than class objects with behaviour. &nbsp;I've found the following function calls the destructor 3 times for my class.<br />MyFunction() {<br />vector&lt;GameEntity&gt;.push_back(GameEntity())<br />GameEntity gameEntity&nbsp;= vector.back();<br />gameEntity&nbsp;.start();<br />}<br />&nbsp;<p>posted by Scott C</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634214448710000000</link>
		<pubDate>Thu, 30 Sep 2010 12:01:11 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634214448710000000</guid>
		<dc:creator>Scott C</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[<p>&gt; Also, a few authors have mentioned its best to keep objects in STL containers for safer memory management, rather than using STL to hold pointers to object in the heap.</p><p>Correct.&nbsp; vector&lt;T&gt;, vector&lt;shared_ptr&lt;T&gt;&gt;, and vector&lt;unique_ptr&lt;T&gt;&gt; are all good. vector&lt;T *&gt; where the pointers have been newed and must be deleted is bad. It's virtually guaranteed to leak memory; this was covered in Part 3.</p><p>(vector&lt;T *&gt; where the pointers point to objects that will outlive the vector is fine, and can occasionally be useful.)</p><p>&gt;&nbsp;Any suggestions how one can push objects into an STL container and use them efficiently?</p><p>Give your classes move constructors and move assignment operators. Then using them with the STL will generate maximally efficient code. (STL objects already have move constructors and move assignment operators, so things like vector&lt;string&gt; and vector&lt;vector&lt;int&gt;&gt; are already efficient.)</p><p>I'll describe what happens with this if GameEntity is copyable but not movable (or if you're using VC9, which you shouldn't be - please, please upgrade to VC10):</p><p>vector&lt;GameEntity&gt; v;</p><p>v.push_back(GameEntity());</p><p>This constructs a temporary GameEntity (that's the GameEntity() expression).&nbsp; Then, a vector element GameEntity is copy-constructed from the temporary.&nbsp; Then the temporary is destroyed (temporaries are destroyed &quot;at the semicolon&quot;).</p><p>If the vector undergoes reallocation, you'll see copy constructors being invoked for elements in the new memory block, and destructors being invoked for elements in the old memory block.</p><p>GameEntity gameEntity = v.back();</p><p>v.back() returns a reference to the last element in the vector.&nbsp; Then you copy-construct the local variable gameEntity from this vector element.</p><p>gameEntity.start();</p><p>You call the start() member function on this local variable, not the vector element (or the original temporary,&nbsp;which is long gone).</p><p>If you wanted to call start() on the vector element, you'd say either v.back().start(), or:</p><p>GameEntity&amp; r = v.back();</p><p>r.start();</p><p>This binds a reference r to the last element of the vector, then invokes start() through the reference.</p><p>posted by STL</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634214941970000000</link>
		<pubDate>Fri, 01 Oct 2010 01:43:17 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634214941970000000</guid>
		<dc:creator>STL</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[<blockquote><p><a class="permalink" title="Comment Permalink" href="/Shows/Going&#43;Deep/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634214941970000000">6 hours&nbsp;ago</a>,<a href="/Niners/STL">STL</a> wrote</p>vector&lt;GameEntity&gt; v;<p>v.push_back(GameEntity());</p><p>This constructs a temporary GameEntity (that's the GameEntity() expression).&nbsp; Then, a vector element GameEntity is copy-constructed from the temporary.&nbsp; Then the temporary is destroyed (temporaries are destroyed &quot;at the semicolon&quot;).</p></blockquote><p>If GameEntity‘s copy constructor has trivial path, there is a workaround, although contrived and against the bitzkrieg convention that objects in C&#43;&#43; should not have an error state: push back a temporary constructed to follow that trivial path and do serious things to v.back() afterwards.</p><p>posted by giecrilj71pl</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634215193350000000</link>
		<pubDate>Fri, 01 Oct 2010 08:42:15 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634215193350000000</guid>
		<dc:creator>giecrilj71pl</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[This is a great example of c++ and STL. However, the implementation itself is not able to fully explore puzzles where multiple solutions exist. &nbsp;I want to emphasize that the scope of the solver was never to determine all possible solutions for a puzzle so I am not criticizing here, just observing.<br />Consider this puzzle, which has 212 solutions:&nbsp;<br /> "big5", 5, 5, " &nbsp; &nbsp; \n" " &nbsp; &nbsp;7\n" " &nbsp; &nbsp; \n" "8 &nbsp; &nbsp;\n" " &nbsp; &nbsp; \n"<br />The solver yields "I'm Stumped!" at the second step.<br />Now this puzzle, which has 2 solutions:<br /> "hasTwo", 5, 5, " 7 &nbsp; \n" " &nbsp; &nbsp; \n" " &nbsp; &nbsp;4\n" " &nbsp; &nbsp; \n" " 2 &nbsp;2\n"<br />The solver yields only the first solution, presumably because of the deterministic solving techniques. &nbsp;<br />I'm not a c++ programmer, but I did write a solver in F# that does find all solutions for a given puzzle using a technique called "recursively expanding neighborhoods" (source: http://www.liacs.nl/assets/Bachelorscripties/18-JohanGroenen.pdf , page 7). &nbsp;I would be interested to see if anyone has explored this further in c++.<p>posted by John</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634256940840000000</link>
		<pubDate>Thu, 18 Nov 2010 16:21:24 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634256940840000000</guid>
		<dc:creator>John</dc:creator>
	</item>
	<item>
		<title>Re: C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 4 of n</title>
		<description>
			<![CDATA[@John:<br />Sorry for the poor formatting. &nbsp;Not sure what happened there.<p>posted by John</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634256941610000000</link>
		<pubDate>Thu, 18 Nov 2010 16:22:41 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n#c634256941610000000</guid>
		<dc:creator>John</dc:creator>
	</item>
</channel>
</rss>