experiment with preserving set order

set_order
cosmonaut 2023-10-17 17:41:26 -07:00
parent 4ef7cb4302
commit 1dfa6ba4ef
1 changed files with 13 additions and 0 deletions

View File

@ -60,12 +60,25 @@ namespace MoonTools.ECS.Collections
return false;
}
/*
var lastElement = array[Count - 1];
var index = indices[element];
array[index] = lastElement;
indices[lastElement] = index;
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;
}