Updated Protection Level of all current datastructures - Needs Review

This commit is contained in:
Luke Else 2022-03-28 23:16:33 +01:00
parent fdd1461e3a
commit de0f4195ed
4 changed files with 21 additions and 32 deletions

View File

@ -6,7 +6,7 @@ using C_.Datastructures.Nodes;
namespace C_.Datastructures
{
internal class DoublyLinkedList<T>
public class DoublyLinkedList<T>
{
internal DoublyLinkedListNode<T>? Head { get; set; } = default;
internal DoublyLinkedListNode<T>? Tail { get; set; } = default;

View File

@ -2,7 +2,7 @@ using C_.Datastructures.Nodes;
namespace C_.Datastructures
{
internal class LinkedList<T>
public class LinkedList<T>
{
internal LinkedListNode<T>? Head { get; set; } = default;
private int Count { get; set; } = 0;

View File

@ -2,17 +2,17 @@ using C_.Datastructures.Nodes;
namespace C_.Datastructures
{
internal class Stack<T>
public class Stack<T>
{
internal StackNode<T>? Head { get; set; }
private int Count { get; set; } = 0;
public Stack<T> Create(){
public static Stack<T> Create(){
//Create a new stack without a head
return new Stack<T>();
}
public Stack<T> Create(T value){
public static Stack<T> Create(T value){
//Create a new Stack with a head
return new Stack<T>{
Head = StackNode<T>.Create(value, default),

View File

@ -21,37 +21,26 @@ Console.WriteLine("Hello, World!");
DoublyLinkedList<int> list = new DoublyLinkedList<int>();
// DoublyLinkedList<int> list = new DoublyLinkedList<int>();
list.Append(1);
list.Append(2);
list.Append(3);
list.Append(4);
list.Append(5);
list.Append(6);
list.Insert(6, 1);
// list.Append(1);
// list.Append(2);
// list.Append(3);
// list.Append(4);
// list.Append(5);
// list.Append(6);
// list.Insert(6, 1);
Console.Write($"{list[0]} ");
Console.Write($"{list[1]} ");
Console.Write($"{list[2]} ");
Console.Write($"{list[3]} ");
Console.Write($"{list[4]} ");
Console.Write($"{list[5]} ");
Console.Write($"{list[6]} \n");
// Console.Write($"{list[0]} ");
// Console.Write($"{list[1]} ");
// Console.Write($"{list[2]} ");
// Console.Write($"{list[3]} ");
// Console.Write($"{list[4]} ");
// Console.Write($"{list[5]} ");
// Console.Write($"{list[6]} \n");
//DoublyLinkedList<int> list2 = new DoublyLinkedList<int>();
//list2.Append(1);
//list2.Append(2);
//list2.Append(3);
//list2.Append(4);
//list2.Append(5);
//list2.Append(6);
//list2.Append(7);
//list2.Append(8);
//var x = list[-6];
Stack<int> test = Stack<int>.Create();