//---------------------------------------------------------------------------- // Copyright (C) 2013-2015 Fabrice HARROUET (ENIB) // // Permission to use, copy, modify, distribute and sell this software // and its documentation for any purpose is hereby granted without fee, // provided that the above copyright notice appear in all copies and // that both that copyright notice and this permission notice appear // in supporting documentation. // The author makes no representations about the suitability of this // software for any purpose. // It is provided "as is" without express or implied warranty. //---------------------------------------------------------------------------- using System; namespace MyStuff.Collections { public class Stack { protected class Entry { public Entry next; public object data; public Entry(Entry next, object data) { this.next=next; this.data=data; } } protected Entry _top; public void Push(object data) { _top=new Entry(_top,data); } public object Pop() { object result=_top.data; _top=_top.next; return result; } } } //----------------------------------------------------------------------------