Updated Linked List to allow for null value to be added

This commit is contained in:
Luke Else 2022-04-19 21:29:25 +01:00
parent 5360fdd47b
commit e8c99f8d5d

View File

@ -11,7 +11,7 @@ namespace C_.Datastructures.LinkedList
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
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
Count++;
@ -86,7 +86,7 @@ namespace C_.Datastructures.LinkedList
end!.Next = newItem;
}
public void Insert(int index, T value)
public void Insert(int index, T? value)
{
Count++;
if (index > Count || index < 0) throw new System.Exception("Error! Index outside of Bounds");