Skip to content

Commit

Permalink
fix: Removes broken OrderedHashSet and adds a simple OrderedSet (#1756)
Browse files Browse the repository at this point in the history
> [!CAUTION]
> **BREAKING CHANGE**
> Removed `OrderdHashSet` and `PooledOrderedHashSet` due to bugs.

> [!NOTE]
> **Developer Note**
> The OrderedSet is not a full data structure. It is not particularly efficient. Pull Requests are welcome for a better implementation, especially if it ends up supporting `ISet<T>` and `IReadOnlySet<T>`

## Summary

The ordered hash set was buggy. It's kind of painful to implement, so for now, I added a simple `OrderedSet` to suffice for gumps. Please reach out if this causes disruption!
  • Loading branch information
kamronbatman committed May 4, 2024
1 parent dc118d8 commit 4ea1d79
Show file tree
Hide file tree
Showing 30 changed files with 121 additions and 1,258 deletions.
46 changes: 0 additions & 46 deletions Projects/Server.Tests/Tests/Collections/OrderedHashSetTests.cs

This file was deleted.

29 changes: 29 additions & 0 deletions Projects/Server.Tests/Tests/Collections/OrderedSetTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Server.Collections;
using Xunit;

namespace Server.Tests;

public class OrderedSetTests
{
[Fact]
public void TestOrderedSet()
{
int[] expected = [6, 2, 4, 23, 0];
var set = new OrderedSet<int>();
for (var i = 0; i < expected.Length; i++)
{
set.Add(expected[i]);
}

Assert.Equal(expected.Length, set.Count);

Assert.True(set.Contains(4));
Assert.False(set.Contains(8));

int index = 0;
foreach (var value in set)
{
Assert.Equal(expected[index++], value);
}
}
}

0 comments on commit 4ea1d79

Please sign in to comment.