<?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>Channel 9 Forums - Tech Off - SimpleCollection/Buffer  for C#? (Think text editor buffers except with objects)</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Forums/rss"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 Forums - Tech Off - SimpleCollection/Buffer  for C#? (Think text editor buffers except with objects)</title>
		<link>http://channel9.msdn.com/Forums</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Forums</link>
	<language>en</language>
	<pubDate>Wed, 22 May 2013 22:01:09 GMT</pubDate>
	<lastBuildDate>Wed, 22 May 2013 22:01:09 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>2</c9:totalResults>
	<c9:pageCount>-2</c9:pageCount>
	<c9:pageSize>-1</c9:pageSize>
	<item>
		<title>Tech Off - SimpleCollection/Buffer  for C#? (Think text editor buffers except with objects)</title>
		<description><![CDATA[<p>I use List&lt;&gt; quite a bit and find that most of the time when I&nbsp;value simplicity of the code, it doesn't seem to do enough.</p><p>I want this to compile and not throw exceptions at any line:</p><p><pre class="brush: csharp">var st=new SimpleThing&lt;string&gt;(default=&quot;&quot;); // Thing that works a lot like text editor buffer except with objects instead of characters

st[4]=&quot;fifth&quot;; // conceptually similar to Console.Left=4; Console.Write(&quot;f&quot;); Console.Left=(last position); except that &quot;f&quot; was the object in this case string &quot;fifth&quot;;

st.Index=3; // conceptually similar to Console.Left=3;

st.Write(&quot;Fourth&quot;); //and increment internal index/position, just like Console.Write moves to next position
//(st.Index=4)
st.Write(&quot;overwriting fifth&quot;); 
//(st.Index=5)
st.Insert(4,&quot;new fifth&quot;); //now [5]=&quot;overwriting fifth&quot;, internal position not touched 
//(st.Index=5)
//st.Insert(otherst); // would enumerate over otherst insert contents before &quot;overwriting fifth&quot; and after &quot;new fifth&quot;
//(st.Index=5)
//var thisisTrue = st.Current == otherst.Take(1); //otherst[0] could throw if default was not set

var q=st[1]; // q==&quot;&quot;, if default param not set, throw exception, if default=null then its null.

foreach(var t in st) // stuff can be modified, removed etc without exceptions during the loop
{
    //st.Delete(t); // same as pressing Delete key on keyboard, everything coming after would move if this was not commented, the next one taking place of current
    Console.WriteLine(t);
    st.Clear(t); // first &quot;Fourth&quot; would become &quot;&quot; (since default=&quot;&quot;)
    //all others that weren't default or not set would be enumerated and be cleared to default
}

foreach(var t in st)
{
//... nothing to enumerate over
}
Console.Write(st[666]);// write the default value

output (with added quotes since last line was the default &quot;&quot;):

&quot;Fourth&quot;
&quot;new fifth&quot;
&quot;overwriting fifth&quot;
&quot;&quot;</pre></p><p>(There should be a way to specify the type of the used index, so it can be eg. ulong or int so you could enter negative indexes as well, in which case enumeration starts from the lowest index, which could be negative) </p><p>&nbsp;</p><p>EDIT:</p><p>Had a bit of a blunder on the foreach there. It should've been st.Delete(t); and st.Clear(t); - correcting that. I'm still not sure it can be made to work at all. </p><p>Alternative that could work is</p><p>while(st.Next) { st.Clear()&nbsp;} ... might do but that's not so simple anymore, losing the foreach word and now it's starting from whatever location the pointer/index was at.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/SimpleCollectionBuffer-for-C-Think-text-editor-buffers-except-with-objects/672d3510ac814dbbaabc9e420070eaca#672d3510ac814dbbaabc9e420070eaca</link>
		<pubDate>Sat, 04 Dec 2010 06:51:07 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/SimpleCollectionBuffer-for-C-Think-text-editor-buffers-except-with-objects/672d3510ac814dbbaabc9e420070eaca#672d3510ac814dbbaabc9e420070eaca</guid>
		<dc:creator>androidi</dc:creator>
		<slash:comments>2</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/androidi/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - SimpleCollection/Buffer  for C#? (Think text editor buffers except with objects)</title>
		<description><![CDATA[<p>use ansi mode on the cosole, or another encoding</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/SimpleCollectionBuffer-for-C-Think-text-editor-buffers-except-with-objects/4cb54d15cd7343ccb9559e62003136df#4cb54d15cd7343ccb9559e62003136df</link>
		<pubDate>Wed, 05 Jan 2011 02:59:11 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/SimpleCollectionBuffer-for-C-Think-text-editor-buffers-except-with-objects/4cb54d15cd7343ccb9559e62003136df#4cb54d15cd7343ccb9559e62003136df</guid>
		<dc:creator>Alex Wykel</dc:creator>
		<slash:comments>2</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/teslaBytes/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>