<?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>Comparing ranges</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/08/19/217226.aspx</link><description>Ryan Farley talks about comparing date ranges . In his post is this phrase “ First range represented by r1start to r1end and second range represented by r2start to r2end ”. Aha, a code smell! 2 things that are related should have that relationship represented</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Comparing ranges</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/08/19/217226.aspx#217235</link><pubDate>Thu, 19 Aug 2004 18:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:217235</guid><dc:creator>Ryan Farley</dc:creator><description>Awesome Jay. I agree that my way was riddled with &amp;quot;code smell&amp;quot;, but it was more the algorithm I was after, not focused on the implementation (that was up to my friend who called me about this).&lt;br&gt;&lt;br&gt;I love how you did this as a range class using generics. Very cool stuff!</description></item><item><title>Intersection of Date Ranges</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/08/19/217226.aspx#217396</link><pubDate>Fri, 20 Aug 2004 00:48:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:217396</guid><dc:creator>{ public virtual blog; }</dc:creator><description>A friend of mine called me yesterday about a scheduling application he is working on. His question was so simple, or so it seemed, but it really drove me nuts. Basically he just wanted to find out if two date ranges intersected at all. Simple enough. It was one of those kinds of answers that you immediately start rattling off the solution, but every thing that started to come out of my mouth was failing my mental unit testing. I'll admit it threw me for a loop for a short bit. </description></item><item><title>re: Comparing ranges</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/08/19/217226.aspx#217398</link><pubDate>Thu, 19 Aug 2004 21:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:217398</guid><dc:creator>Dithermaster</dc:creator><description>Indeed.  A friend approached me years ago about finding if a time range overlaps.  There are just so many cases.  However, (and the &amp;quot;ah ha!&amp;quot; moment), it's *much* easier to find out of they DON'T overlap, and negate that.&lt;br&gt;&lt;br&gt;In other words (in C):&lt;br&gt;&lt;br&gt;   overlap = ! ( (end2 &amp;lt; start1) || (start2 &amp;gt; end1) );&lt;br&gt;&lt;br&gt;Easy.&lt;br&gt;&lt;br&gt;///d@&lt;br&gt;</description></item><item><title>RE: Comparing ranges</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/08/19/217226.aspx#217439</link><pubDate>Thu, 19 Aug 2004 22:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:217439</guid><dc:creator>Ryan Farley</dc:creator><description>Dithermaster, very nice.</description></item><item><title>re: Comparing ranges</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/08/19/217226.aspx#217496</link><pubDate>Fri, 20 Aug 2004 00:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:217496</guid><dc:creator>James Manning</dc:creator><description>            if (left.Start.CompareTo(left.Start) == 0)&lt;br&gt;            {&lt;br&gt;                return true;&lt;br&gt;            }&lt;br&gt;&lt;br&gt;Maybe it's just a typo in reproduction, but maybe we should add some negative tests and not just 5 positive ones? :)</description></item><item><title>re: Comparing ranges</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/08/19/217226.aspx#217543</link><pubDate>Fri, 20 Aug 2004 03:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:217543</guid><dc:creator>mikeb</dc:creator><description>In addition to the typo&lt;br&gt;&lt;br&gt;   if (left.Start.CompareTo(left.Start) == 0)&lt;br&gt;&lt;br&gt;another problem happens if the start and end of a range are out of order.&lt;br&gt;&lt;br&gt;Range&amp;lt;int&amp;gt;( 4, 1) and Range&amp;lt;int&amp;gt;( 2, 1) overlap, but I believe the presented code would not detect this.&lt;br&gt;&lt;br&gt;Either the Range&amp;lt;T&amp;gt; constructor need to enforce left &amp;lt;= right, or the overlap check needs to handle this situation.&lt;br&gt;&lt;br&gt;&lt;br&gt;</description></item><item><title>re: Comparing ranges</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/08/19/217226.aspx#217568</link><pubDate>Fri, 20 Aug 2004 04:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:217568</guid><dc:creator>Matthew W. Jackson</dc:creator><description>I'd vote for the constructor enforcing the order.  This would let you create ranges out of variable-data, which may or may not be in the right order (imagine dragging the mouse to select a range on a timeline), and have the Range automatically be in the correct order.&lt;br&gt;&lt;br&gt;Besides I'm a little biased, because that's how MY Range (recently upgraded to Range&amp;lt;T&amp;gt;) struct works.  But it also does a LOT of other nifty things.</description></item><item><title>re: Comparing ranges</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/08/19/217226.aspx#217670</link><pubDate>Fri, 20 Aug 2004 13:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:217670</guid><dc:creator>Thomas Eyde</dc:creator><description>Isn't this as easy as to verify if one value is inside the range?&lt;br&gt;&lt;br&gt;Overlap(a, b){&lt;br&gt;return IsInside(a) || IsInside(b);&lt;br&gt;}&lt;br&gt;&lt;br&gt;IsInside(a) {&lt;br&gt;return IsBetween(a, this.a, this.b) || IsBetween(a, this.b, this.a);&lt;br&gt;}&lt;br&gt;&lt;br&gt;IsBetween(c, a, b) {&lt;br&gt;return a &amp;lt;= c &amp;amp;&amp;amp; c &amp;lt;= b;&lt;br&gt;} </description></item><item><title>Building a generic Range class</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/08/19/217226.aspx#3010835</link><pubDate>Thu, 31 May 2007 20:41:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3010835</guid><dc:creator>Coding Sanity</dc:creator><description>&lt;p&gt;Quite a long article where I discuss the creation of a generic Range class, and go into the decisions and thinking about many of the design aspects. Touches on lambdas, iterators, generics, and the usual rambling grab-bag of stuff I go on about when I&lt;/p&gt;
</description></item><item><title> jaybaz MS WebLog Comparing ranges | alternative dating</title><link>http://blogs.msdn.com/jaybaz_ms/archive/2004/08/19/217226.aspx#9767500</link><pubDate>Wed, 17 Jun 2009 10:09:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9767500</guid><dc:creator> jaybaz MS WebLog Comparing ranges | alternative dating</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://topalternativedating.info/story.php?id=10942"&gt;http://topalternativedating.info/story.php?id=10942&lt;/a&gt;&lt;/p&gt;
</description></item></channel></rss>