Updated Doubly Linked List to allow for null values to be added

This commit is contained in:
Luke Else 2022-04-19 21:30:37 +01:00
parent e8c99f8d5d
commit a4dfb0f58a

View File

@ -12,7 +12,7 @@
return new DoublyLinkedList<T>(); return new DoublyLinkedList<T>();
} }
public static DoublyLinkedList<T> Create(T value) public static DoublyLinkedList<T> Create(T? value)
{ {
//Create a new Class with a single item //Create a new Class with a single item
return new DoublyLinkedList<T>() return new DoublyLinkedList<T>()
@ -67,7 +67,7 @@
node!.Value = value; node!.Value = value;
} }
} }
public void Append(T value) public void Append(T? value)
{ {
Count++; Count++;
@ -84,7 +84,7 @@
Tail = Tail.Next; Tail = Tail.Next;
} }
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");