using System; using System.Collections.Generic; using System.Text; namespace StgSharp.Logic { public class LinkedList where T: INode { internal ContainerNode _head; internal ContainerNode _tail; private ContainerNode _cache; public T Head { get { return _head._this; } set { _head = new ContainerNode(value); } } public T Tail { get { return _tail._this; } set { _tail = new ContainerNode(value); } } public void Add(T t) { if (_head != default(ContainerNode)) { Head = t; } else { _cache = new ContainerNode(t); _tail._next = _cache; _cache._previous = _tail; _tail = _cache; } } public void RemoveTail() { if (_tail==default(ContainerNode)) { } else { _cache = _tail; _tail = _cache._previous; _cache._previous = default(ContainerNode); } } } }