public class Text:System.Collections.IList where T:Text.TextNode{ public class TextNode:ICloneable { public string text; internal TextNode prev; internal TextNode next; public void PushPrevious(TextNode insertee){...} public void PushNext(TextNode insertee){...} public TextNode PopPrevious(){...} public TextNode PopNext(){...} public TextNode Pop(){...} } private T rootTextNode; private T currentTextNode; // Rest of Text code}
For review of what my previous one looked like:
public class TextLine{ public String data; public T extradata; public TextLine nextNode; public TextLine prevNode; public TextLine(){...} public TextLine(String text){...} public TextLine(T data){...} public TextLine(String text,T data){...} public TextLine(TextLine previous,TextLine next){...} public TextLine(String text,TextLine previous,TextLine next){...} public TextLine(T data,TextLine previous,TextLine next){...} public TextLine(String text,T data,TextLine previous,TextLine next){...} protected void QuickSetup(String text,T data,TextLine previous,TextLine next){...}}
No freakin' idea what I was thinking. Apparently to insert or remove a node, you had to make a new one at the specified spot. Like singletonesque nodes or something... [headshake] Washu is going to kill me.
Anyway, now I should just have to implement System.Collections.IList in it and it *should* be good to go. The only problem I've met so far is the some of the methods receive arguements of the type object. I scanned through the available exceptions for something akin to TypeNotSupportedException, but didn't find any. I went ahead and made up my own, but if there is a standard procedure for handling something like this, I'd be grateful if someone could leave it in a comment or message me. Thanks.
Edit: Or, in freaking retrospect, I could just implement IList and IList instead. :/
Hm, on second thoughts, I've been writing software in C# to work against PHP software, so reimplemented PHP's arrays in C# using the above method. PHP's arrays work as associative (ordered) arrays, dictionaries, stacks and who knows what else, resulting in some rather creative (ie, ugly) code to hack it on top of .NET's existing collections. [grin]