Ran Code Cleanup
This commit is contained in:
parent
fc832edb9d
commit
88d84ab448
@ -1,8 +1,4 @@
|
|||||||
using System;
|
using C_.Datastructures.Nodes;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using C_.Datastructures.Nodes;
|
|
||||||
|
|
||||||
namespace C_.Datastructures
|
namespace C_.Datastructures
|
||||||
{
|
{
|
||||||
|
@ -7,20 +7,24 @@ namespace C_.Datastructures
|
|||||||
internal LinkedListNode<T>? Head { get; set; } = default;
|
internal LinkedListNode<T>? Head { get; set; } = default;
|
||||||
private int Count { get; set; } = 0;
|
private int Count { get; set; } = 0;
|
||||||
|
|
||||||
public static LinkedList<T> Create(){
|
public static LinkedList<T> Create()
|
||||||
|
{
|
||||||
//Create a new empty list
|
//Create a new empty list
|
||||||
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>()
|
||||||
|
{
|
||||||
Head = LinkedListNode<T>.Create(value, null),
|
Head = LinkedListNode<T>.Create(value, null),
|
||||||
Count = 1
|
Count = 1
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LinkedList<T> Create(LinkedList<T> list1, LinkedList<T> list2){
|
public static LinkedList<T> Create(LinkedList<T> list1, LinkedList<T> list2)
|
||||||
|
{
|
||||||
//Append a previous list to a new List
|
//Append a previous list to a new List
|
||||||
LinkedList<T> list;
|
LinkedList<T> list;
|
||||||
|
|
||||||
@ -60,7 +64,8 @@ namespace C_.Datastructures
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Append(T value){
|
public void Append(T value)
|
||||||
|
{
|
||||||
//Create new node
|
//Create new node
|
||||||
Count++;
|
Count++;
|
||||||
LinkedListNode<T> newItem = LinkedListNode<T>.Create(value, default);
|
LinkedListNode<T> newItem = LinkedListNode<T>.Create(value, default);
|
||||||
@ -119,7 +124,8 @@ namespace C_.Datastructures
|
|||||||
node!.Next = node.Next!.Next;
|
node!.Next = node.Next!.Next;
|
||||||
}
|
}
|
||||||
|
|
||||||
private LinkedListNode<T>? Traverse(){
|
private LinkedListNode<T>? Traverse()
|
||||||
|
{
|
||||||
//Start at Head of list
|
//Start at Head of list
|
||||||
LinkedListNode<T>? node = Head;
|
LinkedListNode<T>? node = Head;
|
||||||
if (node != null)
|
if (node != null)
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace C_.Datastructures.Nodes
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace C_.Datastructures.Nodes
|
|
||||||
{
|
{
|
||||||
internal class DoublyLinkedListNode<T> : Node<T, DoublyLinkedListNode<T>>
|
internal class DoublyLinkedListNode<T> : Node<T, DoublyLinkedListNode<T>>
|
||||||
{//Inherits from Node
|
{//Inherits from Node
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace C_.Datastructures.Nodes
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace C_.Datastructures.Nodes
|
|
||||||
{
|
{
|
||||||
internal class LinkedListNode<T> : Node<T, LinkedListNode<T>>
|
internal class LinkedListNode<T> : Node<T, LinkedListNode<T>>
|
||||||
{//Inherits from Node
|
{//Inherits from Node
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace C_.Datastructures.Nodes
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace C_.Datastructures.Nodes
|
|
||||||
{
|
{
|
||||||
internal class Node<T, NodeType>
|
internal class Node<T, NodeType>
|
||||||
{//Generic Node type that every other type inherits from
|
{//Generic Node type that every other type inherits from
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace C_.Datastructures.Nodes
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace C_.Datastructures.Nodes
|
|
||||||
{
|
{
|
||||||
internal class QueueNode<T> : Node<T, QueueNode<T>>
|
internal class QueueNode<T> : Node<T, QueueNode<T>>
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,3 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace C_.Datastructures.Nodes
|
namespace C_.Datastructures.Nodes
|
||||||
{
|
{
|
||||||
internal class StackNode<T> : Node<T, StackNode<T>>
|
internal class StackNode<T> : Node<T, StackNode<T>>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Linq;
|
using C_.Datastructures.Nodes;
|
||||||
using C_.Datastructures.Nodes;
|
|
||||||
|
|
||||||
namespace C_.Datastructures
|
namespace C_.Datastructures
|
||||||
{
|
{
|
||||||
|
@ -7,27 +7,32 @@ namespace C_.Datastructures
|
|||||||
internal StackNode<T>? Head { get; set; }
|
internal StackNode<T>? Head { get; set; }
|
||||||
private int Count { get; set; } = 0;
|
private int Count { get; set; } = 0;
|
||||||
|
|
||||||
public static Stack<T> Create(){
|
public static Stack<T> Create()
|
||||||
|
{
|
||||||
//Create a new stack without a head
|
//Create a new stack without a head
|
||||||
return new Stack<T>();
|
return new Stack<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Stack<T> Create(T value){
|
public static Stack<T> Create(T value)
|
||||||
|
{
|
||||||
//Create a new Stack with a head
|
//Create a new Stack with a head
|
||||||
return new Stack<T>{
|
return new Stack<T>
|
||||||
|
{
|
||||||
Head = StackNode<T>.Create(value, default),
|
Head = StackNode<T>.Create(value, default),
|
||||||
Count = 1
|
Count = 1
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Push(T value){
|
public void Push(T value)
|
||||||
|
{
|
||||||
//Add an Item to the top of the stack
|
//Add an Item to the top of the stack
|
||||||
Count++;
|
Count++;
|
||||||
Head = StackNode<T>.Create(value, Head);
|
Head = StackNode<T>.Create(value, Head);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T? Pop(){
|
public T? Pop()
|
||||||
|
{
|
||||||
//Take the item off of the top of the stack
|
//Take the item off of the top of the stack
|
||||||
T? value = default;
|
T? value = default;
|
||||||
if (Count > 0)
|
if (Count > 0)
|
||||||
@ -43,7 +48,8 @@ namespace C_.Datastructures
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T? Peek(){
|
public T? Peek()
|
||||||
|
{
|
||||||
//View item on top of the stack
|
//View item on top of the stack
|
||||||
if (Count > 0)
|
if (Count > 0)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using C_.Datastructures;
|
|
||||||
using C_.Datastructures.Nodes;
|
|
||||||
|
|
||||||
// See https://aka.ms/new-console-template for more information
|
// See https://aka.ms/new-console-template for more information
|
||||||
Console.WriteLine("Hello, World!");
|
Console.WriteLine("Hello, World!");
|
||||||
|
Loading…
Reference in New Issue
Block a user