using System; using System.Collections; using System.Collections.Generic; using System.Text; namespace StgSharp { public abstract class INode where T : INode { protected ContainerNode _id; internal ContainerNode ID { get; } internal void setID(ContainerNode id) { if (_id!=null) { throw new ArgumentException("Cannot set ID twice"); } else { _id = id; } } } public class ContainerNode where T : INode { internal readonly T _value; internal ContainerNode _previous; internal ContainerNode _next; internal ContainerNode _side; public ContainerNode(T t) { _value = t; t.setID(this); } public virtual ContainerNode Previous { get { return _previous; } set { _previous = value; } } public ContainerNode Next { get { return _next; } set { _next = value; } } public ContainerNode Side { get { return _side; } set { _side = value; } } public T Value { get { return _value; } } public void Remove() { _previous.Next = _next; _next.Previous = _previous; _next = default(ContainerNode); _previous = default(ContainerNode); } } }