Skip to content

Commit

Permalink
Namespace fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Wsm2110 committed Apr 14, 2024
1 parent 2bfc5ec commit 9a535f7
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 22 deletions.
2 changes: 1 addition & 1 deletion benchmarks/Faster.Map.Concurrent.Benchmark/AddBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using BenchmarkDotNet.Attributes;
using Faster.Map.Concurrent;

namespace Faster.Map.Benchmark
namespace Faster.Map.Concurrent.Benchmark
{
[MarkdownExporterAttribute.GitHub]
public class AddBenchmark
Expand Down
1 change: 0 additions & 1 deletion benchmarks/Faster.Map.Concurrent.Benchmark/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using BenchmarkDotNet.Running;
using Faster.Map.Benchmark;

namespace Faster.Map.Concurrent.Benchmark
{
Expand Down
8 changes: 4 additions & 4 deletions src/Faster.Map.RobinhoodMap/RobinHoodMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ public RobinhoodMap(uint length, double loadFactor, IEqualityComparer<TKey> keyC
_shift = (byte)(_shift - BitOperations.Log2(_length));

var size = (int)_length + _maxProbeSequenceLength;
_entries = GC.AllocateUninitializedArray<Entry>(size);
_meta = GC.AllocateUninitializedArray<byte>(size);
_entries = GC.AllocateArray<Entry>(size);
_meta = GC.AllocateArray<byte>(size);
}

#endregion
Expand Down Expand Up @@ -237,7 +237,7 @@ public bool Get(TKey key, out TValue value)
var maxDistance = index + _maxProbeSequenceLength;
do
{
var entry = Find(_entries, index);
ref var entry = ref Find(_entries, index);

if (_keyComparer.Equals(entry.Key, key))
{
Expand Down Expand Up @@ -552,7 +552,7 @@ private void Resize()
var oldEntries = _entries;
var oldMeta = _meta;

_entries = GC.AllocateUninitializedArray<Entry>(size);
_entries = GC.AllocateArray<Entry>(size);
_meta = GC.AllocateArray<byte>(size);

for (uint i = 0; i < oldMeta.Length; ++i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Faster.Map.DenseMap;
using Xunit;

namespace Faster.Map.Densemap.Tests
namespace Faster.Map.DenseMap.Tests
{
public class DenseMapStringWrapperTests
{
Expand Down
5 changes: 2 additions & 3 deletions unittests/Faster.Map.QuadMap.Tests/QuadMapContainsTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Faster.Map;
using Faster.Map.QuadMap;
using Faster.Map.QuadMap;

namespace Faster.Map.RobinhoodMap.Tests
namespace Faster.Map.QuadMap.Tests
{
public class RobinhoodContainsTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Faster.Map.QuadMap;

namespace Faster.Map.RobinhoodMap.Tests
namespace Faster.Map.QuadMap.Tests
{
public class QuadMapGetOrUpdateByRefTests
{
Expand Down Expand Up @@ -41,7 +41,7 @@ public void EmplaceOrUpdate_ByRefValue()
{
// Arrange
var dictionary = new QuadMap<uint, uint>(); // Initialize your dictionary

var existingKey = 2u/* Create an existing key */;
var existingValue = 4u /* Create an existing value corresponding to the existing key */;

Expand Down
5 changes: 2 additions & 3 deletions unittests/Faster.Map.QuadMap.Tests/QuadMapRemoveUnitTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Faster.Map.QuadMap;
using Faster.Map.QuadMap.Tests;

namespace Faster.Map.RobinhoodMap.Tests
namespace Faster.Map.QuadMap.Tests
{
public class QuadMapRemoveUnitTests(QuadMapFixture fixture) : IClassFixture<QuadMapFixture>
{
Expand All @@ -18,7 +17,7 @@ public void Clear_RemovesAllElements()
map.Clear();

// Assert
Assert.Equal(0u, map.Count);
Assert.Equal(0u, map.Count);
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion unittests/Faster.Map.QuadMap.Tests/QuadMapStringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Text;
using System.Threading.Tasks;

namespace Faster.Map.RobinhoodMap.Tests
namespace Faster.Map.QuadMap.Tests
{
public class QuadMapStringTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Faster.Map.Core;
using Faster.Map.QuadMap;

namespace Faster.Map.RobinhoodMap.Tests
namespace Faster.Map.QuadMap.Tests
{
public class QuadMapStringWrapperTests
{
Expand All @@ -12,7 +12,7 @@ public void Emplace_StringWrapper_Should_Return_Correct_String()
// Assign
var map = new QuadMap<StringWrapper, StringWrapper>();

map.Emplace("one", "Nine");
map.Emplace("one", "Nine");

// Act
map.Get("one", out var result); ;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[assembly: CollectionBehavior(DisableTestParallelization = true)]


namespace Faster.Map.RobinhoodMap.Tests
{
public class RobinhoodBenchmarkFixture
Expand Down
26 changes: 24 additions & 2 deletions unittests/Faster.Map.RobinhoodMap.Tests/RobinhoodStringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,36 @@ public void Get_Strings_Return_Succesful(uint amount)
for (uint i = 0; i < amount; i++)
{
// Act
var result = map.Get(i.ToString(), out var _);
var result = map.Get(i.ToString(), out var x);
if (!result)
{
// Assert
Assert.Fail();
Assert.True(result, $"{x} failed");
}
}
}

[Fact]
public void Get_Strings_Return_Succesful_PartTwo()
{
for (uint i = 0; i < 1000; i++)
{
// Arrange
var map = new RobinhoodMap<string, string>();

for (uint ii = 0; ii < 1000; ii++)
{
map.Emplace(ii.ToString(), Guid.NewGuid().ToString());
}

for (uint ii = 0; ii < 1000; ii++)
{
// Act
var result = map.Get(ii.ToString(), out var x);

Assert.True(result, $"{x} failed");
}
}
}
}
}

0 comments on commit 9a535f7

Please sign in to comment.