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