Skip to content

Commit

Permalink
added fixed size sorted arrays and refactored fixed size graph nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Dermody committed Jul 30, 2024
1 parent 3ff5c4e commit 097022d
Show file tree
Hide file tree
Showing 12 changed files with 13,331 additions and 146 deletions.
44 changes: 44 additions & 0 deletions BrightData.UnitTests/FixedSizeArrayTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BrightData.Types;
using FluentAssertions;
using Xunit;

namespace BrightData.UnitTests
{
public class FixedSizeArrayTests
{
[Fact]
public void TestAscending()
{
var array = new FixedSizeSortedAscending2Array<uint, float>();
array.TryAdd(1, 0.5f).Should().BeTrue();
array.TryAdd(1, 0.5f).Should().BeFalse();
array.TryAdd(2, 0.3f).Should().BeTrue();
array.TryAdd(3, 0.8f).Should().BeFalse();
array.MinValue.Should().Be(2);
array.MaxValue.Should().Be(1);
array.RemoveAt(0);
array.Size.Should().Be(1);
array.MinValue.Should().Be(1);
}

[Fact]
public void TestDescending()
{
var array = new FixedSizeSortedDescending2Array<uint, float>();
array.TryAdd(1, 0.5f).Should().BeTrue();
array.TryAdd(1, 0.5f).Should().BeFalse();
array.TryAdd(2, 0.8f).Should().BeTrue();
array.TryAdd(3, 0.3f).Should().BeFalse();
array.MinValue.Should().Be(1);
array.MaxValue.Should().Be(2);
array.RemoveAt(0);
array.Size.Should().Be(1);
array.MaxValue.Should().Be(1);
}
}
}
2 changes: 1 addition & 1 deletion BrightData.UnitTests/VectorSetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void Closest()
[Fact]
public void TestVectorGraphNode()
{
var node = new IndexedFixedSizeGraphNode<float>(1);
var node = new IndexedFixedSizeGraphNode<float, FixedSizeSortedAscending8Array<uint, float>>(1);
node.Index.Should().Be(1);
node.NeighbourIndices.Length.Should().Be(0);

Expand Down
14 changes: 14 additions & 0 deletions BrightData/BrightData.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
<AutoGen>True</AutoGen>
<DependentUpon>GenericTypeMapping.tt</DependentUpon>
</None>
<None Include="Types\FixedSizeSortedArray\FixedSizeSortedArray.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>FixedSizeSortedArray.tt</DependentUpon>
</None>
</ItemGroup>

<ItemGroup>
Expand All @@ -82,6 +87,10 @@
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Update="Types\FixedSizeSortedArray\FixedSizeSortedArray.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>FixedSizeSortedArray.cs</LastGenOutput>
</None>
</ItemGroup>

<ItemGroup>
Expand All @@ -104,5 +113,10 @@
<AutoGen>True</AutoGen>
<DependentUpon>GenericTypeMapping.tt</DependentUpon>
</Compile>
<Compile Update="Types\FixedSizeSortedArray\FixedSizeSortedArray.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>FixedSizeSortedArray.tt</DependentUpon>
</Compile>
</ItemGroup>
</Project>
Loading

0 comments on commit 097022d

Please sign in to comment.