using StgSharp.Logic; using System; using System.Collections; using System.Collections.Generic; using System.Text; namespace StgSharp { public class LinkedList:IEnumerable,INode> where T: INode { internal readonly ContainerNode _heading; internal ContainerNode _first; internal ContainerNode _tail; private ContainerNode> _id; private ContainerNode _cache; public LinkedList() { _heading = new ContainerNode(default(T)); } public T First { get { return _first._value; } set { _first = new ContainerNode(value); _heading._next = _first; } } public T Tail { get { return _tail._value; } set { _tail = new ContainerNode(value); } } public void Add(T t) { if (_first != default(ContainerNode)) { First = 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); } } IEnumerator IEnumerable.GetEnumerator() { return new LinkedListEnumrator(this); } } }