diff --git a/DataStructures.UI.sln b/DataStructures.UI.sln
index 4a36b1a..83c6864 100644
--- a/DataStructures.UI.sln
+++ b/DataStructures.UI.sln
@@ -19,6 +19,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BarcodeChecker", "UI\Barcod
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StateMachineEngine", "StateMachineEngine\StateMachineEngine.csproj", "{BDC9CA70-E444-4743-9FBF-F6C21B9A1438}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CC451AE2-F46D-4415-B156-2C455A01FBA8}"
+ ProjectSection(SolutionItems) = preProject
+ Readme.md = Readme.md
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
diff --git a/DataStructures/AbstractDataTyps.cd b/DataStructures/AbstractDataTyps.cd
deleted file mode 100644
index 798171f..0000000
--- a/DataStructures/AbstractDataTyps.cd
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
-
-
- AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
- Interfaces\IInvariant.cs
- Interfaces\IInvarianti.cs
-
-
-
-
-
- AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
- Interfaces\ICovariant.cs
-
-
-
-
-
- AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAA=
- Interfaces\IData.cs
-
-
-
-
-
- AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACACAAAAAAAA=
- Interfaces\INode.cs
-
-
-
-
-
- AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAA=
- Interfaces\ISingleNode.cs
-
-
-
-
-
- AAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAACACAAAAAAAA=
- Interfaces\ITreeNode.cs
-
-
-
-
-
- AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
- Interfaces\IContravariant.cs
-
-
-
-
\ No newline at end of file
diff --git a/DataStructures/DoubleLinkedList.cs b/DataStructures/DoubleLinkedList.cs
deleted file mode 100644
index 67fe520..0000000
--- a/DataStructures/DoubleLinkedList.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Get.the.Solution.DataStructure
-{
- ///
- /// Represents a double linked list
- ///
- /// DataType of value
- public class DoubleLinkedList : LinkedList
- {
- ///
- /// Constructor of
- ///
- public DoubleLinkedList()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/DataStructures/Graph/Edge.cs b/DataStructures/Graph/Edge.cs
deleted file mode 100644
index 615a77c..0000000
--- a/DataStructures/Graph/Edge.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-using System;
-using System.Diagnostics;
-
-namespace Get.the.Solution.DataStructure
-{
- [DebuggerDisplay("Edge = {Weight},U={U}, V = {V}")]
- public class Edge : IEdge
- where W : IComparable
- {
- #region Members
- protected IVertex u;
- protected IVertex v;
- protected W weight;
- #endregion
-
- public Edge()
- {
- }
- ///
- /// Initializes a new instance of the Edge class.
- ///
- /// Vertex of the Edge
- /// Vertex of the Edge
- public Edge(IVertex pu, IVertex pv)
- : this()
- {
- this.u = pu;
- this.v = pv;
- }
- ///
- /// Initializes a new instance of the Edge class.
- ///
- /// Vertex of the Edge
- /// Vertex of the Edge
- /// Sets the Weighted of the Edge
- public Edge(IVertex pu, IVertex pv, W pweight)
- : this(pu, pv)
- {
- weight = pweight;
- }
-
- ///
- /// Get or sets the vertex U of the Edge
- ///
- public virtual IVertex U { get { return u; } set { u = value; } }
- ///
- /// Get or sets the vertex V of the edge
- ///
- public virtual IVertex V { get { return v; } set { v = value; } }
- ///
- /// Gets or sets the weight of the edge
- ///
- public virtual W Weight { get { return weight; } set { weight = value; } }
-
- public virtual D Value { get; set; }
- ///
- /// Determines whether two object instances are equal.
- ///
- /// The object to compare.
- /// True if the objects are considered equal; otherwise, false.
- public sealed override bool Equals(object obj)
- {
- if (!obj.GetType().Equals(typeof(IEdge))) return false;
-
- //true if objA is the same instance as objB or if both are null; otherwise, false.
- if (Object.ReferenceEquals(this, obj)) return true;
-
- //Check whether any of the compared objects is null.
- if (Object.ReferenceEquals(this, null) || Object.ReferenceEquals(obj, null)) return false;
-
- IEdge edge = obj as IEdge;
-
- return Equals(edge, false);
- }
-
- ///
- /// Serves as a hash function for the type edge.
- /// The implementation of the GetHashCode method does not guarantee unique return values for different objects.
- /// The HasCode will be calculated with the GetHasCode functions from the vertex u and v. Transported edges have the same values.
- /// http://msdn.microsoft.com/en-us/library/system.object.gethashcode.aspx
- ///
- /// A hash code for the current Object.
- public sealed override int GetHashCode()
- {
- return Math.Abs(this.U.GetHashCode()) + Math.Abs(this.V.GetHashCode());
- }
-
- }
-}
diff --git a/DataStructures/Graph/IEdge.cs b/DataStructures/Graph/IEdge.cs
deleted file mode 100644
index 876fcd3..0000000
--- a/DataStructures/Graph/IEdge.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System;
-
-namespace Get.the.Solution.DataStructure
-{
- ///
- /// Represents a Ede which holdes the two connected vertices u and v
- ///
- /// A compareable type for the edge weight
- /// The Data Type of the vertices
- public interface IEdge : IData
- where W : IComparable
- {
- ///
- /// Weight of vertex
- ///
- W Weight { get; set; }
- ///
- /// Get or sets the Vertex U
- ///
- IVertex U { get; set; }
- ///
- /// Get or sets the Vertex V
- ///
- IVertex V { get; set; }
- }
-}
diff --git a/DataStructures/Graph/IVertex.cs b/DataStructures/Graph/IVertex.cs
deleted file mode 100644
index 3d7ba0c..0000000
--- a/DataStructures/Graph/IVertex.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-
-namespace Get.the.Solution.DataStructure
-{
- ///
- /// Vertex which is connected by edges
- ///
- /// A comparable type which is used for the weight of the vertex
- /// The type of the data which the vertex contained
- public interface IVertex< W, D> : IData
- where W : IComparable
- {
- ///
- /// Weight of vertex
- ///
- W Weight { get; set; }
-
- ///
- /// Outbound edges from vertex
- ///
- IEnumerable> Edges { get; set; }
-
- ///
- /// Amount of edges
- ///
- int Size { get; }
-
- ///
- /// Add an edge to the vertex
- ///
- /// The vertex which should be connected.
- /// Weight of the edge.
- /// Determines whether the connection is directed or undirected.
- /// If is set to true, two edges will be created. The first edge will connect the current instance with the overgiven vertex .
- /// The second edge will be created from vertex to the current instance.
- /// The created edge
- IEdge AddEdge(IVertex U, W Weight, Boolean Undirected=true);
-
- ///
- /// Determines whether a directed or undirected edge should be deleted.
- ///
- /// The vertex to be removed.
- /// Determines whether an undirected or directed connection should be delted.
- /// If is set to true, two edges will be deleted. The first edge which is outgoing from vertex will be deleted.
- /// The second edge from the current instance which connects the vertex will be deleted .
- void RemoveEdge(IVertex U, Boolean Undirected=true);
- }
-}
diff --git a/DataStructures/Graph/Vertex.cs b/DataStructures/Graph/Vertex.cs
deleted file mode 100644
index e750636..0000000
--- a/DataStructures/Graph/Vertex.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Diagnostics;
-
-namespace Get.the.Solution.DataStructure
-{
- [DebuggerDisplay("Vertex = {Weight},Size={Size}, GUID = {_Guid}")]
- public class Vertex : IVertex
- where W : IComparable
- {
-
- #region Members
- protected IEnumerable> _Edges;
- protected Guid _Guid;
- protected W weight;
- #endregion
-
- public Vertex()
- {
- this._Guid = Guid.NewGuid();
- this._Edges = new List>();
- }
-
- ///
- /// Initializes a new instance of the Vertex class that contains the specified weighted.
- ///
- ///
- public Vertex(W weight)
- : this()
- {
- this.weight = weight;
- }
- ///
- /// Gets or sets the Weighted of the vertex
- ///
- public virtual W Weight { get { return this.weight; } set { this.weight = value; } }
-
- ///
- /// Gets or sets the list of edges which connects the vertex neighbours
- ///
- public virtual IEnumerable> Edges { get { return _Edges; } set { _Edges = value; } }
-
- ///
- /// Amount of neighbours
- ///
- public int Size
- {
- get
- {
- return Edges.Count(); //Knotengrad
- }
- }
-
- public virtual D Value { get; set; }
-
- public virtual IEdge AddEdge(IVertex U, W Weight, bool Undirected)
- {
- IEdge e1 = new Edge(this,U,weight);
- _Edges.ToList>().Add(e1);
- if (Undirected == true)
- {
- U.AddEdge(this, Weight, false);
- }
-
- return e1;
- }
-
- public virtual void RemoveEdge(IVertex U, bool Undirected)
- {
- // IEdge> edge = this.Edges.Where(a => a.U.Equals(this) && a.V.Equals(U)).FirstOrDefault>();
-
- if (Undirected.Equals(false))
- {
- //IEdge> edged = edge.Left.Edges.Where(a => a.U.Equals(edge.V) && a.V.Equals(this) && a.Weight.Equals(edge.Weight)).FirstOrDefault>();
-
- // edge.V.Edges.ToList>>().Remove(edged);
- }
- // this.Edges.ToList>>().Remove(edge);
- }
-
- ///
- /// Determines with the guid whether the specified Object is equal to the current Object.
- /// http://msdn.microsoft.com/en-us/library/bsc2ak47.aspx
- ///
- /// The object to compare with the current object.
- /// true if the specified Object is equal to the current Object; otherwise, false.
- public override bool Equals(object obj)
- {
- if (!obj.GetType().Equals(typeof(IVertex))) return false;
-
- return this._Guid.Equals((obj as Vertex)._Guid);
- }
- ///
- /// Serves as a hash function for a particular type.
- ///
- /// A hash code for the current Object.
- public override int GetHashCode()
- {
- return _Guid.GetHashCode();
- }
- }
-}
diff --git a/DataStructures/ILNode.cs b/DataStructures/ILNode.cs
deleted file mode 100644
index 0b0bc9c..0000000
--- a/DataStructures/ILNode.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-//using System;
-//using System.Collections.Generic;
-//using System.Linq;
-//using System.Text;
-//using Get.DataStructure;
-
-//namespace Get.the.Solution.DataStructure
-//{
-// public interface ITreeNode : INode
-// where T : INode
-// {
-// T Parent { get; set; }
-// }
-//}
diff --git a/DataStructures/ILinkedList.cs b/DataStructures/ILinkedList.cs
deleted file mode 100644
index c7978ce..0000000
--- a/DataStructures/ILinkedList.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Get.the.Solution.DataStructure
-{
- public interface ILinkedList
- where T : Node
- {
- T Root { get; set; }
- }
-}
diff --git a/DataStructures/Interfaces/IContravariant.cs b/DataStructures/Interfaces/IContravariant.cs
deleted file mode 100644
index e9b4f2a..0000000
--- a/DataStructures/Interfaces/IContravariant.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Get.the.Solution.DataStructure
-{
- ///
- /// Kontravarianz: Obertyp-Beziehung: Parametertyp variiert GEGEN den Klassentypen
- ///
- /// https://msdn.microsoft.com/en-us/library/dd997386.aspx
- /// The type which should be contravariant
- public interface IContravariant { }
-}
diff --git a/DataStructures/Interfaces/ICovariant.cs b/DataStructures/Interfaces/ICovariant.cs
deleted file mode 100644
index 200ec5d..0000000
--- a/DataStructures/Interfaces/ICovariant.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Get.the.Solution.DataStructure
-{
- ///
- /// Kovarianz: UnterTyp-Beziehung: Paramtertyp variiert MIT dem Klassentyp (ko -mit)
- ///
- /// https://msdn.microsoft.com/en-us/library/dd997386.aspx
- /// The type which should be Covariant
- public interface ICovariant { }
-}
diff --git a/DataStructures/Interfaces/IData.cs b/DataStructures/Interfaces/IData.cs
deleted file mode 100644
index b95f67a..0000000
--- a/DataStructures/Interfaces/IData.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Get.the.Solution.DataStructure
-{
- ///
- ///
- ///
- /// The Type of the Data which should be used in the DataStructure
- public interface IData : ICovariant
- {
- D Value { get; }
- }
-}
diff --git a/DataStructures/Interfaces/IInvariant.cs b/DataStructures/Interfaces/IInvariant.cs
deleted file mode 100644
index 8dc2729..0000000
--- a/DataStructures/Interfaces/IInvariant.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Get.the.Solution.DataStructure
-{
- ///
- /// Invarainz: Typen bleiben gleich
- ///
- ///
- /// set-property-on-a-covariant-interface
- /// Creating Variant Generic Interfaces
- /// The type which should be invariant
- public interface IInvariant : ICovariant, IContravariant { }
-}
diff --git a/DataStructures/Interfaces/INode.cs b/DataStructures/Interfaces/INode.cs
deleted file mode 100644
index 9af7890..0000000
--- a/DataStructures/Interfaces/INode.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Get.the.Solution.DataStructure;
-
-namespace Get.the.Solution.DataStructure
-{
- ///
- /// INode interface
- ///
- ///
- public interface INode : ISingleNode
- {
- ///
- /// Get or set the left node
- ///
- INode Left { get; set; }
- ///
- /// Get or sets the right node
- ///
- new INode Right { get; set; }
- }
-
-
-}
diff --git a/DataStructures/Interfaces/ISingleNode.cs b/DataStructures/Interfaces/ISingleNode.cs
deleted file mode 100644
index e2e876d..0000000
--- a/DataStructures/Interfaces/ISingleNode.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Get.the.Solution.DataStructure
-{
- ///
- /// Single Node Interfaces
- ///
- ///
- ///
- public interface ISingleNode : IData, IEnumerable
- {
- ///
- /// Get or sets the right node
- ///
- ISingleNode Right { get; set; }
- }
-}
diff --git a/DataStructures/Interfaces/ITree.cs b/DataStructures/Interfaces/ITree.cs
deleted file mode 100644
index 76c07e0..0000000
--- a/DataStructures/Interfaces/ITree.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-
-namespace Get.the.Solution.DataStructure
-{
- ///
- /// Represents a tree
- ///
- ///
- public interface ITree where T : IComparable
- {
- bool Empty {get;}
- int Length {get;}
- int Height { get; }
- T FindIndex(int k);
- int IndexOf(T t);
- void Add(T t);
- void Remove(T val);
- bool Exists(T val);
-
- void Clear();
- void CopyTo(T[] array, int index);
-
- }
-}
diff --git a/DataStructures/Interfaces/ITreeNode.cs b/DataStructures/Interfaces/ITreeNode.cs
deleted file mode 100644
index e3fc704..0000000
--- a/DataStructures/Interfaces/ITreeNode.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-
-namespace Get.the.Solution.DataStructure
-{
- ///
- /// Represents a node in a binary tree
- ///
- ///
- public interface ITreeNode : INode
- {
- ///
- /// Get or sets the parent node
- ///
- ITreeNode Parent { get; set; }
- ///
- /// Get or sets the left node
- ///
- new ITreeNode Left { get; set; }
- ///
- /// Get or sets the right node
- ///
- new ITreeNode Right { get; set; }
- }
-}
diff --git a/DataStructures/LinkedList.cs b/DataStructures/LinkedList.cs
deleted file mode 100644
index 6160f4f..0000000
--- a/DataStructures/LinkedList.cs
+++ /dev/null
@@ -1,195 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Get.the.Solution.DataStructure
-{
-
- ///
- /// A Linked List implementation of the interface.
- ///
- ///
- /// The can be used with all objects
- /// This class is not guaranteed to be thread safe.
- ///
- /// Type of Value which should be keept.
- public class LinkedList : ICollection
- {
- ///
- /// Initializes a new instance of the LinkedList class.
- ///
- public LinkedList()
- {
- count = 0;
- }
- protected ISingleNode first;
- ///
- /// Gets or sets the first element of LinkedList .
- ///
- public virtual ISingleNode First
- {
- get
- {
- return first;
- }
- private set
- {
- first = value;
- }
- }
- protected ISingleNode last;
- ///
- /// Gets or sets the last element of LinkedList .
- ///
- public virtual ISingleNode Last
- {
- get
- {
- return last;
- }
- private set
- {
- last = value;
- }
- }
- ///
- /// Adds an item to the ICollection.
- ///
- ///
- public virtual void Add(T item)
- {
- this.Count = ++this.Count;
- if (first == null)
- {
- first = new SingleNode(item);
- last = first;
- }
- else
- {
- SingleNode singleNode = new SingleNode(item);
- last.Right = singleNode;
- last = last.Right;
- }
- }
- ///
- /// Removes all items from the ICollection.
- ///
- public void Clear()
- {
- first = null;
- Count = 0;
- }
- ///
- /// Determines whether the ICollection contains a specific value.
- ///
- ///
- ///
- public bool Contains(T item)
- {
- ISingleNode start = this.First;
- while (start != null)
- {
- if (object.Equals(start.Value, item))
- {
- return true;
- }
- start = start.Right;
- }
- return false;
- }
- ///
- /// Copies the elements of the ICollection to an Array, starting at a particular Array index.
- /// More informations regarding CopyTo
- ///
- ///
- ///
- public void CopyTo(T[] array, int arrayIndex)
- {
- throw new NotImplementedException();
- }
-
- protected int count;
- ///
- /// Gets the number of elements contained in the ICollection.
- ///
- public int Count
- {
- get
- {
- return count;
- }
- protected set
- {
- count = value;
- }
- }
- ///
- /// Gets a value indicating whether the ICollection is read-only.
- ///
- public bool IsReadOnly
- {
- get { throw new NotImplementedException(); }
- }
- ///
- /// Removes the first occurrence of a specific from the .
- /// More informations regarding remove item.
- ///
- /// The to remove from the LinkedList.
- /// true if item was successfully removed from the ; otherwise, false. This method also returns false if item is not found in the original .
- public virtual bool Remove(T value)
- {
- ISingleNode start = this.First;
- ISingleNode preview = null;
-
- while (start != null)
- {
- if (start.Value.Equals(value))
- {
- if (object.Equals(start.Value, value))
- {
- if (start == this.First)
- {
- this.First = null;
- }
- else
- {
- preview.Right = start.Right;
-
- if (Last == start)
- {
- Last = preview;
- }
- }
- count--;
- return true;
- }
- }
- preview = start;
- start = start.Right;
- }
- return false;
- }
- ///
- /// Returns an enumerator that iterates through the collection. (Inherited from IEnumerable.)
- ///
- ///
- public virtual IEnumerator GetEnumerator()
- {
- ISingleNode start = this.First;
- while (start != null)
- {
- yield return start.Value;
- start = start.Right;
- }
- }
- ///
- /// Returns an enumerator that iterates through the collection. (Inherited from IEnumerable.)
- ///
- ///
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
- {
- return new SingleListIEnumerator(this.First);
- }
- }
-}
diff --git a/DataStructures/Node.cs b/DataStructures/Node.cs
deleted file mode 100644
index 55571d6..0000000
--- a/DataStructures/Node.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System;
-using System.Diagnostics;
-using Get.the.Solution.DataStructure;
-
-namespace Get.the.Solution.DataStructure
-{
- ///
- /// Reprsents a node
- ///
- ///
- [DebuggerDisplay("Data={Value},INode.Right={Right},INode.Left={Left}")]
- public class Node : SingleNode, INode
- {
- public Node(T data)
- : base(data)
- {
-
- }
- public Node(T data, INode left, ISingleNode right)
- : base(data, right)
- {
- this.Left = left;
- }
-
- public virtual INode Left
- {
- get;
- set;
- }
- ///
- ///
- ///
- /// The base interface can not be assigned because the Right property was redefined with the keyword new.
- /// http://stackoverflow.com/questions/729527/is-it-possible-to-assign-a-base-class-object-to-a-derived-class-reference-with-a
- ///
- ///
- protected new INode right;
- public virtual new INode Right
- {
- get
- {
- return right;
- }
- set
- {
- right = value;
- //because the base type is hidden we assign it manual
- base.Right = value;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/DataStructures/SingleListIEnumerator.cs b/DataStructures/SingleListIEnumerator.cs
deleted file mode 100644
index bd4c4ac..0000000
--- a/DataStructures/SingleListIEnumerator.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Get.the.Solution.DataStructure
-{
- //http://www.codeproject.com/Articles/2836/Doubly-Linked-List-Implementation
- public class SingleListIEnumerator : IEnumerator
- {
- protected ISingleNode initSingleNode;
-
- public SingleListIEnumerator(ISingleNode singlenode)
- {
- initSingleNode = singlenode;
- Current = initSingleNode;
- }
-
- public object Current
- {
- get;
- private set;
- }
-
- public virtual bool MoveNext()
- {
- bool moveSuccessful = false;
-
- Current = initSingleNode.Right;
-
- if (Current != initSingleNode)
- moveSuccessful = true;
-
- return moveSuccessful;
- }
-
- public virtual void Reset()
- {
- Current = initSingleNode;
- }
- }
-}
diff --git a/DataStructures/SingleNode.cs b/DataStructures/SingleNode.cs
deleted file mode 100644
index f8eac5a..0000000
--- a/DataStructures/SingleNode.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-
-namespace Get.the.Solution.DataStructure
-{
- [DebuggerDisplay("Data={Value},Right={Right}")]
- public class SingleNode : ISingleNode
- {
- protected readonly T _Value;
-
- public SingleNode(T data)
- {
- _Value = data;
- }
-
- public SingleNode(T data, ISingleNode right)
- : this(data)
- {
- this.Right = right;
- }
-
- public virtual T Value
- {
- get { return _Value; }
- }
- protected ISingleNode right;
- public virtual ISingleNode Right
- {
- get
- {
- return right;
- }
- set
- {
- right = value;
- }
- }
-
- ///
- /// Returns an enumerator that iterates through the collection. (Inherited from IEnumerable.)
- ///
- ///
- public IEnumerator GetEnumerator()
- {
- ISingleNode start = this;
- while (start != null)
- {
- yield return start.Value;
- start = start.Right;
- }
- }
- ///
- /// Returns an enumerator that iterates through the collection. (Inherited from IEnumerable.)
- ///
- ///
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
- {
- ISingleNode start = this;
- while (start != null)
- {
- yield return start;
- start = start.Right;
- }
- }
- }
-}
diff --git a/DataStructures/Tree.cs b/DataStructures/Tree.cs
deleted file mode 100644
index f107b77..0000000
--- a/DataStructures/Tree.cs
+++ /dev/null
@@ -1,440 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Get.the.Solution.DataStructure
-{
- ///
- /// Represents a base tree class. Implemented binary tree concept.
- ///
- ///
- public class Tree : ITree where T : IComparable
- {
- ///
- /// Represents the method that will handle the get node functionality.
- ///
- /// The value which we are looking for.
- /// The root node of the tree to start the traversing.
- /// The node which contains the overgiven value.
- public delegate ITreeNode GetNodeDelegate(T value, ITreeNode root);
-
- ///
- /// Points to the getNodeHandler
- ///
- protected GetNodeDelegate getNodeHandler;
-
- ///
- /// Initializes a new instance of the class.
- ///
- public Tree()
- {
- this.getNodeHandler = new GetNodeDelegate(this.GetNodePrivate);
- }
- ///
- /// Initializes a new instance of the class.
- ///
- ///
- /// The delegate which implements the function GetNode(T value, ITreeNode root). See the correspondingdelegate
- /// documentation for more details.
- ///
- public Tree(GetNodeDelegate getNode)
- {
- this.getNodeHandler = getNode;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- ///
- /// A function which implements the GetNode(T value, ITreeNode root). See the correspondingdelegate
- /// documentation for more details.
- public Tree(Func, ITreeNode> getNode)
- {
- this.getNodeHandler = new GetNodeDelegate(getNode);
- }
- ///
- /// Get or sets the tree root node.
- ///
- public ITreeNode Root
- {
- get;
- protected set;
- }
- ///
- /// Gets the value that indicates whether the tree is empty or not
- ///
- public virtual bool Empty
- {
- get
- {
- return Root == null;
- }
- }
- //oder Node.AmountNode
- ///
- /// Gets the amount of nodes of the tree
- ///
- public int Length
- {
- get;
- protected set;
- }
- ///
- /// Gets the node with the correspondening value
- ///
- ///
- ///
- public virtual ITreeNode GetNode(T value)
- {
- return this.GetNodePrivate(value, this.Root);
- }
- protected virtual ITreeNode GetNodePrivate(t value, ITreeNode root) where t : IComparable
- {
- ITreeNode p = root;
- //5.CompareTo(6) = -1 First int is smaller.
- //6.CompareTo(5) = 1 First int is larger.
- //5.CompareTo(5) = 0 Ints are equal.
- while (p != null)
- {
- if (value.CompareTo(p.Value) == -1)
- {
- p = p.Left;
- }
- else if (p.Value.CompareTo(value) == 0)
- {
- return p;
- }
- else
- {
- p = p.Right;
- }
- }
-
- return null;
- }
- ///
- /// Gets a value that indicates whether the overgiven value exists in the tree
- ///
- ///
- ///
- public bool Exists(T val)
- {
- return this.GetNode(val) != null;
- }
- ///
- /// Gets the height of the tree
- ///
- public int Height
- {
- get
- {
- return GetHeight(this.Root);
- }
- }
- ///
- /// Gets the height of the tree starting from the overgiven node
- ///
- /// The node
- /// The height from the node
- protected virtual int GetHeight(ITreeNode node)
- {
- if (node == null)
- {
- return -1;
- }
- return 1 + (Math.Max(GetHeight(node.Left), GetHeight(node.Right)));
- }
- ///
- /// Reset the tree
- ///
- public void Clear()
- {
- //if (items.IsReadOnly)
- //{
- //ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
- //}
-
- ClearItems();
- }
- ///
- /// Clear the nodes of the tree
- ///
- protected virtual void ClearItems()
- {
- this.Root = null;
- }
- ///
- /// Add a new value to the tree
- ///
- /// The value to add
- public void Add(T val)
- {
- ITreeNode q = new TreeNode(val);
- ITreeNode r = null; //r wird vorgänger von q
- ITreeNode p = this.Root;
- //5.CompareTo(6) = -1 First int is smaller.
- //6.CompareTo(5) = 1 First int is larger.
- //5.CompareTo(5) = 0 Ints are equal.
- while (p != null)
- {
- r = p;
- if (q.Value.CompareTo(p.Value) == -1)
- {
- p = p.Left;
- }
- else if (p.Value.CompareTo(val) == 0)
- {
- return; //if key already exists
- }
- else
- {
- p = p.Right; //gleiche Schlüssel kommen nach rechts
- }
- }
- q.Parent = r;
- q.Left = null;
- q.Right = null;
-
- if (r == null)
- {
- this.Root = q;
- }
- else
- {
- if (q.Value.CompareTo(r.Value) == -1)
- {
- r.Left = q;
- }
- else
- {
- r.Right = q;
- }
- }
- //increase size of tree;
- Length = Length + 1;
- //node.n = 1 +
- //node.AmountofNode = size(node.Lef) + size(node.right)+1; (size.node) gibt node.amountnode zurück
- }
- ///
- /// The value to remove
- ///
- ///
- public void Remove(T val)
- {
- if (Empty)
- {
- return;
- }
- ITreeNode r = null;
- ITreeNode root = this.Root;
- ITreeNode q = GetNode(val);
- ITreeNode p = null;
-
- if (q.Left == null || q.Right == null)
- { //q hat max 1 NaChfolger --> wird selbst entfernt
- r = q;
- }
- else
- {
- //q hat 2 Nachfolger -> wird durch successor ersetzt, dieser wird entfernt
- r = Successor(q);
- //umhängen der daten von r nach q (q.Value = r.Value;)
- q = new TreeNode(r.Value, q.Parent, q.Left, q.Right);
- if (q == null)
- { }
- }
- //lasse p auf kind von r verweisen (p=null, falls r keine kinder hat)
- if (r.Left != null)
- {
- p = r.Left;
- }
- else
- {
- p = r.Right;
- }
- if (p != null)
- {
- p.Parent = r.Parent;
- //erzeuge einen verweis von p auf seinen neuen vorgänger ( den vorgänger von r)
- }
- //hänge p anstelle von r in den Baum ein
- if (r.Parent == null)
- {
- //r war Wurzel: neue wurzel ist p
- this.Root = p;
- }
- else
- {
- //hänge p an der richtigen seite des vorgängerknotens von r ein
- if (r == r.Parent.Left)
- {
- r.Parent.Left = p; //p sei linker nachfolger
- }
- else
- {
- r.Parent.Right = p;
- }
- }
- r = null;
-
- Length = Length - 1;
- //TODO Save amount of subtree in node
- }
- ///
- /// Returns all nodes of the tree ascending.
- ///
- ///
- /// Recursiv implemention. By default you would call the method with the root node of the tree and pass an empty initalized collection.
- ///
- /// The value type of the nodes
- /// The starting node.
- /// The current created list
- /// A list of all nodes from the starting node.
- protected IList> InOrder(ITreeNode p, IList> list) where t : IComparable
- {
- if (p != null)
- {
- InOrder(p.Left, list);
- list.Add(p);
- InOrder(p.Right, list);
- }
- return list;
- }
- ///
- /// Returns the successor from the overgiven node
- ///
- /// The node from which we should get the successor
- /// The successor of the overgiven node
- public virtual ITreeNode Successor(ITreeNode p)
- {
- ITreeNode q = null;
- if (p.Right != null)
- {
- return Minimum(p.Right);
- }
- else
- {
- q = p.Parent;
- while (q != null && p == q.Right)
- {
- p = q;
- q = q.Parent;
- }
- return q;
- }
- }
- ///
- /// Returns the child node with the minimum value
- ///
- /// the node from which we should seek the node with the minimum value
- /// The node with the minimum value
- public virtual ITreeNode Minimum(ITreeNode p)
- {
- if (p == null)
- {
- return null;
- }
- while (p.Left != null)
- {
- p = p.Left;
- }
- return p;
- }
- ///
- /// Copies the entire Collection to a compatible one-dimensional Array, starting at the specified index of the target array.
- ///
- ///
- /// The one-dimensional Array that is the destination of the elements copied from Collection. The Array must have zero-based indexing.
- ///
- ///
- /// The zero-based index in array at which copying begins.
- ///
- public void CopyTo(T[] array, int index)
- {
- if (array == null)
- {
- throw new ArgumentNullException("array");
- }
-
- if (index < 0 || index > array.Length)
- {
- throw new ArgumentOutOfRangeException("index");
- }
-
- if (array.Length - index < Length)
- {
- throw new ArgumentException("InsufficientSpace");
- }
-
- IList> arr = InOrder(this.Root, new List>());
- for (int i = 0; i < arr.Count;i++ )
- {
- array[index++] = arr[i].Value;
- }
- }
- public virtual T FindIndex(int k)
- {
- //TODO Optimize
- //http://stackoverflow.com/questions/30013591/binary-tree-find-position-in-inorder-traversal
- //INode treenode = InOrder(this.Root, new Counter(k));
- return InOrder(this.Root, new List>()).ElementAt(k).Value;
- }
- ///
- /// Liefert die Position des Wertes val in der InorderReihenfolge aller Werte
- /// im Baum zuruck. Wiederum gilt für diese Aufgabe, dass das ¨ erste
- /// Element an Position 0 steht. Falls das Element nicht im Baum vorhanden
- /// ist, dann soll jene Position zuruckgeliefert werden an der es eingef ¨
- /// ugt werden w ¨ urde
- ///
- ///
- public virtual int IndexOf(T value)
- {
- ///man sucht sich als erstes den wert und wenn man weiß wieviele kinder man hat (für den aktuellen knoten)
- ///dann weiß man auch an welcher position man sich in der inorder befindet und hätte so das element zurück geben können.
- ///zumindest hab ich seine erklärung so verstanden. hatte den simon strassl
- //return GetNodePrivate(value, this.Root);
-
- //TODO Optimize
- var list = InOrder(this.Root, new List>());
-
- int l = 0;
- int h = list.Count - 1;
- //binary search skriptum
- while (l <= h)
- {
- int m = (l + h) / 2;
- //5.CompareTo(6) = -1 First int is smaller.
- //6.CompareTo(5) = 1 First int is larger.
- //5.CompareTo(5) = 0 Ints are equal.
- if (value.CompareTo(list.ElementAt(m).Value) == 1)
- {
- l = m + 1;
- }
- else if (value.CompareTo(list.ElementAt(m).Value) == -1)
- {
- h = m - 1;
- }
- else
- {
- return m;
- }
- }
- return l;
- }
- ///
- /// Tree node type which extends the classic node to the property childrens
- ///
- ///
- private class Node : Get.the.Solution.DataStructure.Node
- {
- public Node(T data) : base(data) { }
- ///
- /// Returns the amount of childrens of the node
- ///
- public int Childrens { get; set; }
- }
-
-
- }
-}
diff --git a/DataStructures/TreeNode.cs b/DataStructures/TreeNode.cs
deleted file mode 100644
index be76a07..0000000
--- a/DataStructures/TreeNode.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-using Get.the.Solution.DataStructure;
-
-namespace Get.the.Solution.DataStructure
-{
- [DebuggerDisplay("Data={Value},Right={TreeNode.Right},Left={TreeNode.Left}")]
- public class TreeNode : Node, ITreeNode
- {
- public TreeNode(T value)
- : base(value)
- {
- this.Parent = null;
- }
- public TreeNode(T data, INode left, INode right)
- : this(data)
- {
- Left = (ITreeNode)left;
- Right = (ITreeNode)right;
-
- }
- public TreeNode(T data, ITreeNode parent, INode left, INode right)
- : this(data, left, right)
- {
- Parent = parent;
- }
- public ITreeNode Parent
- {
- get;
- set;
- }
- private ITreeNode left;
- public virtual new ITreeNode Left
- {
- get
- {
- return left;
- }
- set
- {
- left = value;
- //because the base type is hide we assign it manual
- base.Left = value;
- }
- }
- private new ITreeNode right;
- public virtual new ITreeNode Right
- {
- get
- {
- return right;
- }
- set
- {
- right = value;
- //because the base type is hide we assign it manual
- base.Right = value;
- }
- }
- }
-}