From 91da645d7140d288438655cf4a633d8c3a14dc70 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Thu, 16 Nov 2023 14:46:29 -0800 Subject: [PATCH] EXPERIMENT: try preserving order of indexable set --- src/Collections/IndexableSet.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Collections/IndexableSet.cs b/src/Collections/IndexableSet.cs index 140f9f5..6eaee89 100644 --- a/src/Collections/IndexableSet.cs +++ b/src/Collections/IndexableSet.cs @@ -61,6 +61,7 @@ namespace MoonTools.ECS.Collections return false; } + /* var index = indices[element]; if (index != Count - 1) @@ -71,6 +72,18 @@ namespace MoonTools.ECS.Collections } count -= 1; indices.Remove(element); + */ + + var index = indices[element]; + + for (var i = index; i < Count - 1; i += 1) + { + array[i] = array[i + 1]; + indices[array[i]] = i; + } + + indices.Remove(element); + count -= 1; return true; }