2015-04-28 14:29:30 +03:00
|
|
|
|
namespace Glass
|
|
|
|
|
{
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
public class StackingLinkedList<T>
|
|
|
|
|
{
|
|
|
|
|
private readonly LinkedList<T> linkedList = new LinkedList<T>();
|
|
|
|
|
|
|
|
|
|
public void Push(T item)
|
|
|
|
|
{
|
|
|
|
|
linkedList.AddLast(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public LinkedListNode<T> Current => linkedList.Last;
|
2015-06-29 01:19:31 +03:00
|
|
|
|
public LinkedListNode<T> Previous => Current.Previous;
|
|
|
|
|
public T CurrentValue
|
2015-06-28 22:33:40 +03:00
|
|
|
|
{
|
|
|
|
|
get { return Current.Value; }
|
|
|
|
|
set { Current.Value = value; }
|
|
|
|
|
}
|
2015-04-28 14:29:30 +03:00
|
|
|
|
|
|
|
|
|
public void Pop()
|
|
|
|
|
{
|
|
|
|
|
linkedList.RemoveLast();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Count => linkedList.Count;
|
2015-06-29 01:19:31 +03:00
|
|
|
|
public T PreviousValue
|
|
|
|
|
{
|
|
|
|
|
get { return Previous.Value; }
|
|
|
|
|
set { Previous.Value = value; }
|
|
|
|
|
}
|
2015-04-28 14:29:30 +03:00
|
|
|
|
}
|
|
|
|
|
}
|