diff --git a/Perspex.sln b/Perspex.sln
index 59287f9d89..22b196d2c8 100644
--- a/Perspex.sln
+++ b/Perspex.sln
@@ -31,10 +31,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Application", "src\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Diagnostics", "src\Perspex.Diagnostics\Perspex.Diagnostics.csproj", "{7062AE20-5DCC-4442-9645-8195BDECE63E}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utils", "Utils", "{2BAFBE53-7FA4-4BB9-976F-9AFCC4F9847D}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NGenerics", "src\NGenerics\NGenerics.csproj", "{415E048E-4611-4815-9CF2-D774E29079AC}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Animation", "src\Perspex.Animation\Perspex.Animation.csproj", "{D211E587-D8BC-45B9-95A4-F297C8FA5200}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}"
@@ -163,10 +159,6 @@ Global
{7062AE20-5DCC-4442-9645-8195BDECE63E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7062AE20-5DCC-4442-9645-8195BDECE63E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7062AE20-5DCC-4442-9645-8195BDECE63E}.Release|Any CPU.Build.0 = Release|Any CPU
- {415E048E-4611-4815-9CF2-D774E29079AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {415E048E-4611-4815-9CF2-D774E29079AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {415E048E-4611-4815-9CF2-D774E29079AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {415E048E-4611-4815-9CF2-D774E29079AC}.Release|Any CPU.Build.0 = Release|Any CPU
{D211E587-D8BC-45B9-95A4-F297C8FA5200}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D211E587-D8BC-45B9-95A4-F297C8FA5200}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D211E587-D8BC-45B9-95A4-F297C8FA5200}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -251,7 +243,6 @@ Global
{811A76CF-1CF6-440F-963B-BBE31BD72A82} = {B39A8919-9F95-48FE-AD7B-76E08B509888}
{3E908F67-5543-4879-A1DC-08EACE79B3CD} = {B39A8919-9F95-48FE-AD7B-76E08B509888}
{EC42600F-049B-43FF-AED1-8314D61B2749} = {B39A8919-9F95-48FE-AD7B-76E08B509888}
- {415E048E-4611-4815-9CF2-D774E29079AC} = {2BAFBE53-7FA4-4BB9-976F-9AFCC4F9847D}
{47ECDF59-DEF8-4C53-87B1-2098A3429059} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
{5CCB5571-7C30-4E7D-967D-0E2158EBD91F} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
{76716382-3159-460E-BDA6-C5715CF606D7} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
diff --git a/nuget/build-version.ps1 b/nuget/build-version.ps1
index d046f34888..1cce68564d 100644
--- a/nuget/build-version.ps1
+++ b/nuget/build-version.ps1
@@ -32,7 +32,6 @@ Copy-Item ..\src\Markup\Perspex.Markup.Xaml\bin\Release\Perspex.Markup.Xaml.dll
Copy-Item ..\src\Markup\Perspex.Markup.Xaml\bin\Release\Perspex.Markup.Xaml.xml $lib
Copy-Item ..\src\Perspex.HtmlRenderer\bin\Release\Perspex.HtmlRenderer.dll $lib
Copy-Item ..\src\Perspex.ReactiveUI\bin\Release\Perspex.ReactiveUI.dll $lib
-Copy-Item ..\src\NGenerics\bin\Release\NGenerics.dll $lib
Copy-Item ..\src\Windows\Perspex.Direct2D1\bin\Release\Perspex.Direct2D1.dll $build
Copy-Item ..\src\Windows\Perspex.Direct2D1\bin\Release\SharpDX.dll $build
diff --git a/samples/XamlTestApplication/XamlTestApplication.csproj b/samples/XamlTestApplication/XamlTestApplication.csproj
index 52030934a1..5e99700b38 100644
--- a/samples/XamlTestApplication/XamlTestApplication.csproj
+++ b/samples/XamlTestApplication/XamlTestApplication.csproj
@@ -85,10 +85,6 @@
-
- {415E048E-4611-4815-9CF2-D774E29079AC}
- NGenerics
-
{D211E587-D8BC-45B9-95A4-F297C8FA5200}
Perspex.Animation
diff --git a/src/NGenerics/Constants.cs b/src/NGenerics/Constants.cs
deleted file mode 100644
index 0d7597bab4..0000000000
--- a/src/NGenerics/Constants.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-namespace NGenerics
-{
- internal static class Constants
- {
- public const string NotEnoughSpaceInTheTargetArray = "Not enough space in the target array.";
- }
-}
\ No newline at end of file
diff --git a/src/NGenerics/DataStructures/Comparers/ComparisonComparer.cs b/src/NGenerics/DataStructures/Comparers/ComparisonComparer.cs
deleted file mode 100644
index aee2fd48d1..0000000000
--- a/src/NGenerics/DataStructures/Comparers/ComparisonComparer.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-
-using System;
-using System.Collections.Generic;
-using NGenerics.Util;
-
-namespace NGenerics.Comparers
-{
- ///
- /// A Comparer using a Comparison delegate for comparisons between items.
- ///
- /// The type of the objects to compare.
- //[Serializable]
- public sealed class ComparisonComparer : IComparer
- {
- #region Globals
-
- private Comparison _comparison;
-
- #endregion
-
- #region Construction
-
-
- /// The comparison.
- /// is a null reference (Nothing in Visual Basic).
- public ComparisonComparer(Comparison comparison)
- {
- Guard.ArgumentNotNull(comparison, "comparison");
-
- _comparison = comparison;
- }
-
- #endregion
-
- #region Public Members
-
- ///
- /// Gets or sets the comparison used in this comparer.
- ///
- /// The comparison used in this comparer.
- /// is a null reference (Nothing in Visual Basic).
- public Comparison Comparison
- {
- get
- {
- return _comparison;
- }
- set
- {
- Guard.ArgumentNotNull(value, "value");
-
- _comparison = value;
- }
- }
-
- #endregion
-
- #region IComparer Members
-
- ///
- public int Compare(T x, T y)
- {
- return _comparison(x, y);
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/src/NGenerics/DataStructures/Comparers/KeyValuePairComparer.cs b/src/NGenerics/DataStructures/Comparers/KeyValuePairComparer.cs
deleted file mode 100644
index 8b7a258f39..0000000000
--- a/src/NGenerics/DataStructures/Comparers/KeyValuePairComparer.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-
-using System;
-using System.Collections.Generic;
-
-namespace NGenerics.Comparers
-{
- ///
- /// A comparer for comparing keys for the KeyValuePair class.
- ///
- /// The key type.
- /// The value type.
- //[Serializable]
- public class KeyValuePairComparer : IComparer>
- {
- #region Globals
-
- private readonly IComparer _comparer;
-
- #endregion
-
- #region Construction
-
- ///
- /// Initializes a new instance of the class.
- ///
- public KeyValuePairComparer()
- {
- _comparer = Comparer.Default;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The comparer.
- public KeyValuePairComparer(IComparer comparer)
- {
- if (comparer == null)
- {
- throw new ArgumentNullException("comparer");
- }
-
- _comparer = comparer;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The comparison.
- public KeyValuePairComparer(Comparison comparison)
- {
- if (comparison == null)
- {
- throw new ArgumentNullException("comparison");
- }
-
- _comparer = new ComparisonComparer(comparison);
- }
-
- #endregion
-
- #region IComparer> Members
-
- ///
- public int Compare(KeyValuePair x, KeyValuePair y)
- {
- return _comparer.Compare(x.Key, y.Key);
- }
-
- #endregion
-
- #region IComparer Members
-
- ///
- public int Compare(TKey x, TKey y)
- {
- return _comparer.Compare(x, y);
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/src/NGenerics/DataStructures/Comparers/ReverseComparer.cs b/src/NGenerics/DataStructures/Comparers/ReverseComparer.cs
deleted file mode 100644
index fbfa55cc25..0000000000
--- a/src/NGenerics/DataStructures/Comparers/ReverseComparer.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-
-using System;
-using System.Collections.Generic;
-using NGenerics.Util;
-
-namespace NGenerics.Comparers
-{
- ///
- /// A comparer that wraps the IComparable interface to reproduce the opposite comparison result.
- ///
- /// The type of the objects to compare.
- //[Serializable]
- public sealed class ReverseComparer : IComparer
- {
- #region Globals
-
- private IComparer _comparerToUse;
-
- #endregion
-
- #region Construction
- ///
- public ReverseComparer()
- {
- _comparerToUse = Comparer.Default;
- }
-
-
- /// The comparer to reverse.
- /// is a null reference (Nothing in Visual Basic).
- public ReverseComparer(IComparer comparer)
- {
- Guard.ArgumentNotNull(comparer, "comparer");
- _comparerToUse = comparer;
- }
-
- #endregion
-
- #region IComparer Members
-
- ///
- public int Compare(T x, T y)
- {
- return (_comparerToUse.Compare(y, x));
- }
-
- #endregion
-
- #region Public Members
-
- ///
- /// Gets or sets the comparer used in this instance.
- ///
- /// The comparer.
- /// is a null reference (Nothing in Visual Basic).
- public IComparer Comparer
- {
- get
- {
- return _comparerToUse;
- }
- set
- {
- Guard.ArgumentNotNull(value, "value");
-
- _comparerToUse = value;
- }
- }
-
- #endregion
- }
-}
diff --git a/src/NGenerics/DataStructures/General/Heap.cs b/src/NGenerics/DataStructures/General/Heap.cs
deleted file mode 100644
index 155ad10059..0000000000
--- a/src/NGenerics/DataStructures/General/Heap.cs
+++ /dev/null
@@ -1,405 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using NGenerics.Comparers;
-using System.Diagnostics.CodeAnalysis;
-using NGenerics.Util;
-
-namespace NGenerics.DataStructures.General
-{
- ///
- /// An implementation of a Heap data structure.
- ///
- /// The type of item stored in the .
- //[Serializable]
- [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
- [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
- public class Heap : ICollection, IHeap
- {
- #region Globals
-
- private const string heapIsEmpty = "The heap is empty.";
- private readonly List _data;
- private readonly IComparer _comparerToUse;
- private readonly HeapType _thisType;
-
- #endregion
-
- #region Construction
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The type of Heap to create.
- /// is not either or .
- ///
- ///
- ///
- ///
- public Heap(HeapType type) : this(type, Comparer.Default) { }
-
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The type of heap.
- /// The capacity.
- /// is not either or .
- /// is less than 0.
- /// .
- ///
- ///
- ///
- ///
- public Heap(HeapType type, int capacity) : this(type, capacity, Comparer.Default) { }
-
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The type of heap.
- /// The comparer.
- /// is not either or .
- public Heap(HeapType type, Comparison comparer) : this(type, new ComparisonComparer(comparer)) { }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The type of heap.
- /// The capacity of the heap to start with.
- /// The comparer.
- /// is not either or .
- /// is less than 0.
- public Heap(HeapType type, int capacity, Comparison comparer) : this(type, capacity, new ComparisonComparer(comparer)) { }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The type of Heap to create.
- /// The comparer to use.
- /// is a null reference (Nothing in Visual Basic).
- /// is not either or .
- ///
- ///
- ///
- ///
- public Heap(HeapType type, IComparer comparer)
- {
- Guard.ArgumentNotNull(comparer, "comparer");
-
- if ((type != HeapType.Minimum) && (type != HeapType.Maximum))
- {
- throw new ArgumentOutOfRangeException("type");
- }
-
- _thisType = type;
-
- _data = new List { default(T) };
-
- _comparerToUse = type == HeapType.Minimum ? comparer : new ReverseComparer(comparer);
- }
-
-
- /// The type of heap.
- /// The initial capacity of the Heap.
- /// The comparer to use.
- /// is less than 0..
- /// is a null reference (Nothing in Visual Basic).
- /// is not either or .
- public Heap(HeapType type, int capacity, IComparer comparer)
- {
- Guard.ArgumentNotNull(comparer, "comparer");
-
- if ((type != HeapType.Minimum) && (type != HeapType.Maximum))
- {
- throw new ArgumentOutOfRangeException("type");
- }
- _thisType = type;
-
- _data = new List(capacity) { default(T) };
-
- _comparerToUse = type == HeapType.Minimum ? comparer : new ReverseComparer(comparer);
- }
-
- #endregion
-
- #region Public Members
-
-
- ///
- ///
- ///
- ///
- ///
- public T Root
- {
- get
- {
- #region Validation
-
- if (Count == 0)
- {
- throw new InvalidOperationException(heapIsEmpty);
- }
-
- #endregion
-
- return _data[1];
- }
- }
-
-
- ///
- ///
- ///
- ///
- ///
- public T RemoveRoot()
- {
- #region Validation
-
- if (Count == 0)
- {
- throw new InvalidOperationException(heapIsEmpty);
- }
-
- #endregion
-
- // The minimum item to return.
- var minimum = _data[1];
-
- RemoveRootItem(minimum);
- return minimum;
- }
-
-
- ///
- /// Removes the root item.
- ///
- /// The item.
- ///
- /// Notes to Inheritors:
- /// Derived classes can override this method to change the behavior of the method.
- ///
- protected virtual void RemoveRootItem(T item)
- {
- // The last item in the heap
- var last = _data[Count];
- _data.RemoveAt(Count);
-
- // If there's still items left in this heap, re-heapify it.
- if (Count > 0)
- {
- // Re-heapify the binary tree to conform to the heap property
- var counter = 1;
-
- while ((counter * 2) < (_data.Count))
- {
- var child = counter * 2;
-
- if (((child + 1) < (_data.Count)) &&
- (_comparerToUse.Compare(_data[child + 1], _data[child]) < 0))
- {
- child++;
- }
-
- if (_comparerToUse.Compare(last, _data[child]) <= 0)
- {
- break;
- }
-
- _data[counter] = _data[child];
- counter = child;
- }
-
- _data[counter] = last;
- }
- }
-
-
- ///
- /// Gets the type of heap represented by this instance.
- ///
- /// The type of heap.
- ///
- ///
- ///
- ///
- [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")]
- public HeapType Type => _thisType;
-
- #endregion
-
- #region ICollection Members
-
-
-
- ///
- ///
- ///
- ///
- ///
- public bool IsEmpty => Count == 0;
-
-
- ///
- ///
- ///
- ///
- ///
- public bool Contains(T item)
- {
- return _data.Contains(item);
- }
-
- ///
- ///
- ///
- ///
- ///
- public void CopyTo(T[] array, int arrayIndex)
- {
- #region Validation
-
- Guard.ArgumentNotNull(array, "array");
-
- if ((array.Length - arrayIndex) < Count)
- {
- throw new ArgumentException(Constants.NotEnoughSpaceInTheTargetArray, "array");
- }
-
- #endregion
-
- for (var i = 1; i < _data.Count; i++)
- {
- array[arrayIndex++] = _data[i];
- }
- }
-
- ///
- ///
- ///
- ///
- ///
- public int Count => _data.Count - 1;
-
- ///
- ///
- ///
- ///
- ///
- public void Add(T item)
- {
- AddItem(item);
- }
-
- ///
- /// Adds the item.
- ///
- /// The item to add.
- ///
- /// Notes to Inheritors:
- /// Derived classes can override this method to change the behavior of the method.
- ///
- protected virtual void AddItem(T item)
- {
- // Add a dummy to the end of the list (it will be replaced)
- _data.Add(default(T));
-
- var counter = _data.Count - 1;
-
- while ((counter > 1) && (_comparerToUse.Compare(_data[counter / 2], item) > 0))
- {
- _data[counter] = _data[counter / 2];
- counter = counter / 2;
- }
-
- _data[counter] = item;
- }
-
-
-
- ///
- /// Always.
- [SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
- bool ICollection.Remove(T item)
- {
- throw new NotSupportedException();
- }
-
- ///
- /// Returns an enumerator that iterates through the collection.
- ///
- ///
- /// A that can be used to iterate through the collection.
- ///
- ///
- ///
- ///
- ///
- public IEnumerator GetEnumerator()
- {
- for (var i = 1; i < _data.Count; i++)
- {
- yield return _data[i];
- }
- }
-
- ///
- ///
- ///
- ///
- ///
- public void Clear()
- {
- ClearItems();
- }
- ///
- /// Clears all the objects in this instance.
- ///
- ///
- /// Notes to Inheritors:
- /// Derived classes can override this method to change the behavior of the method.
- ///
- protected virtual void ClearItems()
- {
- _data.RemoveRange(1, _data.Count - 1); // Clears all objects in this instance except the first dummy one.
- }
-
- #endregion
-
- #region ICollection Members
-
- ///
- ///
- ///
- ///
- ///
- public bool IsReadOnly => false;
-
- #endregion
-
- #region IEnumerable Members
-
- ///
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- #endregion
- }
-}
diff --git a/src/NGenerics/DataStructures/General/HeapType.cs b/src/NGenerics/DataStructures/General/HeapType.cs
deleted file mode 100644
index 5622bdb10c..0000000000
--- a/src/NGenerics/DataStructures/General/HeapType.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-
-
-namespace NGenerics.DataStructures.General
-{
- ///
- /// The type of to implemented.
- ///
- public enum HeapType
- {
- ///
- /// Makes the heap a Minimum-Heap - the smallest item is kept in the root of the .
- ///
- Minimum,
-
- ///
- /// Makes the heap a Maximum-Heap - the largest item is kept in the root of the .
- ///
- Maximum
- }
-}
\ No newline at end of file
diff --git a/src/NGenerics/DataStructures/General/IHeap.cs b/src/NGenerics/DataStructures/General/IHeap.cs
deleted file mode 100644
index c8db163f01..0000000000
--- a/src/NGenerics/DataStructures/General/IHeap.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-
-using System;
-
-namespace NGenerics.DataStructures.General
-{
- ///
- /// An interface for the data structure.
- ///
- /// The type of elements in the heap.
- public interface IHeap
- {
- ///
- /// Adds the specified item.
- ///
- /// The item.
- void Add(T item);
-
- ///
- /// Removes the root and returns it.
- ///
- /// The root of the .
- /// The is empty.
- T RemoveRoot();
-
- ///
- /// Gets the root.
- ///
- /// The root.
- /// The is empty.
- T Root { get; }
- }
-}
diff --git a/src/NGenerics/DataStructures/Queues/IQueue.cs b/src/NGenerics/DataStructures/Queues/IQueue.cs
deleted file mode 100644
index e1e6df809d..0000000000
--- a/src/NGenerics/DataStructures/Queues/IQueue.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-
-using System;
-using System.Diagnostics.CodeAnalysis;
-
-namespace NGenerics.DataStructures.Queues
-{
- ///
- /// A queue interface.
- ///
- /// The type of the elements in the queue.
- [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
- public interface IQueue
- {
- ///
- /// Enqueues the item at the back of the queue.
- ///
- /// The item.
- void Enqueue(T item);
-
- ///
- /// Dequeues the item at the front of the queue.
- ///
- /// The item at the front of the queue.
- /// The is empty.
- T Dequeue();
-
- ///
- /// Peeks at the item in the front of the queue, without removing it.
- ///
- /// The item at the front of the queue.
- /// The is empty.
- T Peek();
- }
-}
diff --git a/src/NGenerics/DataStructures/Queues/PriorityQueue.cs b/src/NGenerics/DataStructures/Queues/PriorityQueue.cs
deleted file mode 100644
index ec91df458e..0000000000
--- a/src/NGenerics/DataStructures/Queues/PriorityQueue.cs
+++ /dev/null
@@ -1,556 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-
- Community contributions :
- - TKey Peek(out TPriority) contributed by Karl Shulze (http://www.karlschulze.com/).
-*/
-
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using NGenerics.Comparers;
-using NGenerics.DataStructures.Trees;
-using NGenerics.Util;
-
-namespace NGenerics.DataStructures.Queues
-{
- ///
- /// An implementation of a Priority Queue (can be or ).
- ///
- /// The type of the priority in the .
- /// The type of the elements in the .
- [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
- [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
- //[Serializable]
- public class PriorityQueue : ICollection, IQueue
- {
- #region Globals
-
- private readonly RedBlackTreeList _tree;
- private TPriority _defaultPriority;
- private readonly PriorityQueueType _queueType;
-
- #endregion
-
- #region Construction
-
- /// Type of the queue.
- ///
- ///
- ///
- ///
- public PriorityQueue(PriorityQueueType queueType) :
- this(queueType, Comparer.Default)
- {
- }
-
- ///
- public PriorityQueue(PriorityQueueType queueType, IComparer comparer)
- {
- if ((queueType != PriorityQueueType.Minimum) && (queueType != PriorityQueueType.Maximum))
- {
- throw new ArgumentOutOfRangeException("queueType");
- }
- _queueType = queueType;
- _tree = new RedBlackTreeList(comparer);
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Type of the queue.
- /// The comparison.
- ///
- public PriorityQueue(PriorityQueueType queueType, Comparison comparison) :
- this(queueType, new ComparisonComparer(comparison))
- {
- }
-
- #endregion
-
- #region IQueue Members
-
- ///
- ///
- ///
- ///
- ///
- public void Enqueue(TValue item)
- {
- Add(item);
- }
-
- ///
- /// Enqueues the specified item.
- ///
- /// The item.
- /// The priority.
- ///
- ///
- ///
- ///
- public void Enqueue(TValue item, TPriority priority)
- {
- Add(item, priority);
- }
-
- ///
- /// Dequeues the item at the front of the queue.
- ///
- /// The item at the front of the queue.
- ///
- ///
- ///
- ///
- public TValue Dequeue()
- {
- TPriority priority;
- return Dequeue(out priority);
- }
-
-
- ///
- /// Peeks at the item in the front of the queue, without removing it.
- ///
- /// The item at the front of the queue.
- ///
- ///
- ///
- ///
- public TValue Peek()
- {
- var association = GetNextItem();
-
- // Always dequeue in FIFO manner
- return association.Value.First.Value;
- }
-
-
- ///
- /// Peeks at the item in the front of the queue, without removing it.
- ///
- /// The priority of the item.
- /// The item at the front of the queue.
- ///
- ///
- ///
- ///
- public TValue Peek(out TPriority priority)
- {
- var association = GetNextItem();
- var item = association.Value.First.Value;
- priority = association.Key;
- return item;
- }
-
- #endregion
-
- #region ICollection Members
-
- ///
- ///
- ///
- ///
- ///
- public bool IsReadOnly => false;
-
- #endregion
-
- #region IEnumerable Members
-
- ///
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- ///
- /// Returns an enumerator that iterates through the collection.
- ///
- ///
- /// A that can be used to iterate through the collection.
- ///
- ///
- ///
- ///
- ///
- public IEnumerator GetEnumerator()
- {
- return _tree.GetValueEnumerator();
- }
-
- #endregion
-
- #region Public Members
-
- ///
- ///
- ///
- ///
- ///
- public int Count { get; private set; }
-
- ///
- ///
- ///
- ///
- ///
- public bool Contains(TValue item)
- {
- return _tree.ContainsValue(item);
- }
-
- ///
- ///
- ///
- ///
- ///
- public void CopyTo(TValue[] array, int arrayIndex)
- {
- #region Validation
-
- Guard.ArgumentNotNull(array, "array");
-
- if ((array.Length - arrayIndex) < Count)
- {
- throw new ArgumentException(Constants.NotEnoughSpaceInTheTargetArray, "array");
- }
-
- #endregion
-
-
- foreach (var association in _tree)
- {
- var items = association.Value;
-
- foreach (var item in items)
- {
- array.SetValue(item, arrayIndex++);
- }
- }
- }
-
- ///
- ///
- ///
- ///
- ///
- public void Add(TValue item)
- {
- Add(item, _defaultPriority);
- }
-
- ///
- /// Adds an item to the .
- ///
- /// The object to add to the .
- /// The priority of the item.
- /// The is read-only.
- ///
- ///
- ///
- ///
- public void Add(TValue item, TPriority priority)
- {
- AddItem(item, priority);
- }
-
- ///
- public bool Remove(TValue item)
- {
- TPriority priority;
- return Remove(item, out priority);
- }
-
- ///
- /// Returns an enumerator that iterates through the keys in the collection.
- ///
- /// A that can be used to iterate through the keys in the collection.
- ///
- ///
- ///
- ///
- [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
- [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
- public IEnumerator> GetKeyEnumerator()
- {
- return _tree.GetKeyEnumerator();
- }
-
- ///
- ///
- ///
- ///
- ///
- public void Clear()
- {
- ClearItems();
- }
-
- ///
- /// Dequeues the item from the head of the queue.
- ///
- /// The priority of the item to dequeue.
- /// The item at the head of the queue.
- /// The is empty.
- ///
- ///
- ///
- ///
- [SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
- public TValue Dequeue(out TPriority priority)
- {
- return DequeueItem(out priority);
- }
-
- ///
- /// Dequeues the item at the front of the queue.
- ///
- /// The item at the front of the queue.
- ///
- /// Notes to Inheritors:
- /// Derived classes can override this method to change the behavior of the or methods.
- ///
- [SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
- protected virtual TValue DequeueItem(out TPriority priority)
- {
- var association = GetNextItem();
-
- var item = association.Value.First.Value;
- association.Value.RemoveFirst();
-
- var key = association.Key;
-
- if (association.Value.Count == 0)
- {
- _tree.Remove(association.Key);
- }
-
- Count--;
-
- priority = key;
- return item;
- }
-
- ///
- /// Gets or sets the default priority.
- ///
- /// The default priority.
- public TPriority DefaultPriority
- {
- get
- {
- return _defaultPriority;
- }
- set
- {
- _defaultPriority = value;
- }
- }
-
- ///
- /// Removes the first occurrence of the specified item from the property queue.
- ///
- /// The item to remove.
- /// The priority associated with the item.
- /// true if the item exists in the and has been removed; otherwise false.
- [SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#")]
- public bool Remove(TValue item, out TPriority priority)
- {
- return RemoveItem(item, out priority);
- }
- ///
- /// Removes the item.
- ///
- /// The item to remove
- /// The priority of the item that was removed.
- /// An indication of whether the item was found, and removed.
- ///
- /// Notes to Inheritors:
- /// Derived classes can override this method to change the behavior of the method.
- ///
- [SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#")]
- protected virtual bool RemoveItem(TValue item, out TPriority priority)
- {
- var removed = _tree.Remove(item, out priority);
-
- if (removed)
- {
- Count--;
- }
-
- return removed;
- }
-
- ///
- /// Removes the items with the specified priority.
- ///
- /// The priority.
- /// true if the priority exists in the and has been removed; otherwise false.
- public bool RemovePriorityGroup(TPriority priority)
- {
- return RemoveItems(priority);
- }
-
- ///
- /// Removes the items from the collection with the specified priority.
- ///
- /// The priority to search for.
- /// An indication of whether items were found having the specified priority.
- protected virtual bool RemoveItems(TPriority priority)
- {
- LinkedList items;
-
- if (_tree.TryGetValue(priority, out items))
- {
- _tree.Remove(priority);
- Count -= items.Count;
- return true;
- }
-
- return false;
- }
-
- ///
- /// Removes the items with the specified priority.
- ///
- /// The priority.
- /// The items with the specified priority.
- public IList GetPriorityGroup(TPriority priority)
- {
- LinkedList items;
-
- return _tree.TryGetValue(priority, out items) ? new List(items) : new List();
- }
-
-
- ///
- /// Adds the specified items to the priority queue with the specified priority.
- ///
- /// The items.
- /// The priority.
- /// is a null reference (Nothing in Visual Basic).
- public void AddPriorityGroup(IList items, TPriority priority)
- {
- #region Validation
-
- Guard.ArgumentNotNull(items, "items");
-
- #endregion
-
- AddPriorityGroupItem(items, priority);
- }
-
- ///
- /// Adds the specified items to the priority queue with the specified priority.
- ///
- /// The items.
- /// The priority.
- ///
- /// Notes to Inheritors:
- /// Derived classes can override this method to change the behavior of the method.
- ///
- protected virtual void AddPriorityGroupItem(IList items, TPriority priority)
- {
- LinkedList currentValues;
-
- if (_tree.TryGetValue(priority, out currentValues))
- {
- for (var i = 0; i < items.Count; i++)
- {
- currentValues.AddLast(items[i]);
- }
- }
- else
- {
- currentValues = new LinkedList(items);
- _tree.Add(priority, currentValues);
- }
- }
-
- #endregion
-
- #region Protected Members
-
- ///
- /// Adds the item to the queue.
- ///
- /// The item to add.
- /// The priority of the item.
- ///
- /// Notes to Inheritors:
- /// Derived classes can override this method to change the behavior of the method.
- ///
- protected virtual void AddItem(TValue item, TPriority priority)
- {
- LinkedList list;
-
- if (_tree.TryGetValue(priority, out list))
- {
- list.AddLast(item);
- }
- else
- {
- list = new LinkedList();
- list.AddLast(item);
- _tree.Add(priority, list);
- }
-
- Count++;
- }
-
- ///
- /// Clears all the objects in this instance.
- ///
- ///
- /// Notes to Inheritors:
- /// Derived classes can override this method to change the behavior of the method.
- ///
- protected virtual void ClearItems()
- {
- _tree.Clear();
- Count = 0;
- }
-
- #endregion
-
- #region Private Members
-
- ///
- /// Checks if the list is not empty, and if it is, throw an exception.
- ///
- private void CheckTreeNotEmpty()
- {
- if (_tree.Count == 0)
- {
- throw new InvalidOperationException("The Priority Queue is empty.");
- }
- }
-
- ///
- /// Gets the next item.
- ///
- private KeyValuePair> GetNextItem()
- {
- #region Validation
-
- CheckTreeNotEmpty();
-
- #endregion
-
- return _queueType == PriorityQueueType.Maximum ? _tree.Maximum : _tree.Minimum;
- }
-
- #endregion
- }
-}
diff --git a/src/NGenerics/DataStructures/Queues/PriorityQueueType.cs b/src/NGenerics/DataStructures/Queues/PriorityQueueType.cs
deleted file mode 100644
index 94ee9a2dd9..0000000000
--- a/src/NGenerics/DataStructures/Queues/PriorityQueueType.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-namespace NGenerics.DataStructures.Queues
-{
- ///
- /// Specifies the Priority Queue type (min or max).
- ///
- public enum PriorityQueueType
- {
- ///
- /// Specify a Minimum .
- ///
- Minimum = 0,
-
- ///
- /// Specify a Maximum .
- ///
- Maximum = 1
- }
-}
\ No newline at end of file
diff --git a/src/NGenerics/DataStructures/Trees/BinarySearchTreeBase.cs b/src/NGenerics/DataStructures/Trees/BinarySearchTreeBase.cs
deleted file mode 100644
index f7a55392d6..0000000000
--- a/src/NGenerics/DataStructures/Trees/BinarySearchTreeBase.cs
+++ /dev/null
@@ -1,529 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using NGenerics.Comparers;
-using NGenerics.Patterns.Visitor;
-using NGenerics.Util;
-
-namespace NGenerics.DataStructures.Trees
-{
- ///
- /// A base class for Binary Search Trees that store a single value in each node.
- ///
- ///
- //[Serializable]
- public abstract class BinarySearchTreeBase : ISearchTree
- {
- #region Globals
-
- internal const string alreadyContainedInTheTree = "The item is already contained in the tree.";
- private BinaryTree _tree;
- private readonly IComparer _comparer;
-
- #endregion
-
- #region Delegates
-
- ///
- /// A custom comparison between some search value and the type of item that is kept in the tree.
- ///
- /// The type of the search.
- protected delegate int CustomComparison(TSearch value, T item);
-
- #endregion
-
- #region Construction
-
- ///
- /// Initializes a new instance of the class.
- ///
- protected BinarySearchTreeBase()
- {
- _comparer = Comparer.Default;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The comparer to use when comparing items.
- /// is a null reference (Nothing in Visual Basic).
- protected BinarySearchTreeBase(IComparer comparer)
- {
- Guard.ArgumentNotNull(comparer, "comparer");
- _comparer = comparer;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The comparison.
- protected BinarySearchTreeBase(Comparison comparison)
- {
- Guard.ArgumentNotNull(comparison, "comparison");
- _comparer = new ComparisonComparer(comparison);
- }
-
- #endregion
-
- #region Public Members
-
- ///
- /// Gets the comparer.
- ///
- /// The comparer.
- public IComparer Comparer => _comparer;
-
- #endregion
-
- #region Protected Members
-
- ///
- /// Finds the node containing the specified data key.
- ///
- /// The item.
- ///
- /// The node with the specified key if found. If the key is not in the tree, this method returns null.
- ///
- [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
- protected virtual BinaryTree FindNode(T item)
- {
- if (_tree == null)
- {
- return null;
- }
-
- var currentNode = _tree;
-
- while (currentNode != null)
- {
- var nodeResult = _comparer.Compare(item, currentNode.Data);
-
- if (nodeResult == 0)
- {
- return currentNode;
- }
-
- currentNode = nodeResult < 0 ? currentNode.Left : currentNode.Right;
- }
-
- return null;
- }
-
- ///
- /// Finds the node that matches the custom delegate.
- ///
- /// The type of the search.
- /// The value.
- /// The custom comparison.
- /// The item if found, else null.
- protected virtual BinaryTree FindNode(TSearch value, CustomComparison customComparison)
- {
- if (_tree == null)
- {
- return null;
- }
-
- var currentNode = _tree;
-
- while (currentNode != null)
- {
- var nodeResult = customComparison(value, currentNode.Data);
-
- if (nodeResult == 0)
- {
- return currentNode;
- }
-
- currentNode = nodeResult < 0 ? currentNode.Left : currentNode.Right;
- }
-
- return null;
- }
-
- ///
- /// Removes the item from the tree.
- ///
- /// The item to remove.
- /// An indication of whether the item has been removed from the tree.
- protected abstract bool RemoveItem(T item);
-
- ///
- /// Adds the item.
- ///
- /// The item.
- protected abstract void AddItem(T item);
-
-
- ///
- /// Find the maximum node.
- ///
- /// The maximum node.
- [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
- protected BinaryTree FindMaximumNode()
- {
- #region Debug
-
- Debug.Assert(_tree != null);
-
- #endregion
-
- return FindMaximumNode(_tree);
- }
-
-
- ///
- /// Find the minimum node.
- ///
- /// The minimum node.
- [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
- protected BinaryTree FindMinimumNode()
- {
- #region Debug
-
- Debug.Assert(_tree != null);
-
- #endregion
-
- return FindMinimumNode(_tree);
- }
-
- ///
- /// Finds the maximum node.
- ///
- /// The start node.
- /// The maximum node below this node.
- [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")]
- protected static BinaryTree FindMaximumNode(BinaryTree startNode)
- {
- #region Asserts
-
- Debug.Assert(startNode != null);
-
- #endregion
-
- var searchNode = startNode;
-
- while (searchNode.Right != null)
- {
- searchNode = searchNode.Right;
- }
-
- return searchNode;
- }
-
-
- ///
- /// Finds the minimum node.
- ///
- /// The start node.
- /// The minimum node below this node.
- [SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")]
- protected static BinaryTree FindMinimumNode(BinaryTree startNode)
- {
- #region Asserts
-
- Debug.Assert(startNode != null);
-
- #endregion
-
- var searchNode = startNode;
-
- while (searchNode.Left != null)
- {
- searchNode = searchNode.Left;
- }
-
- return searchNode;
- }
-
- ///
- /// Gets or sets the for this .
- ///
- [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
- [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
- protected BinaryTree Tree
- {
- get
- {
- return _tree;
- }
- set
- {
- _tree = value;
- }
- }
-
- #endregion
-
- #region Private Members
-
- ///
- /// Visits the node in an in-order fashion.
- ///
- /// The node.
- /// The visitor.
- private static void VisitNode(BinaryTree node, OrderedVisitor visitor)
- {
- if (node != null)
- {
- var pair = node.Data;
-
- visitor.VisitPreOrder(pair);
-
- VisitNode(node.Left, visitor);
-
- visitor.VisitInOrder(pair);
-
- VisitNode(node.Right, visitor);
-
- visitor.VisitPostOrder(pair);
- }
- }
-
- #endregion
-
- #region ISearchTree Members
-
- ///
- ///
- ///
- ///
- ///
- public virtual T Minimum
- {
- get
- {
- #region Validation
-
- ValidateEmpty();
-
- #endregion
-
- return FindMinimumNode().Data;
- }
- }
-
- private void ValidateEmpty()
- {
- if (Count == 0)
- {
- throw new InvalidOperationException("The search tree is empty.");
- }
- }
-
- ///
- ///
- ///
- ///
- ///
- public virtual T Maximum
- {
- get
- {
- ValidateEmpty();
-
- return FindMaximumNode().Data;
- }
- } ///
- [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
- public void DepthFirstTraversal(OrderedVisitor visitor)
- {
- Guard.ArgumentNotNull(visitor, "visitor");
-
- VisitNode(_tree, visitor);
- }
-
- ///
- [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
- [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
- public IEnumerator GetOrderedEnumerator()
- {
- if (_tree != null)
- {
- var trackingVisitor = new TrackingVisitor();
- var inOrderVisitor = new InOrderVisitor(trackingVisitor);
-
- _tree.DepthFirstTraversal(inOrderVisitor);
-
- var trackingList = trackingVisitor.TrackingList;
-
- for (var i = 0; i < trackingList.Count; i++)
- {
- yield return trackingList[i];
- }
- }
- }
-
- ///
- ///
- ///
- ///
- ///
- public bool IsEmpty => Count == 0;
-
- ///
- public bool Remove(T item)
- {
- var itemRemoved = RemoveItem(item);
-
- if (itemRemoved)
- {
- Count--;
- }
-
- return itemRemoved;
- }
-
- ///
- ///
- ///
- ///
- ///
- public void Clear()
- {
- ClearItems();
- }
-
- ///
- /// Clears all the objects in this instance.
- ///
- ///
- /// Notes to Inheritors:
- /// Derived classes can override this method to change the behavior of the method.
- ///
- protected virtual void ClearItems()
- {
- _tree = null;
- Count = 0;
- }
-
- ///
- ///
- ///
- ///
- ///
- public int Count { get; private set; }
-
- #endregion
-
- #region IEnumerable Members
-
- ///
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- ///
- /// Returns an enumerator that iterates through the collection.
- ///
- ///
- /// A that can be used to iterate through the collection.
- ///
- ///
- ///
- ///
- ///
- [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
- public IEnumerator GetEnumerator()
- {
- if (_tree != null)
- {
- var stack = new Stack>();
-
- stack.Push(_tree);
-
- while (stack.Count > 0)
- {
- var binaryTree = stack.Pop();
-
- yield return binaryTree.Data;
-
- if (binaryTree.Left != null)
- {
- stack.Push(binaryTree.Left);
- }
-
- if (binaryTree.Right != null)
- {
- stack.Push(binaryTree.Right);
- }
- }
- }
- }
-
- #endregion
-
-
- #region ICollection Members
-
- ///
- ///
- ///
- ///
- ///
- public void Add(T item)
- {
- AddItem(item);
- Count++;
- }
-
- ///
- ///
- ///
- ///
- ///
- public virtual bool Contains(T item)
- {
- var node = FindNode(item);
- return node != null;
- }
-
-
- ///
- ///
- ///
- ///
- ///
- public void CopyTo(T[] array, int arrayIndex)
- {
- #region Validation
-
- Guard.ArgumentNotNull(array, "array");
-
- if ((array.Length - arrayIndex) < Count)
- {
- throw new ArgumentException(Constants.NotEnoughSpaceInTheTargetArray, "array");
- }
-
- #endregion
-
- foreach (var association in _tree)
- {
- array[arrayIndex++] = association;
- }
- }
- ///
- ///
- ///
- ///
- ///
- public bool IsReadOnly => false;
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/src/NGenerics/DataStructures/Trees/BinaryTree.cs b/src/NGenerics/DataStructures/Trees/BinaryTree.cs
deleted file mode 100644
index 6f3f953f97..0000000000
--- a/src/NGenerics/DataStructures/Trees/BinaryTree.cs
+++ /dev/null
@@ -1,674 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using NGenerics.Patterns.Visitor;
-using NGenerics.Util;
-using System.Diagnostics.CodeAnalysis;
-
-namespace NGenerics.DataStructures.Trees
-{
- ///
- /// An implementation of a Binary Tree data structure.
- ///
- /// The type of elements in the .
- //[Serializable]
- [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
- public class BinaryTree : ICollection, ITree
- {
- #region Globals
-
- private BinaryTree _leftSubtree;
- private BinaryTree _rightSubtree;
- private T _data;
-
- #endregion
-
- #region Construction
-
- /// The data contained in this node.
- public BinaryTree(T data) : this(data, null, null) { }
-
- /// The data.
- /// The data of the left subtree.
- /// The data of the right subtree.
- public BinaryTree(T data, T left, T right) : this(data, new BinaryTree(left), new BinaryTree(right)) { }
-
- /// The data contained in this node.
- /// The left subtree.
- /// The right subtree.
- public BinaryTree(T data, BinaryTree left, BinaryTree right)
- : this(data, left, right, true)
- {
- }
-
-
-
- /// The data contained in this node.
- /// The left subtree.
- /// The right subtree.
- /// to validate ; otherwise .
- internal BinaryTree(T data, BinaryTree left, BinaryTree right, bool validateData)
- {
- #region Validation
-
- //TODO: probably not the most efficient way of doing this but SplayTree needs to use a BinaryTree with null data.
- if (validateData)
- {
- Guard.ArgumentNotNull(data, "data");
- }
-
- #endregion
-
- _leftSubtree = left;
-
- if (left != null)
- {
- left.Parent = this;
- }
-
- _rightSubtree = right;
-
- if (right != null)
- {
- right.Parent = this;
- }
-
- _data = data;
- }
-
-
-
- #endregion
-
- #region ICollection Members
-
- ///
- public bool IsEmpty => Count == 0;
-
- ///
- public bool IsFull => (_leftSubtree != null) && (_rightSubtree != null);
-
- ///
- public bool Contains(T item)
- {
- foreach (var thisItem in this)
- {
- if (item.Equals(thisItem))
- {
- return true;
- }
- }
-
- return false;
- }
-
- ///
- public void CopyTo(T[] array, int arrayIndex)
- {
- Guard.ArgumentNotNull(array, "array");
-
- foreach (var item in this)
- {
- #region Validation
-
- if (arrayIndex >= array.Length)
- {
- throw new ArgumentException(Constants.NotEnoughSpaceInTheTargetArray, "array");
- }
-
- #endregion
-
- array[arrayIndex++] = item;
- }
- }
-
- ///
- public int Count
- {
- get
- {
- var count = 0;
-
- if (_leftSubtree != null)
- {
- count++;
- }
-
- if (_rightSubtree != null)
- {
- count++;
- }
-
- return count;
- }
- }
-
- ///
- public void Add(T item)
- {
- AddItem(new BinaryTree(item));
- }
-
- ///
- public bool Remove(T item)
- {
- if (_leftSubtree != null)
- {
- if (_leftSubtree._data.Equals(item))
- {
- RemoveLeft();
- return true;
- }
- }
-
- if (_rightSubtree != null)
- {
- if (_rightSubtree._data.Equals(item))
- {
- RemoveRight();
- return true;
- }
- }
-
- return false;
- }
-
- ///
- /// Removes the specified child.
- ///
- /// The child.
- /// A value indicating whether the child was found (and removed) from this tree.
- public bool Remove(BinaryTree child)
- {
- if (_leftSubtree != null)
- {
- if (_leftSubtree == child)
- {
- RemoveLeft();
- return true;
- }
- }
-
- if (_rightSubtree != null)
- {
- if (_rightSubtree == child)
- {
- RemoveRight();
- return true;
- }
- }
-
- return false;
- }
-
- ///
- /// Returns an enumerator that iterates through the collection.
- ///
- ///
- /// A that can be used to iterate through the collection.
- ///
- public IEnumerator GetEnumerator()
- {
- var stack = new Stack>();
-
- stack.Push(this);
-
- while (stack.Count > 0)
- {
- var tree = stack.Pop();
-
- yield return tree.Data;
-
- if (tree._leftSubtree != null)
- {
- stack.Push(tree._leftSubtree);
- }
-
- if (tree._rightSubtree != null)
- {
- stack.Push(tree._rightSubtree);
- }
- }
- }
-
- ///
- public virtual void Clear()
- {
- if (_leftSubtree != null)
- {
- _leftSubtree.Parent = null;
- _leftSubtree = null;
- }
-
- if (_rightSubtree != null)
- {
- _rightSubtree.Parent = null;
- _rightSubtree = null;
- }
- }
-
- #endregion
-
- #region ITree Members
-
- ///
- void ITree.Add(ITree child)
- {
- AddItem((BinaryTree)child);
- }
-
- ///
- ITree ITree.GetChild(int index)
- {
- return GetChild(index);
- }
-
- ///
- bool ITree.Remove(ITree child)
- {
- return Remove((BinaryTree)child);
- }
-
- ///
- ITree ITree.FindNode(Predicate condition)
- {
- return FindNode(condition);
- }
-
- ///
- ITree ITree.Parent => Parent;
-
- #endregion
-
- #region Public Members
-
- ///
- /// Gets the parent of the current node..
- ///
- /// The parent of the current node.
- public BinaryTree Parent { get; private set; }
-
- ///
- /// Finds the node with the specified condition. If a node is not found matching
- /// the specified condition, null is returned.
- ///
- /// The condition to test.
- /// The first node that matches the condition supplied. If a node is not found, null is returned.
- /// is a null reference (Nothing in Visual Basic).
- public BinaryTree FindNode(Predicate condition)
- {
- Guard.ArgumentNotNull(condition, "condition");
-
- if (condition(Data))
- {
- return this;
- }
-
- if (_leftSubtree != null)
- {
- var ret = _leftSubtree.FindNode(condition);
-
- if (ret != null)
- {
- return ret;
- }
- }
-
- if (_rightSubtree != null)
- {
- var ret = _rightSubtree.FindNode(condition);
-
- if (ret != null)
- {
- return ret;
- }
- }
-
- return null;
- }
-
- ///
- /// Gets or sets the left subtree.
- ///
- /// The left subtree.
- [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
- public virtual BinaryTree Left
- {
- get
- {
- return _leftSubtree;
- }
- set
- {
- if (_leftSubtree != null)
- {
- RemoveLeft();
- }
-
- if (value != null)
- {
- if (value.Parent != null)
- {
- value.Parent.Remove(value);
- }
-
- value.Parent = this;
- }
-
- _leftSubtree = value;
- }
- }
-
- ///
- /// Gets or sets the right subtree.
- ///
- /// The right subtree.
- [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
- public virtual BinaryTree Right
- {
- get
- {
- return _rightSubtree;
- }
- set
- {
- if (_rightSubtree != null)
- {
- RemoveRight();
- }
-
- if (value != null)
- {
- if (value.Parent != null)
- {
- value.Parent.Remove(value);
- }
-
- value.Parent = this;
- }
-
- _rightSubtree = value;
- }
- }
-
- ///
- public virtual T Data
- {
- get
- {
- return _data;
- }
- set
- {
- #region Validation
-
- Guard.ArgumentNotNull(value, "data");
-
- #endregion
-
- _data = value;
- }
- }
-
- ///
- public int Degree => Count;
-
- ///
- /// Gets the child at the specified index.
- ///
- /// The index of the child in question.
- /// The child at the specified index.
- /// does not equal 0 or 1.
- public BinaryTree GetChild(int index)
- {
- switch (index)
- {
- case 0:
- return _leftSubtree;
- case 1:
- return _rightSubtree;
- default:
- throw new ArgumentOutOfRangeException("index");
- }
- }
- ///
- public virtual int Height
- {
- get
- {
- if (Degree == 0)
- {
- return 0;
- }
-
- return 1 + FindMaximumChildHeight();
- }
- }
-
-
- ///
- /// Performs a depth first traversal on this tree with the specified visitor.
- ///
- /// The ordered visitor.
- /// is a null reference (Nothing in Visual Basic).
- public virtual void DepthFirstTraversal(OrderedVisitor orderedVisitor)
- {
- Guard.ArgumentNotNull(orderedVisitor, "orderedVisitor");
-
- if (orderedVisitor.HasCompleted)
- {
- return;
- }
-
- // Preorder visit
- orderedVisitor.VisitPreOrder(Data);
-
- if (_leftSubtree != null)
- {
- _leftSubtree.DepthFirstTraversal(orderedVisitor);
- }
-
- // In-order visit
- orderedVisitor.VisitInOrder(_data);
-
- if (_rightSubtree != null)
- {
- _rightSubtree.DepthFirstTraversal(orderedVisitor);
- }
-
- // PostOrder visit
- orderedVisitor.VisitPostOrder(Data);
- }
-
- ///
- /// Performs a breadth first traversal on this tree with the specified visitor.
- ///
- /// The visitor.
- /// is a null reference (Nothing in Visual Basic).
- public virtual void BreadthFirstTraversal(IVisitor visitor)
- {
- Guard.ArgumentNotNull(visitor, "visitor");
-
- var queue = new Queue>();
-
- queue.Enqueue(this);
-
- while (queue.Count > 0)
- {
- if (visitor.HasCompleted)
- {
- break;
- }
-
- var binaryTree = queue.Dequeue();
- visitor.Visit(binaryTree.Data);
-
- for (var i = 0; i < binaryTree.Degree; i++)
- {
- var child = binaryTree.GetChild(i);
-
- if (child != null)
- {
- queue.Enqueue(child);
- }
- }
- }
- }
-
-
- ///
- public virtual bool IsLeafNode => Degree == 0;
-
- ///
- /// Removes the left child.
- ///
- public virtual void RemoveLeft()
- {
- if (_leftSubtree != null)
- {
- _leftSubtree.Parent = null;
- _leftSubtree = null;
- }
- }
-
- ///
- /// Removes the left child.
- ///
- public virtual void RemoveRight()
- {
- if (_rightSubtree != null)
- {
- _rightSubtree.Parent = null;
- _rightSubtree = null;
- }
- }
-
- ///
- /// Adds an item to the .
- ///
- /// The subtree.
- /// The is read-only.
- /// The is full.
- /// is null (Nothing in Visual Basic).
- public void Add(BinaryTree subtree)
- {
- Guard.ArgumentNotNull(subtree, "subtree");
-
- AddItem(subtree);
- }
-
- ///
- /// Adds an item to the .
- ///
- /// The subtree.
- ///
- /// Notes to Inheritors:
- /// Derived classes can override this method to change the behavior of the method.
- ///
- protected virtual void AddItem(BinaryTree subtree)
- {
- if (_leftSubtree == null)
- {
- if (subtree.Parent != null)
- {
- subtree.Parent.Remove(subtree);
- }
-
- _leftSubtree = subtree;
- subtree.Parent = this;
- }
- else if (_rightSubtree == null)
- {
- if (subtree.Parent != null)
- {
- subtree.Parent.Remove(subtree);
- }
-
- _rightSubtree = subtree;
- subtree.Parent = this;
- }
- else
- {
- throw new InvalidOperationException("This binary tree is full.");
- }
- }
-
-
- #endregion
-
- #region Private Members
-
- ///
- /// Finds the maximum height between the child nodes.
- ///
- /// The maximum height of the tree between all paths from this node and all leaf nodes.
- protected virtual int FindMaximumChildHeight()
- {
- var leftHeight = 0;
- var rightHeight = 0;
-
- if (_leftSubtree != null)
- {
- leftHeight = _leftSubtree.Height;
- }
-
- if (_rightSubtree != null)
- {
- rightHeight = _rightSubtree.Height;
- }
-
- return leftHeight > rightHeight ? leftHeight : rightHeight;
- }
-
- #endregion
-
- #region Operator Overloads
-
- ///
- /// Gets the at the specified index.
- ///
- public BinaryTree this[int index] => GetChild(index);
-
- #endregion
-
- #region ICollection Members
-
- ///
- public bool IsReadOnly => false;
-
- #endregion
-
- #region IEnumerable Members
-
- ///
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- #endregion
-
- #region Object Members
-
- ///
- public override string ToString()
- {
- return _data.ToString();
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/src/NGenerics/DataStructures/Trees/ISearchTree.cs b/src/NGenerics/DataStructures/Trees/ISearchTree.cs
deleted file mode 100644
index 08cc31ddfa..0000000000
--- a/src/NGenerics/DataStructures/Trees/ISearchTree.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using NGenerics.Patterns.Visitor;
-
-namespace NGenerics.DataStructures.Trees
-{
- ///
- /// An interface for Search Trees that mimic a dictionary.
- ///
- /// The type of element to hold in the tree.
- [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
- public interface ISearchTree : ICollection
- {
- ///
- /// Gets the largest item in the tree.
- ///
- /// The largest item in the tree.
- /// The is empty.
- T Maximum { get; }
-
- ///
- /// Gets the smallest item in the tree.
- ///
- /// The smallest item in the tree.
- /// The is empty.
- T Minimum { get; }
-
- ///
- /// Performs a depth first traversal on the search tree.
- ///
- /// The visitor to use.
- /// is a null reference (Nothing in Visual Basic).
- ///
- ///
- ///
- ///
- [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
- void DepthFirstTraversal(OrderedVisitor visitor);
-
- ///
- /// Returns an enumerator that iterates through the collection.
- ///
- ///
- /// A that can be used to iterate through the collection.
- ///
- ///
- ///
- ///
- ///
- [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
- [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
- IEnumerator GetOrderedEnumerator();
- }
-}
diff --git a/src/NGenerics/DataStructures/Trees/ITree.cs b/src/NGenerics/DataStructures/Trees/ITree.cs
deleted file mode 100644
index 7d2f7d134a..0000000000
--- a/src/NGenerics/DataStructures/Trees/ITree.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-using System;
-
-namespace NGenerics.DataStructures.Trees
-{
- ///
- /// An interface for the tree data structure
- ///
- /// The type of elements in the tree.
- public interface ITree
- {
- ///
- /// Adds the specified child to the tree.
- ///
- /// The child to add..
- void Add(ITree child);
-
- ///
- /// Gets the data held in this node.
- ///
- /// The data.
- T Data { get; }
-
- ///
- /// Gets the degree of this node.
- ///
- /// The degree of this node.
- int Degree { get; }
-
- ///
- /// Gets the child at the specified index.
- ///
- /// The index.
- /// The child at the specified index.
- ITree GetChild(int index);
-
- ///
- /// Gets the height of this tree.
- ///
- /// The height of this tree.
- int Height { get; }
-
- ///
- /// Gets a value indicating whether this instance is leaf node.
- ///
- ///
- /// true if this instance is leaf node; otherwise, false.
- ///
- bool IsLeafNode { get; }
-
- ///
- /// Removes the specified child.
- ///
- /// The child.
- /// An indication of whether the child was found (and removed) from this tree.
- bool Remove(ITree child);
-
- ///
- /// Finds the node for which the given predicate holds true.
- ///
- /// The condition to test on the data item.
- /// The fist node that matches the condition if found, otherwise null.
- ITree FindNode(Predicate condition);
-
- ///
- /// Gets the parent of the current node.
- ///
- /// The parent of the current node.
- ITree Parent { get; }
- }
-}
diff --git a/src/NGenerics/DataStructures/Trees/NodeColor.cs b/src/NGenerics/DataStructures/Trees/NodeColor.cs
deleted file mode 100644
index 839c1fbe0e..0000000000
--- a/src/NGenerics/DataStructures/Trees/NodeColor.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-
-namespace NGenerics.DataStructures.Trees
-{
- internal enum NodeColor
- {
- Red = 0,
- Black = 1
- }
-}
\ No newline at end of file
diff --git a/src/NGenerics/DataStructures/Trees/RedBlackTree.cs b/src/NGenerics/DataStructures/Trees/RedBlackTree.cs
deleted file mode 100644
index a2c76971c5..0000000000
--- a/src/NGenerics/DataStructures/Trees/RedBlackTree.cs
+++ /dev/null
@@ -1,291 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-
-/*
- * The insertion and deletion code is based on the code found at http://eternallyconfuzzled.com/tuts/redblack.htm.
- * It's an excellent tutorial - if you want to understand Red Black trees, look there first.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-
-namespace NGenerics.DataStructures.Trees
-{
- ///
- /// An implementation of a Red-Black tree.
- ///
- /// The type of element to keep in the tree.
- [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
- //[Serializable]
- public class RedBlackTree : BinarySearchTreeBase
- {
- #region Construction
-
- ///
- public RedBlackTree()
- {
- // Do nothing - the default Comparer will be used by the base class.
- }
-
-
- ///
- public RedBlackTree(IComparer comparer)
- : base(comparer)
- {
- // Do nothing else.
- }
-
- ///
- public RedBlackTree(Comparison comparison)
- : base(comparison)
- {
- // Do nothing else.
- }
-
- #endregion
-
- #region Public Members
-
- ///
- /// Adds an element with the provided key and value to the .
- ///
- /// The item.
- protected override void AddItem(T item)
- {
- #region Validation
-
- if (Equals(item, null))
- {
- throw new ArgumentNullException("item");
- }
-
- #endregion
-
- var root = (RedBlackTreeNode)Tree;
-
- var newRoot = InsertNode(root, item);
- newRoot.Color = NodeColor.Black;
- Tree = newRoot;
- }
-
- ///
- /// Removes the element with the specified key from the .
- ///
- /// The item to remove.
- ///
- /// true if the element is successfully removed; otherwise, false. This method also returns false if key was not found in the original .
- ///
- ///
- protected override bool RemoveItem(T item)
- {
- if (Tree != null)
- {
- var startNode = new RedBlackTreeNode(default(T));
-
- var childNode = startNode;
- startNode.Right = (RedBlackTreeNode)Tree;
-
- RedBlackTreeNode parent = null;
- RedBlackTreeNode foundNode = null;
-
- var direction = true;
-
- while (childNode[direction] != null)
- {
- var lastDirection = direction;
-
- var grandParent = parent;
- parent = childNode;
- childNode = childNode[direction];
-
- var comparisonValue = Comparer.Compare(childNode.Data, item);
-
- if (comparisonValue == 0)
- {
- foundNode = childNode;
- }
-
- direction = comparisonValue < 0;
-
- if ((IsBlack(childNode)) && (IsBlack(childNode[direction])))
- {
- if (IsRed(childNode[!direction]))
- {
- parent = parent[lastDirection] = SingleRotation(childNode, direction);
- }
- else if (IsBlack(childNode[direction]))
- {
- var sibling = parent[!lastDirection];
-
- if (sibling != null)
- {
- if ((IsBlack(sibling.Left)) && (IsBlack(sibling.Right)))
- {
- parent.Color = NodeColor.Black;
- sibling.Color = NodeColor.Red;
- childNode.Color = NodeColor.Red;
- }
- else
- {
- var parentDirection = grandParent.Right == parent;
-
- if (IsRed(sibling[lastDirection]))
- {
- grandParent[parentDirection] = DoubleRotation(parent, lastDirection);
- }
- else if (IsRed(sibling[!lastDirection]))
- {
- grandParent[parentDirection] = SingleRotation(parent, lastDirection);
- }
-
- childNode.Color = grandParent[parentDirection].Color = NodeColor.Red;
- grandParent[parentDirection].Left.Color = NodeColor.Black;
- grandParent[parentDirection].Right.Color = NodeColor.Black;
- }
- }
- }
- }
- }
-
- if (foundNode != null)
- {
- foundNode.Data = childNode.Data;
- parent[parent.Right == childNode] = childNode[childNode.Left == null];
- }
-
- Tree = startNode.Right;
-
- if (Tree != null)
- {
- ((RedBlackTreeNode)Tree).Color = NodeColor.Black;
- }
-
- if (foundNode != null)
- {
- return true;
- }
- }
-
- return false;
- }
-
- #endregion
-
- #region Private Members
-
- ///
- /// Determines whether the specified node is red.
- ///
- /// The node.
- ///
- /// true if the specified node is red; otherwise, false.
- ///
- private static bool IsRed(RedBlackTreeNode node)
- {
- return (node != null) && (node.Color == NodeColor.Red);
- }
-
- ///
- /// Determines whether the specified node is black.
- ///
- /// The node.
- ///
- /// true if the specified node is black; otherwise, false.
- ///
- private static bool IsBlack(RedBlackTreeNode node)
- {
- return (node == null) || (node.Color == NodeColor.Black);
- }
-
- ///
- /// A recursive implementation of insertion of a node into the tree.
- ///
- /// The start node.
- /// The item.
- /// The node created in the insertion.
- private RedBlackTreeNode InsertNode(RedBlackTreeNode node, T item)
- {
- if (node == null)
- {
- node = new RedBlackTreeNode(item);
- }
- else if (Comparer.Compare(item, node.Data) != 0)
- {
- var direction = Comparer.Compare(node.Data, item) < 0;
-
- node[direction] = InsertNode(node[direction], item);
-
- if (IsRed(node[direction]))
- {
- if (IsRed(node[!direction]))
- {
- node.Color = NodeColor.Red;
- node.Left.Color = NodeColor.Black;
- node.Right.Color = NodeColor.Black;
- }
- else
- {
- if (IsRed(node[direction][direction]))
- {
- node = SingleRotation(node, !direction);
- }
- else if (IsRed(node[direction][!direction]))
- {
- node = DoubleRotation(node, !direction);
- }
- }
- }
- }
- else
- {
- throw new ArgumentException(alreadyContainedInTheTree);
- }
-
- return node;
- }
-
- ///
- /// Perform a single rotation on the node provided..
- ///
- /// The node on which to focus the rotation.
- /// The direction of the rotation. If direction is equal to true, a right rotation is performed. Other wise, a left rotation.
- /// The new root of the cluster.
- private static RedBlackTreeNode SingleRotation(RedBlackTreeNode node, bool direction)
- {
- var childSibling = node[!direction];
-
- node[!direction] = childSibling[direction];
- childSibling[direction] = node;
-
- node.Color = NodeColor.Red;
- childSibling.Color = NodeColor.Black;
-
- return childSibling;
- }
-
- ///
- /// Perform a double rotation on the node provided..
- ///
- /// The node on which to focus the rotation.
- /// The direction of the rotation. If direction is equal to true, a right rotation is performed. Other wise, a left rotation.
- /// The new root of the cluster.
- private static RedBlackTreeNode DoubleRotation(RedBlackTreeNode node, bool direction)
- {
- node[!direction] = SingleRotation(node[!direction], !direction);
- return SingleRotation(node, direction);
- }
-
- #endregion
- }
-}
diff --git a/src/NGenerics/DataStructures/Trees/RedBlackTreeDictionary.cs b/src/NGenerics/DataStructures/Trees/RedBlackTreeDictionary.cs
deleted file mode 100644
index 812fb0fa8b..0000000000
--- a/src/NGenerics/DataStructures/Trees/RedBlackTreeDictionary.cs
+++ /dev/null
@@ -1,251 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-
-/*
- * The insertion and deletion code is based on the code found at http://eternallyconfuzzled.com/tuts/redblack.htm.
- * It's an excellent tutorial - if you want to understand Red Black trees, look there first.
- */
-
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics.CodeAnalysis;
-using NGenerics.Comparers;
-using NGenerics.Patterns.Visitor;
-
-namespace NGenerics.DataStructures.Trees
-{
- ///
- /// An implementation of a Red-Black tree.
- ///
- /// The type of the keys in the .
- /// The type of the values in the .
- [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
-#if (!SILVERLIGHT && !WINDOWSPHONE)
- //[Serializable]
-#endif
- public class RedBlackTree : RedBlackTree>, IDictionary // BinarySearchTreeBase
- {
- #region Construction
- ///
- public RedBlackTree() : base(new KeyValuePairComparer())
- {
- // Do nothing - the default Comparer will be used by the base class.
- }
-
-
- ///
- public RedBlackTree(IComparer comparer)
- : base(new KeyValuePairComparer(comparer))
- {
- // Do nothing else.
- }
-
- ///
- public RedBlackTree(Comparison comparison)
- : base(new KeyValuePairComparer(comparison))
- {
- // Do nothing else.
- }
-
- #endregion
-
- #region Private Members
-
- private RedBlackTreeNode> FindNode(TKey key)
- {
- return base.FindNode(new KeyValuePair(key, default(TValue))) as RedBlackTreeNode>;
- }
-
- private bool Contains(KeyValuePair item, bool checkValue)
- {
- var node = FindNode(item);
-
- if ((node != null) && !checkValue)
- {
- return true;
- }
-
- return node != null && Equals(item.Value, node.Data.Value);
- }
-
- #endregion
-
- #region IDictionary Members
-
- ///
- /// Removes the element with the specified key from the .
- ///
- /// The key of the element to remove.
- ///
- /// true if the element is successfully removed; otherwise, false. This method also returns false if was not found in the original .
- ///
- ///
- /// is null.
- ///
- ///
- /// The is read-only.
- ///
- public bool Remove(TKey key)
- {
- return Remove(new KeyValuePair(key, default(TValue)));
- }
-
- ///
- /// Adds an element with the provided key and value to the .
- ///
- /// The object to use as the key of the element to add.
- /// The object to use as the value of the element to add.
- ///
- /// is null.
- ///
- ///
- /// An element with the same key already exists in the .
- ///
- ///
- /// The is read-only.
- ///
- public void Add(TKey key, TValue value)
- {
- if (Equals(key, null))
- {
- throw new ArgumentNullException("key");
- }
-
- Add(new KeyValuePair(key, value));
- }
-
- ///
- /// Determines whether the contains an element with the specified key.
- ///
- /// The key to locate in the .
- ///
- /// true if the contains an element with the key; otherwise, false.
- ///
- ///
- /// is null.
- ///
- public bool ContainsKey(TKey key)
- {
- return Contains(new KeyValuePair(key, default(TValue)), false);
- }
-
- ///
- /// Gets an containing the keys of the .
- ///
- ///
- ///
- ///
- ///
- ///
- public ICollection Keys
- {
- get
- {
- // Get the keys in sorted order
- var visitor = new KeyTrackingVisitor();
- var inOrderVisitor = new InOrderVisitor>(visitor);
- DepthFirstTraversal(inOrderVisitor);
- return new ReadOnlyCollection(visitor.TrackingList);
- }
- }
-
-
- ///
- ///
- ///
- ///
- ///
- public bool TryGetValue(TKey key, out TValue value)
- {
- var node = FindNode(new KeyValuePair(key, default(TValue)));
-
- if (node == null)
- {
- value = default(TValue);
- return false;
- }
-
- value = node.Data.Value;
- return true;
- }
-
- ///
- /// Gets an containing the values in the .
- ///
- ///
- ///
- ///
- ///
- ///
- public ICollection Values
- {
- get
- {
- var visitor = new ValueTrackingVisitor();
- var inOrderVisitor = new InOrderVisitor>(visitor);
-
- DepthFirstTraversal(inOrderVisitor);
-
- return new ReadOnlyCollection(visitor.TrackingList);
- }
- }
-
-
- ///
- /// Gets or sets the value with the specified key.
- ///
- /// The key of the item to set or get.
- public TValue this[TKey key]
- {
- get
- {
- var node = FindNode(key);
-
- if (node == null)
- {
- throw new KeyNotFoundException("key");
- }
-
- return node.Data.Value;
- }
- set
- {
- var node = FindNode(key);
-
- if (node == null)
- {
- throw new KeyNotFoundException("key");
- }
-
- node.Data = new KeyValuePair(key, value);
- }
- }
-
- #endregion
-
- #region ICollection> Members
-
- ///
- ///
- ///
- ///
- ///
- public override bool Contains(KeyValuePair item)
- {
- return Contains(item, true);
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/src/NGenerics/DataStructures/Trees/RedBlackTreeList.cs b/src/NGenerics/DataStructures/Trees/RedBlackTreeList.cs
deleted file mode 100644
index 7a4c64168d..0000000000
--- a/src/NGenerics/DataStructures/Trees/RedBlackTreeList.cs
+++ /dev/null
@@ -1,232 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-
-namespace NGenerics.DataStructures.Trees
-{
- ///
- /// A RedBlack Tree list variant. Equivalent to where TValue is a .
- ///
- /// The type of the key.
- /// The type of the value.
- //[Serializable]
- internal class RedBlackTreeList : RedBlackTree>
- {
- #region Delegates
-
- private delegate bool NodeAction(TKey key, LinkedList values);
-
- #endregion
-
- #region Construction
-
- ///
- /// Initializes a new instance of the class.
- ///
- ///
- public RedBlackTreeList()
- {
- // Do nothing else.
- }
-
- ///
- public RedBlackTreeList(IComparer comparer)
- : base(comparer)
- {
- // Do nothing else.
- }
-
- ///
- public RedBlackTreeList(Comparison comparison)
- : base(comparison)
- {
- // Do nothing else.
- }
-
- #endregion
-
- #region Public Members
-
- ///
- /// Determines whether the specified value contains value.
- ///
- /// The value.
- ///
- /// true if the specified value contains value; otherwise, false.
- ///
- public bool ContainsValue(TValue value)
- {
- return TraverseItems((key, list) => list.Contains(value));
- }
-
- ///
- /// Gets the value enumerator.
- ///
- /// An enumerator to enumerate through the values contained in this instance.
- public IEnumerator GetValueEnumerator()
- {
- var stack = new Stack>>>();
-
- if (Tree != null)
- {
- stack.Push(Tree);
- }
-
- while (stack.Count > 0)
- {
- var currentNode = stack.Pop();
-
- var list = currentNode.Data.Value;
-
- foreach (var item in list)
- {
- yield return item;
- }
-
- if (currentNode.Left != null)
- {
- stack.Push(currentNode.Left);
- }
-
- if (currentNode.Right != null)
- {
- stack.Push(currentNode.Right);
- }
- }
- }
-
- ///
- /// Returns an enumerator that iterates through the collection.
- ///
- ///
- /// A that can be used to iterate through the collection.
- ///
- [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
- [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
- public IEnumerator> GetKeyEnumerator()
- {
- var stack = new Stack>>>();
-
- if (Tree != null)
- {
- stack.Push(Tree);
- }
-
- while (stack.Count > 0)
- {
- var currentNode = stack.Pop();
-
- var list = currentNode.Data.Value;
-
- foreach (var item in list)
- {
- yield return new KeyValuePair(currentNode.Data.Key, item);
- }
-
- if (currentNode.Left != null)
- {
- stack.Push(currentNode.Left);
- }
-
- if (currentNode.Right != null)
- {
- stack.Push(currentNode.Right);
- }
- }
- }
-
- ///
- /// Removes the specified value.
- ///
- /// The value.
- /// The key under which the item was found.
- /// A value indicating whether the item was found or not.
- public bool Remove(TValue value, out TKey key)
- {
- var foundKey = default(TKey);
-
- var ret = TraverseItems(
- delegate (TKey itemKey, LinkedList list)
- {
- if (list.Remove(value))
- {
- if (list.Count == 0)
- {
- Remove(itemKey);
- }
-
- foundKey = itemKey;
- return true;
- }
-
- return false;
- }
- );
-
- key = foundKey;
- return ret;
- }
-
- #endregion
-
- #region Private Members
-
- ///
- /// Traverses the items.
- ///
- /// A predicate that performs an action on the list, and indicates whether the enumeration of items should stop or not.
- /// An indication of whether the enumeration was stopped prematurely.
- private bool TraverseItems(NodeAction shouldStop)
- {
- #region Validation
-
- Debug.Assert(shouldStop != null);
-
- #endregion
-
- var stack = new Stack>>>();
-
- if (Tree != null)
- {
- stack.Push(Tree);
- }
-
- while (stack.Count > 0)
- {
- var currentNode = stack.Pop();
-
- if (shouldStop(currentNode.Data.Key, currentNode.Data.Value))
- {
- return true;
- }
-
- if (currentNode.Left != null)
- {
- stack.Push(currentNode.Left);
- }
-
- if (currentNode.Right != null)
- {
- stack.Push(currentNode.Right);
- }
- }
-
- return false;
- }
-
- #endregion
- }
-}
diff --git a/src/NGenerics/DataStructures/Trees/RedBlackTreeNode.cs b/src/NGenerics/DataStructures/Trees/RedBlackTreeNode.cs
deleted file mode 100644
index 02d6cf837a..0000000000
--- a/src/NGenerics/DataStructures/Trees/RedBlackTreeNode.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-
-
-using System;
-using System.Diagnostics.CodeAnalysis;
-
-namespace NGenerics.DataStructures.Trees
-{
- ///
- /// A container class, used for the RedBlackTree.
- ///
- /// The type of element.
- //[Serializable]
- [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
- internal class RedBlackTreeNode : BinaryTree
- {
- #region Construction
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The data contained in this node.
- internal RedBlackTreeNode(T data)
- : base(data)
- {
- Color = NodeColor.Red;
- }
-
- #endregion
-
- #region Properties
-
- ///
- /// Gets or sets the color of the current node.
- ///
- /// The color of the node.
- internal NodeColor Color { get; set; }
-
- ///
- /// Gets or sets the with the specified direction.
- ///
- ///
- internal RedBlackTreeNode this[bool direction]
- {
- get
- {
- return direction ? Right : Left;
- }
- set
- {
- if (direction)
- {
- Right = value;
- }
- else
- {
- Left = value;
- }
- }
- }
-
- ///
- /// Gets or sets the left subtree.
- ///
- /// The left subtree.
- internal new RedBlackTreeNode Left
- {
- get
- {
- return (RedBlackTreeNode)base.Left;
- }
- set
- {
- base.Left = value;
- }
- }
-
- ///
- /// Gets or sets the right subtree.
- ///
- /// The right subtree.
- internal new RedBlackTreeNode Right
- {
- get
- {
- return (RedBlackTreeNode)base.Right;
- }
- set
- {
- base.Right = value;
- }
- }
-
- #endregion
- }
-}
diff --git a/src/NGenerics/NGenerics.csproj b/src/NGenerics/NGenerics.csproj
deleted file mode 100644
index beba06a3c5..0000000000
--- a/src/NGenerics/NGenerics.csproj
+++ /dev/null
@@ -1,76 +0,0 @@
-
-
-
-
- 11.0
- Debug
- AnyCPU
- {415E048E-4611-4815-9CF2-D774E29079AC}
- Library
- Properties
- NGenerics
- NGenerics
- en-US
- 512
- {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- Profile7
- v4.5
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/NGenerics/Patterns/Visitor/IVisitor.cs b/src/NGenerics/Patterns/Visitor/IVisitor.cs
deleted file mode 100644
index acaf2ff110..0000000000
--- a/src/NGenerics/Patterns/Visitor/IVisitor.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-
-namespace NGenerics.Patterns.Visitor
-{
- ///
- /// Provides an interface for visitors.
- ///
- /// The type of objects to be visited.
- public interface IVisitor
- {
- ///
- /// Gets a value indicating whether this instance is done performing it's work..
- ///
- /// true if this instance is done; otherwise, false.
- bool HasCompleted { get; }
-
- ///
- /// Visits the specified object.
- ///
- /// The object to visit.
- void Visit(T obj);
- }
-}
\ No newline at end of file
diff --git a/src/NGenerics/Patterns/Visitor/InOrderVisitor.cs b/src/NGenerics/Patterns/Visitor/InOrderVisitor.cs
deleted file mode 100644
index de65c9cd92..0000000000
--- a/src/NGenerics/Patterns/Visitor/InOrderVisitor.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-
-namespace NGenerics.Patterns.Visitor
-{
- ///
- /// An in order implementation of the class.
- ///
- /// The type of objects to be visited.
- public sealed class InOrderVisitor : OrderedVisitor
- {
- #region Construction
-
- /// The visitor.
- public InOrderVisitor(IVisitor visitor) : base(visitor) { }
-
- #endregion
-
- #region OrderedVisitor Members
-
- ///
- /// Visits the object in post order.
- ///
- /// The obj.
- public override void VisitPostOrder(T obj)
- {
- // Do nothing.
- }
-
- ///
- /// Visits the object in pre order.
- ///
- /// The obj.
- public override void VisitPreOrder(T obj)
- {
- // Do nothing.
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/src/NGenerics/Patterns/Visitor/KeyTrackingVisitor.cs b/src/NGenerics/Patterns/Visitor/KeyTrackingVisitor.cs
deleted file mode 100644
index df17b4396c..0000000000
--- a/src/NGenerics/Patterns/Visitor/KeyTrackingVisitor.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-
-using System.Collections.Generic;
-
-namespace NGenerics.Patterns.Visitor
-{
- ///
- /// A visitor that tracks (stores) keys from KeyValuePAirs in the order they were visited.
- ///
- /// The type of the keys for the items to be visited.
- /// The type of the values for the items to be visited.
- public sealed class KeyTrackingVisitor : IVisitor>
- {
- #region Globals
-
- private readonly List _tracks;
-
- #endregion
-
- #region Construction
-
- ///
- public KeyTrackingVisitor()
- {
- _tracks = new List();
- }
-
- #endregion
-
- #region Public Members
-
- ///
- /// Gets the tracking list.
- ///
- /// The tracking list.
- public IList TrackingList => _tracks;
-
- #endregion
-
- #region IVisitor> Members
-
-
- ///
- public void Visit(KeyValuePair obj)
- {
- _tracks.Add(obj.Key);
- }
-
- ///
- public bool HasCompleted => false;
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/src/NGenerics/Patterns/Visitor/OrderedVisitor.cs b/src/NGenerics/Patterns/Visitor/OrderedVisitor.cs
deleted file mode 100644
index beeef6a8ac..0000000000
--- a/src/NGenerics/Patterns/Visitor/OrderedVisitor.cs
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-
-using System;
-using System.Diagnostics.CodeAnalysis;
-using NGenerics.Util;
-
-namespace NGenerics.Patterns.Visitor
-{
- ///
- /// A visitor that visits objects in order (PreOrder, PostOrder, or InOrder).
- /// Used primarily as a base class for Visitors specializing in a specific order type.
- ///
- /// The type of objects to be visited.
- public class OrderedVisitor : IVisitor
- {
- #region Globals
-
- private readonly IVisitor _visitorToUse;
-
- #endregion
-
- #region Construction
-
- /// The visitor to use when visiting the object.
- /// is a null reference (Nothing in Visual Basic).
- public OrderedVisitor(IVisitor visitorToUse)
- {
- Guard.ArgumentNotNull(visitorToUse, "visitorToUse");
-
- _visitorToUse = visitorToUse;
- }
-
- #endregion
-
- #region IOrderedVisitor Members
-
- ///
- /// Determines whether this visitor is done.
- ///
- ///
- ///
- /// true if this visitor is done; otherwise, false.
- ///
- public bool HasCompleted => _visitorToUse.HasCompleted;
-
- ///
- /// Visits the object in pre order.
- ///
- /// The obj.
- [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "PreOrder")]
- public virtual void VisitPreOrder(T obj)
- {
- _visitorToUse.Visit(obj);
- }
-
- ///
- /// Visits the object in post order.
- ///
- /// The obj.
- public virtual void VisitPostOrder(T obj)
- {
- _visitorToUse.Visit(obj);
- }
-
- ///
- /// Visits the object in order.
- ///
- /// The obj.
- public virtual void VisitInOrder(T obj)
- {
- _visitorToUse.Visit(obj);
- }
- ///
- public void Visit(T obj)
- {
- _visitorToUse.Visit(obj);
- }
-
- #endregion
-
- #region Public Members
-
- ///
- /// Gets the visitor to use.
- ///
- /// The visitor to use.
- public IVisitor VisitorToUse => _visitorToUse;
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/src/NGenerics/Patterns/Visitor/TrackingVisitor.cs b/src/NGenerics/Patterns/Visitor/TrackingVisitor.cs
deleted file mode 100644
index aa747df54d..0000000000
--- a/src/NGenerics/Patterns/Visitor/TrackingVisitor.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-
-using System.Collections.Generic;
-
-namespace NGenerics.Patterns.Visitor
-{
- ///
- /// A visitor that tracks (stores) objects in the order they were visited.
- /// Handy for demonstrating and testing different ordered visits implementations on
- /// data structures.
- ///
- /// The type of objects to be visited.
- public sealed class TrackingVisitor : IVisitor
- {
- #region Globals
-
- private readonly List _tracks;
-
- #endregion
-
- #region Construction
-
-
- ///
- public TrackingVisitor()
- {
- _tracks = new List();
- }
-
- #endregion
-
- #region IVisitor Members
- ///
- public void Visit(T obj)
- {
- _tracks.Add(obj);
- }
-
- ///
- public bool HasCompleted => false;
-
- #endregion
-
- #region Public Members
-
- ///
- /// Gets the tracking list.
- ///
- /// The tracking list.
- public IList TrackingList => _tracks;
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/src/NGenerics/Patterns/Visitor/ValueTrackingVisitor.cs b/src/NGenerics/Patterns/Visitor/ValueTrackingVisitor.cs
deleted file mode 100644
index e6dde77695..0000000000
--- a/src/NGenerics/Patterns/Visitor/ValueTrackingVisitor.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-/*
- Copyright 2007-2013 The NGenerics Team
- (https://github.com/ngenerics/ngenerics/wiki/Team)
-
- This program is licensed under the GNU Lesser General Public License (LGPL). You should
- have received a copy of the license along with the source code. If not, an online copy
- of the license can be found at http://www.gnu.org/copyleft/lesser.html.
-*/
-
-
-using System.Collections.Generic;
-
-namespace NGenerics.Patterns.Visitor
-{
- ///
- /// A visitor that tracks (stores) keys from KeyValuePairs in the order they were visited.
- ///
- /// The type of key of the KeyValuePair.
- /// The type of value of the KeyValuePair.
- public sealed class ValueTrackingVisitor : IVisitor>
- {
- #region Globals
-
- private readonly List _tracks;
-
- #endregion
-
- #region Construction
-
-
- ///
- public ValueTrackingVisitor()
- {
- _tracks = new List();
- }
-
- #endregion
-
- #region Public Members
-
- ///