Updated Linked List to allow for null value to be added
This commit is contained in:
parent
5360fdd47b
commit
e8c99f8d5d
@ -11,7 +11,7 @@ namespace C_.Datastructures.LinkedList
|
|||||||
return new LinkedList<T>();
|
return new LinkedList<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LinkedList<T> Create(T value)
|
public static LinkedList<T> Create(T? value)
|
||||||
{
|
{
|
||||||
//Create a new Class with a single item
|
//Create a new Class with a single item
|
||||||
return new LinkedList<T>()
|
return new LinkedList<T>()
|
||||||
@ -62,7 +62,7 @@ namespace C_.Datastructures.LinkedList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Append(T value)
|
public void Append(T? value)
|
||||||
{
|
{
|
||||||
//Create new node
|
//Create new node
|
||||||
Count++;
|
Count++;
|
||||||
@ -86,7 +86,7 @@ namespace C_.Datastructures.LinkedList
|
|||||||
end!.Next = newItem;
|
end!.Next = newItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Insert(int index, T value)
|
public void Insert(int index, T? value)
|
||||||
{
|
{
|
||||||
Count++;
|
Count++;
|
||||||
if (index > Count || index < 0) throw new System.Exception("Error! Index outside of Bounds");
|
if (index > Count || index < 0) throw new System.Exception("Error! Index outside of Bounds");
|
||||||
|
Loading…
Reference in New Issue
Block a user