mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Grid2D: use ISet<T> instead of HashSet<T> to support SortedSet<T>
This commit is contained in:
parent
da367c7bb9
commit
8d98a42ab6
@ -50,7 +50,7 @@ public void Add(Vector2Int position, T value)
|
||||
// -> result is passed as parameter to avoid allocations
|
||||
// -> result is not cleared before. this allows us to pass the HashSet from
|
||||
// GetWithNeighbours and avoid .UnionWith which is very expensive.
|
||||
void GetAt(Vector2Int position, HashSet<T> result)
|
||||
void GetAt(Vector2Int position, ISet<T> result)
|
||||
{
|
||||
// return the set at position
|
||||
if (grid.TryGetValue(position, out HashSet<T> hashSet))
|
||||
@ -62,7 +62,8 @@ void GetAt(Vector2Int position, HashSet<T> result)
|
||||
|
||||
// helper function to get at position and it's 8 neighbors without worrying
|
||||
// -> result is passed as parameter to avoid allocations
|
||||
public void GetWithNeighbours(Vector2Int position, HashSet<T> result)
|
||||
// -> ISet so it works with both HashSet and SortedSet.
|
||||
public void GetWithNeighbours(Vector2Int position, ISet<T> result)
|
||||
{
|
||||
// clear result first
|
||||
result.Clear();
|
||||
|
Loading…
Reference in New Issue
Block a user