├── TunnelVisionLabs.Collections.Trees
├── PublicAPI.Shipped.txt
├── ExceptionUtilities.cs
├── ExcludeFromCodeCoverageAttribute.cs
├── ValidationRules.cs
├── KeyOfPairComparer`2.cs
├── ComparisonComparer`1.cs
├── Immutable
│ ├── ImmutableSortedTreeSet`1+Enumerator.cs
│ ├── ImmutableTreeSet`1+Enumerator.cs
│ ├── ImmutableSortedTreeList`1+Enumerator.cs
│ ├── ImmutableTreeQueue`1+Enumerator.cs
│ ├── ImmutableTreeStack`1+Enumerator.cs
│ ├── ImmutableTreeList.cs
│ ├── ImmutableTreeDictionary`2+KeyCollection+Enumerator.cs
│ ├── ImmutableTreeDictionary`2+ValueCollection+Enumerator.cs
│ ├── ImmutableSortedTreeDictionary`2+KeyCollection+Enumerator.cs
│ ├── ImmutableSortedTreeDictionary`2+ValueCollection+Enumerator.cs
│ ├── ImmutableTreeStack.cs
│ ├── ImmutableTreeQueue.cs
│ ├── ImmutableSortedTreeList.cs
│ ├── ImmutableTreeStack`1.cs
│ ├── ImmutableTreeQueue`1.cs
│ ├── ImmutableTreeSet.cs
│ ├── ImmutableSortedTreeSet.cs
│ ├── ImmutableTreeDictionary`2+Enumerator.cs
│ └── ImmutableSortedTreeDictionary`2+Enumerator.cs
├── TreeQueue`1+Enumerator.cs
├── TreeStack`1+Enumerator.cs
├── SortedTreeSet`1+Enumerator.cs
├── SortedTreeList`1+Enumerator.cs
├── TreeSet`1+Enumerator.cs
├── KeyOfPairEqualityComparer`2.cs
├── TreeDictionary`2+KeyCollection+Enumerator.cs
├── TreeDictionary`2+ValueCollection+Enumerator.cs
├── SortedTreeDictionary`2+KeyCollection+Enumerator.cs
├── SortedTreeDictionary`2+ValueCollection+Enumerator.cs
├── TunnelVisionLabs.Collections.Trees.csproj
├── Properties
│ └── AssemblyInfo.cs
├── TreeDictionary`2+Enumerator.cs
├── SortedTreeDictionary`2+Enumerator.cs
├── TreeSpan.cs
├── TreeStack`1.cs
├── TreeQueue`1.cs
├── TreeList`1+Enumerator.cs
└── TreeDictionary`2+KeyCollection.cs
├── TunnelVisionLabs.Collections.Trees.Experimental
├── PublicAPI.Shipped.txt
├── PublicAPI.Unshipped.txt
├── TunnelVisionLabs.Collections.Trees.Experimental.csproj
└── Properties
│ └── AssemblyInfo.cs
├── global.json
├── .nuget
└── packages.config
├── TunnelVisionLabs.Collections.Trees.Benchmarks
├── App.config
├── Properties
│ ├── launchSettings.json
│ └── AssemblyInfo.cs
├── Program.cs
├── MemoryDiagnoserConfig.cs
├── DummyBenchmark.cs
├── TunnelVisionLabs.Collections.Trees.Benchmarks.csproj
└── Immutable
│ └── ImmutableTreeListBenchmark.cs
├── .gitignore
├── NuGet.Config
├── TunnelVisionLabs.Collections.Trees.Test
├── App.config
├── packages.config
├── ExceptionUtilitiesTest.cs
├── EverythingThrowsEnumerable`1.cs
├── Immutable
│ ├── ImmutableTreeSetBuilderTest+ImmutableArguments.cs
│ ├── ImmutableSortedTreeSetBuilderTest+ImmutableArguments.cs
│ ├── FixedArray8Test.cs
│ ├── ImmutableTreeListFactoryTest.cs
│ ├── ImmutableTreeListTest+ForEach.cs
│ └── ImmutableTreeListBuilderTest+ForEach.cs
├── ZeroHashCodeEqualityComparer`1.cs
├── ReverseComparer`1.cs
├── TunnelVisionLabs.Collections.Trees.Test.csproj
├── CollectionAssert.cs
├── Properties
│ └── AssemblyInfo.cs
├── List
│ ├── TreeListIListIsReadOnly.cs
│ ├── TreeListIListIsFixedSize.cs
│ ├── TreeListICollectionSyncRoot.cs
│ ├── TreeListCtor1.cs
│ ├── TreeListICollectionIsSynchronized.cs
│ ├── TreeListCount.cs
│ ├── TreeListICollectionIsReadOnly.cs
│ ├── TreeListIListContains.cs
│ ├── TreeListToArray.cs
│ ├── TreeListIListRemove.cs
│ ├── TreeListClear.cs
│ ├── TreeListAdd.cs
│ ├── TreeListIEnumerableGetEnumerator.cs
│ ├── TreeListIEnumerableGetEnumerator2.cs
│ ├── TreeListAddRange.cs
│ ├── TreeListCtor2.cs
│ ├── TreeListContains.cs
│ ├── TreeListGetEnumerator.cs
│ ├── TreeListIndexOf1.cs
│ ├── TreeListIListAdd.cs
│ ├── TreeListRemoveAt.cs
│ ├── TreeListIListIndexOf.cs
│ ├── TreeListIListItem.cs
│ ├── CopyTo1.cs
│ ├── TreeListReverse.cs
│ ├── TreeListLastIndexOf1.cs
│ ├── TreeListRemoveRange.cs
│ ├── TreeListForEach.cs
│ ├── TreeListIndexOf2.cs
│ ├── TreeListLastIndexOf2.cs
│ └── BinarySearch1.cs
├── SubsetHashCodeEqualityComparer`1.cs
├── ReverseComparerTests.cs
├── EverythingThrowsEnumerableTest.cs
├── GeneratorTest.cs
├── Generator.cs
└── ThrowingTraceListener.cs
├── .gitattributes
├── version.json
├── codecov.yml
├── stylecop.json
├── TunnelVisionLabs.Collections.Trees.Internal.ruleset
├── appveyor.yml
├── LICENSE
├── Directory.Build.targets
├── README.md
└── TunnelVisionLabs.Collections.Trees.ruleset
/TunnelVisionLabs.Collections.Trees/PublicAPI.Shipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Experimental/PublicAPI.Shipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Experimental/PublicAPI.Unshipped.txt:
--------------------------------------------------------------------------------
1 | #nullable enable
2 |
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "3.1.400",
4 | "rollForward": "latestPatch"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/.nuget/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Benchmarks/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build and test output
2 | packages/
3 | bin/
4 | obj/
5 |
6 | # Per-user files created by IDEs
7 | *.suo
8 | *.user
9 | .vs/
10 |
11 | # Created by the build script
12 | build/nuget/
13 | .nuget/nuget.exe
14 | /TunnelVisionLabs.Collections.Trees.Benchmarks/BenchmarkDotNet.Artifacts/*
15 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Benchmarks/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "Benchmark (All)": {
4 | "commandName": "Project",
5 | "commandLineArgs": "--filter *"
6 | },
7 | "Benchmark (Interactive)": {
8 | "commandName": "Project"
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Set the default behavior (used when a rule below doesn't match)
2 | * text=auto
3 |
4 | # Source code files
5 | *.cs text
6 | *.config text
7 | *.resx text
8 | *.nuspec text
9 | *.ps1 text
10 | *.cd text
11 |
12 | # Text files
13 | *.md text
14 | *.txt text
15 | LICENSE text
16 |
17 | # Projects and solutions
18 | *.sln text
19 | *.csproj text
20 | *.yml text
21 | *.StyleCop text
22 | *.ruleset
23 |
24 | # Known binary files
25 | *.snk binary
26 |
--------------------------------------------------------------------------------
/version.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3 | "version": "1.0.0-alpha.{height}",
4 | "assemblyVersion": {
5 | "precision": "minor"
6 | },
7 | "publicReleaseRefSpec": [
8 | "^refs/heads/master$"
9 | ],
10 | "nugetPackageVersion": {
11 | "semVer": 2
12 | },
13 | "cloudBuild": {
14 | "buildNumber": {
15 | "enabled": true
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/ExceptionUtilities.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees
5 | {
6 | using System;
7 |
8 | internal static class ExceptionUtilities
9 | {
10 | public static Exception Unreachable => new InvalidOperationException("This code should not be reachable.");
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/ExcludeFromCodeCoverageAttribute.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | #if NETSTANDARD1_1
5 |
6 | namespace System.Diagnostics.CodeAnalysis
7 | {
8 | [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = false)]
9 | internal sealed class ExcludeFromCodeCoverageAttribute : Attribute
10 | {
11 | }
12 | }
13 |
14 | #endif
15 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Benchmarks/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Benchmarks
5 | {
6 | using BenchmarkDotNet.Running;
7 |
8 | internal class Program
9 | {
10 | private static void Main(string[] args)
11 | {
12 | new BenchmarkSwitcher(typeof(Program).Assembly).Run(args);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Benchmarks/MemoryDiagnoserConfig.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Benchmarks
5 | {
6 | using BenchmarkDotNet.Configs;
7 | using BenchmarkDotNet.Diagnosers;
8 |
9 | public class MemoryDiagnoserConfig : ManualConfig
10 | {
11 | public MemoryDiagnoserConfig()
12 | {
13 | Add(MemoryDiagnoser.Default);
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | # https://docs.codecov.io/docs/codecov-yaml
2 | # https://github.com/codecov/support/wiki/Codecov-Yaml
3 |
4 | coverage:
5 | status:
6 | project:
7 | default: false
8 | patch:
9 | default: false
10 |
11 | comment:
12 | layout: "diff"
13 |
14 | flags:
15 | production:
16 | paths:
17 | - TunnelVisionLabs.Collections.Trees/
18 | - TunnelVisionLabs.Collections.Trees.Experimental/
19 | test:
20 | paths:
21 | - TunnelVisionLabs.Collections.Trees.Test/
22 | # Filter results to only show debug reports until the accuracy problems with
23 | # the report merge process are fixed.
24 | Release:
25 | paths:
26 | - nonexistent/
27 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/ValidationRules.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees
5 | {
6 | using System;
7 |
8 | [Flags]
9 | internal enum ValidationRules
10 | {
11 | ///
12 | /// No special validation rules apply.
13 | ///
14 | None = 0,
15 |
16 | ///
17 | /// The tree is packed (i.e. there is empty space except at the end of each level).
18 | ///
19 | RequirePacked = 0b0001,
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Benchmarks/DummyBenchmark.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Benchmarks
5 | {
6 | using BenchmarkDotNet.Attributes;
7 |
8 | [ShortRunJob]
9 | public class DummyBenchmark
10 | {
11 | private static readonly int[] Ints = { 1, 2, 3 };
12 |
13 | [Benchmark(Baseline = true)]
14 | public object NewTreeList1()
15 | {
16 | return new TreeList(Ints);
17 | }
18 |
19 | [Benchmark]
20 | public object NewTreeList2()
21 | {
22 | return new TreeList(Ints);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Benchmarks/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | using System;
5 | using System.Reflection;
6 | using System.Runtime.InteropServices;
7 |
8 | // General Information about an assembly is controlled through the following
9 | // set of attributes. Change these attribute values to modify the information
10 | // associated with an assembly.
11 | [assembly: AssemblyTrademark("")]
12 | [assembly: AssemblyCulture("")]
13 | [assembly: CLSCompliant(false)]
14 | [assembly: ComVisible(false)]
15 |
16 | [assembly: BenchmarkDotNet.Attributes.Config(typeof(TunnelVisionLabs.Collections.Trees.Benchmarks.MemoryDiagnoserConfig))]
17 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/ExceptionUtilitiesTest.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Test
5 | {
6 | using System;
7 | using Xunit;
8 |
9 | public class ExceptionUtilitiesTest
10 | {
11 | [Fact]
12 | public void TestUnreachable()
13 | {
14 | // Make sure it has the correct type
15 | Assert.IsAssignableFrom(ExceptionUtilities.Unreachable);
16 |
17 | // Make sure a new instance is created each time it's accessed
18 | Assert.NotSame(ExceptionUtilities.Unreachable, ExceptionUtilities.Unreachable);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/stylecop.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
3 | "settings": {
4 | "documentationRules": {
5 | "companyName": "Tunnel Vision Laboratories, LLC",
6 | "copyrightText": "Copyright (c) {companyName}. All Rights Reserved.\r\nLicensed under the MIT License. See LICENSE in the project root for license information.",
7 | "xmlHeader": false,
8 | "fileNamingConvention": "metadata"
9 | },
10 | "layoutRules": {
11 | "newlineAtEndOfFile": "require"
12 | },
13 | "orderingRules": {
14 | // Ignore accessibility for determining the element order
15 | "elementOrder": [ "kind", "constant" ]
16 | },
17 | "namingRules": {
18 | "tupleElementNameCasing": "camelCase"
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/EverythingThrowsEnumerable`1.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Test
5 | {
6 | using System;
7 | using System.Collections;
8 | using System.Collections.Generic;
9 |
10 | public sealed class EverythingThrowsEnumerable : IEnumerable
11 | {
12 | public static readonly EverythingThrowsEnumerable Instance = new EverythingThrowsEnumerable();
13 |
14 | private EverythingThrowsEnumerable()
15 | {
16 | }
17 |
18 | public IEnumerator GetEnumerator() => throw new NotSupportedException();
19 |
20 | IEnumerator IEnumerable.GetEnumerator() => throw new NotSupportedException();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Experimental/TunnelVisionLabs.Collections.Trees.Experimental.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | net45;netstandard1.1;netstandard2.0;netstandard2.1
6 | TunnelVisionLabs.Collections.Trees
7 | true
8 |
9 |
10 |
11 | ..\TunnelVisionLabs.Collections.Trees.ruleset
12 |
13 |
14 |
15 | true
16 | ..\build\keys\UnitTestingKey.snk
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Internal.ruleset:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/Immutable/ImmutableTreeSetBuilderTest+ImmutableArguments.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Test.Immutable
5 | {
6 | using System.Collections.Generic;
7 | using TunnelVisionLabs.Collections.Trees.Immutable;
8 |
9 | public partial class ImmutableTreeSetBuilderTest
10 | {
11 | public class ImmutableArguments : AbstractSetTest
12 | {
13 | protected override ISet CreateSet()
14 | {
15 | return ImmutableTreeSet.CreateBuilder();
16 | }
17 |
18 | protected override IEnumerable TransformEnumerableForSetOperation(IEnumerable enumerable)
19 | {
20 | return ImmutableTreeSet.CreateRange(enumerable);
21 | }
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/ZeroHashCodeEqualityComparer`1.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Test
5 | {
6 | using System.Collections.Generic;
7 | using System.Diagnostics.CodeAnalysis;
8 |
9 | internal sealed class ZeroHashCodeEqualityComparer : IEqualityComparer
10 | {
11 | public static readonly ZeroHashCodeEqualityComparer Default = new ZeroHashCodeEqualityComparer(null);
12 | private readonly IEqualityComparer _comparer;
13 |
14 | public ZeroHashCodeEqualityComparer(IEqualityComparer? comparer)
15 | {
16 | _comparer = comparer ?? EqualityComparer.Default;
17 | }
18 |
19 | public bool Equals([AllowNull] T x, [AllowNull] T y) => _comparer.Equals(x, y);
20 |
21 | public int GetHashCode(T obj) => 0;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/Immutable/ImmutableSortedTreeSetBuilderTest+ImmutableArguments.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Test.Immutable
5 | {
6 | using System.Collections.Generic;
7 | using TunnelVisionLabs.Collections.Trees.Immutable;
8 |
9 | public partial class ImmutableSortedTreeSetBuilderTest
10 | {
11 | public class ImmutableArguments : AbstractSetTest
12 | {
13 | protected override ISet CreateSet()
14 | {
15 | return ImmutableSortedTreeSet.CreateBuilder();
16 | }
17 |
18 | protected override IEnumerable TransformEnumerableForSetOperation(IEnumerable enumerable)
19 | {
20 | return ImmutableSortedTreeSet.CreateRange(enumerable);
21 | }
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Experimental/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | using System;
5 | using System.Reflection;
6 | using System.Runtime.CompilerServices;
7 |
8 | // General Information about an assembly is controlled through the following
9 | // set of attributes. Change these attribute values to modify the information
10 | // associated with an assembly.
11 | [assembly: AssemblyTrademark("")]
12 | [assembly: AssemblyCulture("")]
13 | [assembly: CLSCompliant(true)]
14 |
15 | [assembly: InternalsVisibleTo("TunnelVisionLabs.Collections.Trees.Test, PublicKey=002400000480000094000000060200000024000052534131000400000100010063bb30979a5f932c6ecc131ea6e9cf2e2a50a8476dd94a803452df56f75882df32a98244f6b162da6873515f5cd84217bb773aa18053fb4b2c4a74b60eb8c4d7dce9fa916819c8a85f4df559d9a10d9d89c1db47e5f18730b2047b636220156b9c3761acd9588f566b14d84ba110be8c4aa52868c0204e2ee2b51430a9611cd0")]
16 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/ReverseComparer`1.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Test
5 | {
6 | using System.Collections.Generic;
7 | using System.Diagnostics.CodeAnalysis;
8 |
9 | internal sealed class ReverseComparer : IComparer
10 | {
11 | public static readonly ReverseComparer Default = new ReverseComparer(null);
12 |
13 | private readonly IComparer _comparer;
14 |
15 | public ReverseComparer(IComparer? comparer)
16 | {
17 | _comparer = comparer ?? Comparer.Default;
18 | }
19 |
20 | public int Compare([AllowNull] T x, [AllowNull] T y)
21 | {
22 | var direct = _comparer.Compare(x, y);
23 | if (direct == int.MinValue)
24 | return int.MaxValue;
25 |
26 | return -direct;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/KeyOfPairComparer`2.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees
5 | {
6 | using System.Collections.Generic;
7 | using System.Diagnostics;
8 |
9 | internal sealed class KeyOfPairComparer : IComparer>
10 | {
11 | internal KeyOfPairComparer(IComparer comparer)
12 | {
13 | Debug.Assert(comparer != null, $"Assertion failed: {nameof(comparer)} != null");
14 | KeyComparer = comparer;
15 | }
16 |
17 | internal static KeyOfPairComparer Default { get; }
18 | = new KeyOfPairComparer(Comparer.Default);
19 |
20 | internal IComparer KeyComparer { get; }
21 |
22 | public int Compare(KeyValuePair x, KeyValuePair y)
23 | => KeyComparer.Compare(x.Key, y.Key);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | version: '{build}'
2 | image: Visual Studio 2019
3 | configuration:
4 | - Debug
5 | - Release
6 | init:
7 | - git config --global core.autocrlf true
8 | before_build:
9 | - nuget restore
10 | skip_tags: true
11 | build:
12 | project: dotnet-trees.sln
13 | verbosity: minimal
14 | test_script:
15 | - .\packages\OpenCover.4.6.519\tools\OpenCover.Console.exe -register:Path32 -target:"%xunit20%\xunit.console.x86.exe" -targetargs:"C:\projects\dotnet-trees\TunnelVisionLabs.Collections.Trees.Test\bin\%configuration%\net452\TunnelVisionLabs.Collections.Trees.Test.dll -noshadow -appveyor" -threshold:1 -oldStyle -returntargetcode -filter:"+[TunnelVisionLabs*]*" -excludebyattribute:*.ExcludeFromCodeCoverage* -excludebyfile:*\*Designer.cs -hideskipped:All -output:.\trees_coverage.xml
16 | - .\packages\Codecov.1.12.1\tools\codecov.exe -n "%configuration%" -f "trees_coverage.xml" --flag "%configuration%"
17 | cache:
18 | - packages -> **\packages.config
19 | artifacts:
20 | - path: 'TunnelVisionLabs.Collections.Trees\**\*.nupkg'
21 | - path: 'TunnelVisionLabs.Collections.Trees.Experimental\**\*.nupkg'
22 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/ComparisonComparer`1.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees
5 | {
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Diagnostics;
9 | using System.Diagnostics.CodeAnalysis;
10 |
11 | internal sealed class ComparisonComparer : IComparer
12 | {
13 | private readonly Comparison _comparison;
14 |
15 | public ComparisonComparer(Comparison comparison)
16 | {
17 | Debug.Assert(comparison != null, $"Assertion failed: {nameof(comparison)} != null");
18 | _comparison = comparison;
19 | }
20 |
21 | #pragma warning disable CS8604 // Possible null reference argument. (.NET 5 corrected the signature of Comparison)
22 | public int Compare([AllowNull] T x, [AllowNull] T y) => _comparison(x, y);
23 | #pragma warning restore CS8604 // Possible null reference argument.
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/TunnelVisionLabs.Collections.Trees.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | net452
6 |
7 |
8 |
9 | ..\TunnelVisionLabs.Collections.Trees.Internal.ruleset
10 |
11 |
12 |
13 | true
14 | ..\build\keys\UnitTestingKey.snk
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/CollectionAssert.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Test
5 | {
6 | using System;
7 | using System.Collections.Generic;
8 | using Xunit;
9 |
10 | public static class CollectionAssert
11 | {
12 | public static void EnumeratorInvalidated(IEnumerable enumerable, Action action)
13 | {
14 | using (IEnumerator enumerator = enumerable.GetEnumerator())
15 | {
16 | action();
17 | Assert.Throws(() => enumerator.MoveNext());
18 | }
19 | }
20 |
21 | public static void EnumeratorNotInvalidated(IEnumerable enumerable, Action action)
22 | {
23 | using (IEnumerator enumerator = enumerable.GetEnumerator())
24 | {
25 | action();
26 | enumerator.MoveNext();
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/Immutable/ImmutableSortedTreeSet`1+Enumerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Immutable
5 | {
6 | using System.Collections;
7 | using System.Collections.Generic;
8 |
9 | public partial class ImmutableSortedTreeSet
10 | {
11 | public struct Enumerator : IEnumerator
12 | {
13 | private ImmutableSortedTreeList.Enumerator _enumerator;
14 |
15 | internal Enumerator(ImmutableSortedTreeList.Enumerator enumerator)
16 | {
17 | _enumerator = enumerator;
18 | }
19 |
20 | public T Current => _enumerator.Current;
21 |
22 | object? IEnumerator.Current => Current;
23 |
24 | public void Dispose() => _enumerator.Dispose();
25 |
26 | public bool MoveNext() => _enumerator.MoveNext();
27 |
28 | public void Reset() => _enumerator.Reset();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/TreeQueue`1+Enumerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees
5 | {
6 | using System.Collections;
7 | using System.Collections.Generic;
8 |
9 | public partial class TreeQueue
10 | {
11 | public struct Enumerator : IEnumerator
12 | {
13 | private TreeList.Enumerator _enumerator;
14 |
15 | internal Enumerator(TreeList.Enumerator enumerator)
16 | {
17 | _enumerator = enumerator;
18 | }
19 |
20 | public T Current => _enumerator.Current;
21 |
22 | object? IEnumerator.Current => _enumerator.Current;
23 |
24 | public void Dispose() => _enumerator.Dispose();
25 |
26 | public bool MoveNext() => _enumerator.MoveNext();
27 |
28 | void IEnumerator.Reset() => InternalReset();
29 |
30 | internal void InternalReset() => _enumerator.InternalReset();
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/TreeStack`1+Enumerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees
5 | {
6 | using System.Collections;
7 | using System.Collections.Generic;
8 |
9 | public partial class TreeStack
10 | {
11 | public struct Enumerator : IEnumerator
12 | {
13 | private TreeList.Enumerator _enumerator;
14 |
15 | internal Enumerator(TreeList.Enumerator enumerator)
16 | {
17 | _enumerator = enumerator;
18 | }
19 |
20 | public T Current => _enumerator.Current;
21 |
22 | object? IEnumerator.Current => _enumerator.Current;
23 |
24 | public void Dispose() => _enumerator.Dispose();
25 |
26 | public bool MoveNext() => _enumerator.MoveNext();
27 |
28 | void IEnumerator.Reset() => InternalReset();
29 |
30 | internal void InternalReset() => _enumerator.InternalReset();
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) Tunnel Vision Laboratories, LLC
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/SortedTreeSet`1+Enumerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees
5 | {
6 | using System.Collections;
7 | using System.Collections.Generic;
8 |
9 | public partial class SortedTreeSet
10 | {
11 | public struct Enumerator : IEnumerator
12 | {
13 | private SortedTreeList.Enumerator _enumerator;
14 |
15 | internal Enumerator(SortedTreeList.Enumerator enumerator)
16 | {
17 | _enumerator = enumerator;
18 | }
19 |
20 | public T Current => _enumerator.Current;
21 |
22 | object? IEnumerator.Current => Current;
23 |
24 | public void Dispose() => _enumerator.Dispose();
25 |
26 | public bool MoveNext() => _enumerator.MoveNext();
27 |
28 | void IEnumerator.Reset() => InternalReset();
29 |
30 | internal void InternalReset() => _enumerator.InternalReset();
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/Immutable/ImmutableTreeSet`1+Enumerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Immutable
5 | {
6 | using System.Collections;
7 | using System.Collections.Generic;
8 |
9 | public partial class ImmutableTreeSet
10 | {
11 | public struct Enumerator : IEnumerator
12 | {
13 | private ImmutableSortedTreeList<(int hashCode, T value)>.Enumerator _enumerator;
14 |
15 | internal Enumerator(ImmutableSortedTreeList<(int hashCode, T value)>.Enumerator enumerator)
16 | {
17 | _enumerator = enumerator;
18 | }
19 |
20 | public T Current => _enumerator.Current.value;
21 |
22 | object? IEnumerator.Current => Current;
23 |
24 | public void Dispose() => _enumerator.Dispose();
25 |
26 | public bool MoveNext() => _enumerator.MoveNext();
27 |
28 | public void Reset() => _enumerator.Reset();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/Immutable/ImmutableSortedTreeList`1+Enumerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Immutable
5 | {
6 | using System.Collections;
7 | using System.Collections.Generic;
8 |
9 | internal sealed partial class ImmutableSortedTreeList
10 | {
11 | public struct Enumerator : IEnumerator
12 | {
13 | private ImmutableTreeList.Enumerator _enumerator;
14 |
15 | internal Enumerator(ImmutableTreeList.Enumerator enumerator)
16 | {
17 | _enumerator = enumerator;
18 | }
19 |
20 | public T Current => _enumerator.Current;
21 |
22 | object? IEnumerator.Current => Current;
23 |
24 | public void Dispose()
25 | => _enumerator.Dispose();
26 |
27 | public bool MoveNext()
28 | => _enumerator.MoveNext();
29 |
30 | public void Reset()
31 | => _enumerator.Reset();
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/SortedTreeList`1+Enumerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees
5 | {
6 | using System;
7 | using System.Collections;
8 | using System.Collections.Generic;
9 |
10 | public partial class SortedTreeList
11 | {
12 | public struct Enumerator : IEnumerator
13 | {
14 | private TreeList.Enumerator _enumerator;
15 |
16 | internal Enumerator(TreeList.Enumerator enumerator)
17 | {
18 | _enumerator = enumerator;
19 | }
20 |
21 | public T Current => _enumerator.Current;
22 |
23 | object? IEnumerator.Current => Current;
24 |
25 | public void Dispose() => ((IDisposable)_enumerator).Dispose();
26 |
27 | public bool MoveNext() => _enumerator.MoveNext();
28 |
29 | void IEnumerator.Reset() => InternalReset();
30 |
31 | internal void InternalReset() => _enumerator.InternalReset();
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/TreeSet`1+Enumerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees
5 | {
6 | using System.Collections;
7 | using System.Collections.Generic;
8 |
9 | public partial class TreeSet
10 | {
11 | public struct Enumerator : IEnumerator
12 | {
13 | private SortedTreeList<(int hashCode, T value)>.Enumerator _enumerator;
14 |
15 | internal Enumerator(SortedTreeList<(int hashCode, T value)>.Enumerator enumerator)
16 | {
17 | _enumerator = enumerator;
18 | }
19 |
20 | public T Current => _enumerator.Current.value;
21 |
22 | object? IEnumerator.Current => Current;
23 |
24 | public void Dispose() => _enumerator.Dispose();
25 |
26 | public bool MoveNext() => _enumerator.MoveNext();
27 |
28 | void IEnumerator.Reset() => InternalReset();
29 |
30 | internal void InternalReset() => _enumerator.InternalReset();
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | using System;
5 | using System.Reflection;
6 | using System.Runtime.InteropServices;
7 | using Xunit;
8 |
9 | // General Information about an assembly is controlled through the following
10 | // set of attributes. Change these attribute values to modify the information
11 | // associated with an assembly.
12 | [assembly: AssemblyTrademark("")]
13 | [assembly: AssemblyCulture("")]
14 | [assembly: CLSCompliant(false)]
15 |
16 | // Setting ComVisible to false makes the types in this assembly not visible
17 | // to COM components. If you need to access a type in this assembly from
18 | // COM, set the ComVisible attribute to true on that type.
19 | [assembly: ComVisible(false)]
20 |
21 | // The following GUID is for the ID of the typelib if this project is exposed to COM
22 | [assembly: Guid("73541434-2511-441c-bbaf-05044be33019")]
23 |
24 | // Disable test parallelization since GeneratorTest manipulates mutable shared data
25 | [assembly: CollectionBehavior(DisableTestParallelization = true)]
26 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/Immutable/ImmutableTreeQueue`1+Enumerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Immutable
5 | {
6 | using System;
7 | using System.Collections;
8 | using System.Collections.Generic;
9 |
10 | public partial class ImmutableTreeQueue
11 | {
12 | public struct Enumerator : IEnumerator
13 | {
14 | private ImmutableTreeList.Enumerator _enumerator;
15 |
16 | internal Enumerator(ImmutableTreeList.Enumerator enumerator)
17 | {
18 | _enumerator = enumerator;
19 | }
20 |
21 | public T Current => _enumerator.Current;
22 |
23 | object? IEnumerator.Current => _enumerator.Current;
24 |
25 | public bool MoveNext() => _enumerator.MoveNext();
26 |
27 | void IDisposable.Dispose() => _enumerator.Dispose();
28 |
29 | void IEnumerator.Reset() => InternalReset();
30 |
31 | internal void InternalReset() => _enumerator.Reset();
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/Immutable/ImmutableTreeStack`1+Enumerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Immutable
5 | {
6 | using System;
7 | using System.Collections;
8 | using System.Collections.Generic;
9 |
10 | public partial class ImmutableTreeStack
11 | {
12 | public struct Enumerator : IEnumerator
13 | {
14 | private ImmutableTreeList.Enumerator _enumerator;
15 |
16 | internal Enumerator(ImmutableTreeList.Enumerator enumerator)
17 | {
18 | _enumerator = enumerator;
19 | }
20 |
21 | public T Current => _enumerator.Current;
22 |
23 | object? IEnumerator.Current => _enumerator.Current;
24 |
25 | public bool MoveNext() => _enumerator.MoveNext();
26 |
27 | void IDisposable.Dispose() => _enumerator.Dispose();
28 |
29 | void IEnumerator.Reset() => InternalReset();
30 |
31 | internal void InternalReset() => _enumerator.Reset();
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Benchmarks/TunnelVisionLabs.Collections.Trees.Benchmarks.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | net461
6 | Exe
7 | true
8 |
9 |
10 |
11 | ..\TunnelVisionLabs.Collections.Trees.Internal.ruleset
12 |
13 |
14 |
15 | true
16 | ..\build\keys\UnitTestingKey.snk
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/List/TreeListIListIsReadOnly.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Test.List
5 | {
6 | using System.Collections;
7 | using System.Collections.Generic;
8 | using Xunit;
9 |
10 | ///
11 | /// Tests for the implementation of , derived from tests for
12 | /// in dotnet/coreclr.
13 | ///
14 | public class TreeListIListIsReadOnly
15 | {
16 | [Fact(DisplayName = "PosTest1: this IsFixedSize property always returns false.")]
17 | public void PosTest1()
18 | {
19 | int[] iArray = { 1, 9, 3, 6, 5, 8, 7, 2, 4, 0 };
20 | TreeList listObject = new TreeList(iArray);
21 | Assert.False(((IList)listObject).IsReadOnly);
22 |
23 | string[] sArray = { "1", "9", "3", "6", "5", "8", "7", "2", "4", "0" };
24 | TreeList listObject1 = new TreeList(sArray);
25 | Assert.False(((IList)listObject).IsReadOnly);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/List/TreeListIListIsFixedSize.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Test.List
5 | {
6 | using System.Collections;
7 | using System.Collections.Generic;
8 | using Xunit;
9 |
10 | ///
11 | /// Tests for the implementation of , derived from tests for
12 | /// in dotnet/coreclr.
13 | ///
14 | public class TreeListIListIsFixedSize
15 | {
16 | [Fact(DisplayName = "PosTest1: this IsFixedSize property always returns false.")]
17 | public void PosTest1()
18 | {
19 | int[] iArray = { 1, 9, 3, 6, 5, 8, 7, 2, 4, 0 };
20 | TreeList listObject = new TreeList(iArray);
21 | Assert.False(((IList)listObject).IsFixedSize);
22 |
23 | string[] sArray = { "1", "9", "3", "6", "5", "8", "7", "2", "4", "0" };
24 | TreeList listObject1 = new TreeList(sArray);
25 | Assert.False(((IList)listObject).IsFixedSize);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/Immutable/FixedArray8Test.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Test.Immutable
5 | {
6 | using System;
7 | using System.Collections.Generic;
8 | using TunnelVisionLabs.Collections.Trees.Immutable;
9 | using Xunit;
10 |
11 | public class FixedArray8Test
12 | {
13 | [Fact]
14 | public void TestBoundsCheck()
15 | {
16 | FixedArray8 array = default;
17 | Assert.Throws(() => array[-1]);
18 | Assert.Throws(() => array[-1] = 0);
19 | Assert.Throws(() => array[array.Length]);
20 | Assert.Throws(() => array[array.Length] = 0);
21 | }
22 |
23 | [Fact]
24 | public void TestSortSmallRange()
25 | {
26 | FixedArray8 array = default;
27 | array.Sort(0, 0, Comparer.Default);
28 | array.Sort(1, 1, Comparer.Default);
29 | Assert.Equal(default, array);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/Immutable/ImmutableTreeList.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Immutable
5 | {
6 | using System.Collections.Generic;
7 |
8 | public static class ImmutableTreeList
9 | {
10 | public static ImmutableTreeList Create() => ImmutableTreeList.Empty;
11 |
12 | public static ImmutableTreeList Create(T item) => ImmutableTreeList.Empty.Add(item);
13 |
14 | public static ImmutableTreeList Create(params T[] items) => ImmutableTreeList.Empty.AddRange(items);
15 |
16 | public static ImmutableTreeList.Builder CreateBuilder() => Create().ToBuilder();
17 |
18 | public static ImmutableTreeList CreateRange(IEnumerable items) => ImmutableTreeList.Empty.AddRange(items);
19 |
20 | public static ImmutableTreeList ToImmutableTreeList(this IEnumerable source)
21 | {
22 | if (source is ImmutableTreeList existingList)
23 | return existingList;
24 |
25 | return ImmutableTreeList.Empty.AddRange(source);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # .NET Trees
2 |
3 | Efficient implementations of standard .NET collection interfaces using tree data structures.
4 |
5 | [](https://ci.appveyor.com/project/sharwell/dotnet-trees/branch/master)
6 |
7 | [](https://codecov.io/gh/tunnelvisionlabs/dotnet-trees)
8 |
9 | [](https://gitter.im/tunnelvisionlabs/dotnet-trees?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
10 |
11 | ## Releases
12 |
13 | [](https://www.nuget.org/packages/TunnelVisionLabs.Collections.Trees) [](https://www.nuget.org/packages/TunnelVisionLabs.Collections.Trees/absoluteLatest)
14 |
15 | * [Binaries (NuGet)](https://www.nuget.org/packages/TunnelVisionLabs.Collections.Trees)
16 | * [Release Notes](https://github.com/tunnelvisionlabs/dotnet-trees/releases)
17 | * [License](https://github.com/tunnelvisionlabs/dotnet-trees/blob/master/LICENSE)
18 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/SubsetHashCodeEqualityComparer`1.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Test
5 | {
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Diagnostics.CodeAnalysis;
9 |
10 | internal sealed class SubsetHashCodeEqualityComparer : IEqualityComparer
11 | {
12 | private readonly IEqualityComparer _equalityComparer;
13 | private readonly Func _getHashCode;
14 |
15 | public SubsetHashCodeEqualityComparer(IEqualityComparer equalityComparer, IEqualityComparer hashCodeEqualityComparer)
16 | : this(equalityComparer, hashCodeEqualityComparer.GetHashCode)
17 | {
18 | }
19 |
20 | public SubsetHashCodeEqualityComparer(IEqualityComparer equalityComparer, Func getHashCode)
21 | {
22 | _equalityComparer = equalityComparer;
23 | _getHashCode = getHashCode;
24 | }
25 |
26 | public bool Equals([AllowNull] T x, [AllowNull] T y) => _equalityComparer.Equals(x, y);
27 |
28 | public int GetHashCode(T obj) => _getHashCode(obj);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/Immutable/ImmutableTreeDictionary`2+KeyCollection+Enumerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Immutable
5 | {
6 | using System.Collections;
7 | using System.Collections.Generic;
8 |
9 | public partial class ImmutableTreeDictionary
10 | {
11 | public partial struct KeyCollection
12 | {
13 | public struct Enumerator : IEnumerator
14 | {
15 | private ImmutableTreeDictionary.Enumerator _enumerator;
16 |
17 | internal Enumerator(ImmutableTreeDictionary.Enumerator enumerator)
18 | {
19 | _enumerator = enumerator;
20 | }
21 |
22 | public TKey Current => _enumerator.Current.Key;
23 |
24 | object IEnumerator.Current => Current;
25 |
26 | public void Dispose() => _enumerator.Dispose();
27 |
28 | public bool MoveNext() => _enumerator.MoveNext();
29 |
30 | public void Reset() => _enumerator.Reset();
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/Immutable/ImmutableTreeDictionary`2+ValueCollection+Enumerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Immutable
5 | {
6 | using System.Collections;
7 | using System.Collections.Generic;
8 |
9 | public partial class ImmutableTreeDictionary
10 | {
11 | public partial struct ValueCollection
12 | {
13 | public struct Enumerator : IEnumerator
14 | {
15 | private ImmutableTreeDictionary.Enumerator _enumerator;
16 |
17 | internal Enumerator(ImmutableTreeDictionary.Enumerator enumerator)
18 | {
19 | _enumerator = enumerator;
20 | }
21 |
22 | public TValue Current => _enumerator.Current.Value;
23 |
24 | object? IEnumerator.Current => Current;
25 |
26 | public void Dispose() => _enumerator.Dispose();
27 |
28 | public bool MoveNext() => _enumerator.MoveNext();
29 |
30 | public void Reset() => _enumerator.Reset();
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/Immutable/ImmutableSortedTreeDictionary`2+KeyCollection+Enumerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Immutable
5 | {
6 | using System.Collections;
7 | using System.Collections.Generic;
8 |
9 | public partial class ImmutableSortedTreeDictionary
10 | {
11 | public partial struct KeyCollection
12 | {
13 | public struct Enumerator : IEnumerator
14 | {
15 | private ImmutableSortedTreeDictionary.Enumerator _enumerator;
16 |
17 | internal Enumerator(ImmutableSortedTreeDictionary.Enumerator enumerator)
18 | {
19 | _enumerator = enumerator;
20 | }
21 |
22 | public TKey Current => _enumerator.Current.Key;
23 |
24 | object IEnumerator.Current => Current;
25 |
26 | public void Dispose() => _enumerator.Dispose();
27 |
28 | public bool MoveNext() => _enumerator.MoveNext();
29 |
30 | public void Reset() => _enumerator.Reset();
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/KeyOfPairEqualityComparer`2.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees
5 | {
6 | using System.Collections.Generic;
7 | using System.Diagnostics;
8 |
9 | internal sealed class KeyOfPairEqualityComparer : IEqualityComparer>
10 | {
11 | internal KeyOfPairEqualityComparer(IEqualityComparer comparer)
12 | {
13 | Debug.Assert(comparer != null, $"Assertion failed: {nameof(comparer)} != null");
14 | KeyComparer = comparer;
15 | }
16 |
17 | internal static KeyOfPairEqualityComparer Default { get; }
18 | = new KeyOfPairEqualityComparer(EqualityComparer.Default);
19 |
20 | internal IEqualityComparer KeyComparer { get; }
21 |
22 | public bool Equals(KeyValuePair x, KeyValuePair y)
23 | {
24 | return KeyComparer.Equals(x.Key, y.Key);
25 | }
26 |
27 | public int GetHashCode(KeyValuePair obj)
28 | {
29 | return KeyComparer.GetHashCode(obj.Key);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/Immutable/ImmutableSortedTreeDictionary`2+ValueCollection+Enumerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Immutable
5 | {
6 | using System.Collections;
7 | using System.Collections.Generic;
8 |
9 | public partial class ImmutableSortedTreeDictionary
10 | {
11 | public partial struct ValueCollection
12 | {
13 | public struct Enumerator : IEnumerator
14 | {
15 | private ImmutableSortedTreeDictionary.Enumerator _enumerator;
16 |
17 | internal Enumerator(ImmutableSortedTreeDictionary.Enumerator enumerator)
18 | {
19 | _enumerator = enumerator;
20 | }
21 |
22 | public TValue Current => _enumerator.Current.Value;
23 |
24 | object? IEnumerator.Current => Current;
25 |
26 | public void Dispose() => _enumerator.Dispose();
27 |
28 | public bool MoveNext() => _enumerator.MoveNext();
29 |
30 | public void Reset() => _enumerator.Reset();
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/TreeDictionary`2+KeyCollection+Enumerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees
5 | {
6 | using System.Collections;
7 | using System.Collections.Generic;
8 |
9 | public partial class TreeDictionary
10 | {
11 | public partial struct KeyCollection
12 | {
13 | public struct Enumerator : IEnumerator
14 | {
15 | private TreeDictionary.Enumerator _enumerator;
16 |
17 | internal Enumerator(TreeDictionary.Enumerator enumerator)
18 | {
19 | _enumerator = enumerator;
20 | }
21 |
22 | public TKey Current => _enumerator.Current.Key;
23 |
24 | object IEnumerator.Current => Current;
25 |
26 | public void Dispose() => _enumerator.Dispose();
27 |
28 | public bool MoveNext() => _enumerator.MoveNext();
29 |
30 | void IEnumerator.Reset() => InternalReset();
31 |
32 | internal void InternalReset() => _enumerator.InternalReset();
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/TreeDictionary`2+ValueCollection+Enumerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees
5 | {
6 | using System.Collections;
7 | using System.Collections.Generic;
8 |
9 | public partial class TreeDictionary
10 | {
11 | public partial struct ValueCollection
12 | {
13 | public struct Enumerator : IEnumerator
14 | {
15 | private TreeDictionary.Enumerator _enumerator;
16 |
17 | internal Enumerator(TreeDictionary.Enumerator enumerator)
18 | {
19 | _enumerator = enumerator;
20 | }
21 |
22 | public TValue Current => _enumerator.Current.Value;
23 |
24 | object? IEnumerator.Current => Current;
25 |
26 | public void Dispose() => _enumerator.Dispose();
27 |
28 | public bool MoveNext() => _enumerator.MoveNext();
29 |
30 | void IEnumerator.Reset() => InternalReset();
31 |
32 | internal void InternalReset() => _enumerator.InternalReset();
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/SortedTreeDictionary`2+KeyCollection+Enumerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees
5 | {
6 | using System.Collections;
7 | using System.Collections.Generic;
8 |
9 | public partial class SortedTreeDictionary
10 | {
11 | public partial struct KeyCollection
12 | {
13 | public struct Enumerator : IEnumerator
14 | {
15 | private SortedTreeDictionary.Enumerator _enumerator;
16 |
17 | internal Enumerator(SortedTreeDictionary.Enumerator enumerator)
18 | {
19 | _enumerator = enumerator;
20 | }
21 |
22 | public TKey Current => _enumerator.Current.Key;
23 |
24 | object IEnumerator.Current => Current;
25 |
26 | public void Dispose() => _enumerator.Dispose();
27 |
28 | public bool MoveNext() => _enumerator.MoveNext();
29 |
30 | void IEnumerator.Reset() => InternalReset();
31 |
32 | internal void InternalReset() => _enumerator.InternalReset();
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/SortedTreeDictionary`2+ValueCollection+Enumerator.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees
5 | {
6 | using System.Collections;
7 | using System.Collections.Generic;
8 |
9 | public partial class SortedTreeDictionary
10 | {
11 | public partial struct ValueCollection
12 | {
13 | public struct Enumerator : IEnumerator
14 | {
15 | private SortedTreeDictionary.Enumerator _enumerator;
16 |
17 | internal Enumerator(SortedTreeDictionary.Enumerator enumerator)
18 | {
19 | _enumerator = enumerator;
20 | }
21 |
22 | public TValue Current => _enumerator.Current.Value;
23 |
24 | object? IEnumerator.Current => Current;
25 |
26 | public void Dispose() => _enumerator.Dispose();
27 |
28 | public bool MoveNext() => _enumerator.MoveNext();
29 |
30 | void IEnumerator.Reset() => InternalReset();
31 |
32 | internal void InternalReset() => _enumerator.InternalReset();
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/TunnelVisionLabs.Collections.Trees.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | net45;netstandard1.1;netstandard2.0;netstandard2.1
6 | true
7 |
8 |
9 |
10 | true
11 |
12 |
13 |
14 | ..\TunnelVisionLabs.Collections.Trees.ruleset
15 |
16 |
17 |
18 | true
19 | ..\build\keys\TunnelVisionLabs.Collections.Trees.snk
20 | ..\build\keys\TunnelVisionLabs.Collections.Trees.dev.snk
21 |
22 |
23 |
24 | $(DefineConstants);DEVELOPMENT_KEY
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/List/TreeListICollectionSyncRoot.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Test.List
5 | {
6 | using System.Collections;
7 | using System.Collections.Generic;
8 | using Xunit;
9 |
10 | ///
11 | /// Tests for the implementation of , derived from tests for
12 | /// in dotnet/coreclr.
13 | ///
14 | public class TreeListICollectionSyncRoot
15 | {
16 | [Fact(DisplayName = "PosTest1: this SyncRoot property always returns the current instance.")]
17 | public void PosTest1()
18 | {
19 | int[] iArray = { 1, 9, 3, 6, 5, 8, 7, 2, 4, 0 };
20 | TreeList listObject = new TreeList(iArray);
21 | object actualValue = ((ICollection)listObject).SyncRoot;
22 | Assert.NotNull(actualValue);
23 |
24 | string[] sArray = { "1", "9", "3", "6", "5", "8", "7", "2", "4", "0" };
25 | TreeList listObject1 = new TreeList(sArray);
26 | actualValue = ((ICollection)listObject1).SyncRoot;
27 | Assert.NotNull(actualValue);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/ReverseComparerTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Test
5 | {
6 | using System.Collections.Generic;
7 | using Xunit;
8 |
9 | public class ReverseComparerTests
10 | {
11 | private static readonly IComparer DifferencingComparer =
12 | new ComparisonComparer((x, y) => x - y);
13 |
14 | [Fact]
15 | public void TestMinValueHandling()
16 | {
17 | Assert.Equal(int.MinValue, DifferencingComparer.Compare(0, int.MinValue));
18 | Assert.Equal(int.MaxValue, new ReverseComparer(DifferencingComparer).Compare(0, int.MinValue));
19 | }
20 |
21 | [Fact]
22 | public void TestDefaultComparer()
23 | {
24 | Assert.True(Comparer.Default.Compare(0, 1) < 0);
25 | Assert.True(ReverseComparer.Default.Compare(0, 1) > 0);
26 |
27 | Assert.True(Comparer.Default.Compare(1, 0) > 0);
28 | Assert.True(ReverseComparer.Default.Compare(1, 0) < 0);
29 |
30 | Assert.True(Comparer.Default.Compare(0, 0) == 0);
31 | Assert.True(ReverseComparer.Default.Compare(0, 0) == 0);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/List/TreeListCtor1.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Test.List
5 | {
6 | using System.Collections.Generic;
7 | using Xunit;
8 |
9 | ///
10 | /// Tests for , derived from tests for
11 | /// in dotnet/coreclr.
12 | ///
13 | public class TreeListCtor1
14 | {
15 | [Fact(DisplayName = "PosTest1: The genaric type is a value type")]
16 | public void PosTest1()
17 | {
18 | TreeList listObject = new TreeList();
19 | Assert.NotNull(listObject);
20 | }
21 |
22 | [Fact(DisplayName = "PosTest2: The generic type is a reference type")]
23 | public void PosTest2()
24 | {
25 | TreeList listObject = new TreeList();
26 | Assert.NotNull(listObject);
27 | }
28 |
29 | [Fact(DisplayName = "PosTest3: The generic type is a custom type")]
30 | public void PosTest3()
31 | {
32 | TreeList listObject = new TreeList();
33 | Assert.NotNull(listObject);
34 | }
35 |
36 | public class MyClass
37 | {
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/List/TreeListICollectionIsSynchronized.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Test.List
5 | {
6 | using System.Collections;
7 | using System.Collections.Generic;
8 | using Xunit;
9 |
10 | ///
11 | /// Tests for the implementation of , derived from tests for
12 | /// in dotnet/coreclr.
13 | ///
14 | public class TreeListICollectionIsSynchronized
15 | {
16 | [Fact(DisplayName = "PosTest1: In the default implementation of List, this property always returns false.")]
17 | public void PosTest1()
18 | {
19 | int[] iArray = { 1, 9, 3, 6, 5, 8, 7, 2, 4, 0 };
20 | TreeList listObject = new TreeList(iArray);
21 | bool actualValue = ((ICollection)listObject).IsSynchronized;
22 | Assert.False(actualValue);
23 |
24 | string[] sArray = { "1", "9", "3", "6", "5", "8", "7", "2", "4", "0" };
25 | TreeList listObject1 = new TreeList(sArray);
26 | actualValue = ((ICollection)listObject).IsSynchronized;
27 | Assert.False(actualValue);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/Immutable/ImmutableTreeStack.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Immutable
5 | {
6 | using System;
7 | using System.Collections.Generic;
8 |
9 | public static class ImmutableTreeStack
10 | {
11 | public static ImmutableTreeStack Create()
12 | => ImmutableTreeStack.Empty;
13 |
14 | public static ImmutableTreeStack Create(T item)
15 | => ImmutableTreeStack.Empty.Push(item);
16 |
17 | public static ImmutableTreeStack Create(params T[] items)
18 | {
19 | if (items is null)
20 | throw new ArgumentNullException(nameof(items));
21 |
22 | ImmutableTreeStack result = ImmutableTreeStack.Empty;
23 | foreach (T item in items)
24 | result = result.Push(item);
25 |
26 | return result;
27 | }
28 |
29 | public static ImmutableTreeStack CreateRange(IEnumerable items)
30 | {
31 | if (items is null)
32 | throw new ArgumentNullException(nameof(items));
33 |
34 | ImmutableTreeStack result = ImmutableTreeStack.Empty;
35 | foreach (T item in items)
36 | result = result.Push(item);
37 |
38 | return result;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees/Immutable/ImmutableTreeQueue.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Immutable
5 | {
6 | using System;
7 | using System.Collections.Generic;
8 |
9 | public static class ImmutableTreeQueue
10 | {
11 | public static ImmutableTreeQueue Create()
12 | => ImmutableTreeQueue.Empty;
13 |
14 | public static ImmutableTreeQueue Create(T item)
15 | => ImmutableTreeQueue.Empty.Enqueue(item);
16 |
17 | public static ImmutableTreeQueue Create(params T[] items)
18 | {
19 | if (items is null)
20 | throw new ArgumentNullException(nameof(items));
21 |
22 | ImmutableTreeQueue result = ImmutableTreeQueue.Empty;
23 | foreach (T item in items)
24 | result = result.Enqueue(item);
25 |
26 | return result;
27 | }
28 |
29 | public static ImmutableTreeQueue CreateRange(IEnumerable items)
30 | {
31 | if (items is null)
32 | throw new ArgumentNullException(nameof(items));
33 |
34 | ImmutableTreeQueue result = ImmutableTreeQueue.Empty;
35 | foreach (T item in items)
36 | result = result.Enqueue(item);
37 |
38 | return result;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/TunnelVisionLabs.Collections.Trees.Test/EverythingThrowsEnumerableTest.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2 | // Licensed under the MIT License. See LICENSE in the project root for license information.
3 |
4 | namespace TunnelVisionLabs.Collections.Trees.Test
5 | {
6 | using System;
7 | using System.Collections.Generic;
8 | using Xunit;
9 | using IEnumerable = System.Collections.IEnumerable;
10 |
11 | public class EverythingThrowsEnumerableTest
12 | {
13 | [Fact]
14 | public void TestEverythingThrows()
15 | {
16 | TestEverythingThrowsImpl();
17 | TestEverythingThrowsImpl();
18 | TestEverythingThrowsImpl