daily update on 20230104 by nitload youmu

This commit is contained in:
Nitload
2023-01-05 01:21:54 +08:00
parent 5fd8462e16
commit e464ac56ba
23 changed files with 128 additions and 36 deletions
+51 -1
View File
@@ -4,7 +4,57 @@ using System.Text;
namespace StgSharp.Logic
{
public class LinkedList<T> where T:
public class LinkedList<T> where T: INode
{
private LinkedListNode<T> _head;
private LinkedListNode<T> _tail;
private LinkedListNode<T> _cache;
public T Head
{
get { return _head._this; }
set { _head = new LinkedListNode<T>(value); }
}
public T Tail
{
get { return _tail._this; }
set { _tail = new LinkedListNode<T>(value); }
}
public void Add(T t)
{
if (_head != default(LinkedListNode<T>))
{
Head = t;
}
else
{
_cache = new LinkedListNode<T>(t);
_tail._next = _cache;
_cache._previous = _tail;
_tail = _cache;
}
}
public void RemoveTail()
{
if (_tail==default(LinkedListNode<T>))
{
}
else
{
_cache = _tail;
_tail = _cache._previous;
_cache._previous = default(LinkedListNode<T>);
}
}
}
}