Created
May 13, 2011 16:04
-
-
Save NightBrownie/970805 to your computer and use it in GitHub Desktop.
Stack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace Lab_3_inisp | |
{ | |
class ListItem<T> | |
{ | |
public ListItem<T> Next | |
{ get; set; } | |
public T Value | |
{ get; set; } | |
public ListItem(T _value, ListItem<T> _next) | |
{ | |
Next = _next; | |
Value = _value; | |
} | |
} | |
class List<T> | |
{ | |
private ListItem<T> Head; | |
public List() | |
{ | |
Head = null; | |
} | |
public void Push(T _value) | |
{ | |
ListItem<T> BufferItem = new ListItem<T>(_value, Head); | |
Head = BufferItem; | |
} | |
public T Pop() | |
{ | |
if (Head != null) | |
{ | |
T BufferValue = Head.Value; | |
Head = Head.Next; | |
return BufferValue; | |
} | |
else | |
return default(T); | |
} | |
public bool Contains(T _value) | |
{ | |
bool Result = false; | |
ListItem<T> ListPointer = Head; | |
while (ListPointer != null) | |
if (ListPointer.Value.Equals(_value)) | |
{ | |
Result = true; | |
break; | |
} | |
return Result; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment