MD_NodeTable_Insert preserve order

This commit is contained in:
ryanfleury
2021-01-29 12:18:56 -07:00
parent 8a09a5c315
commit e8af78ed4c
2 changed files with 31 additions and 17 deletions
+16 -2
View File
@@ -974,8 +974,22 @@ MD_NodeTable_Insert(MD_NodeTable *table, MD_NodeTableCollisionRule collision_rul
slot = _MD_PushArray(_MD_GetCtx(), MD_NodeTableSlot, 1);
if(slot)
{
slot->next = table->table[index];
table->table[index] = slot;
slot->next = 0;
if(table->table[index])
{
for(MD_NodeTableSlot *old_slot = table->table[index]; old_slot; old_slot = old_slot->next)
{
if(old_slot->next == 0)
{
old_slot->next = slot;
break;
}
}
}
else
{
table->table[index] = slot;
}
}
}