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
@@ -25,21 +25,6 @@
</div>
<div class="page_content">
<h1 class="title">Blog</h1><input autofocus id="lister_search_0" class="lister_search" oninput="SearchInput(event, 0)" onkeydown="SearchKeyDown(event, 0)" placeholder="Filter..."></input><ul id="lister_0" class="lister">
<a class="lister_item_link" href="blog2.html">
<li class="lister_item">
<div class="lister_item_text">
<div class="lister_item_title">
Hello, Again!
</div>
<div class="lister_item_date">
28 November 2020
</div>
<div class="lister_item_desc">
This is another test blog.
</div>
</div>
</a>
</li>
<a class="lister_item_link" href="blog1.html">
<li class="lister_item">
<div class="lister_item_text">
@@ -55,6 +40,21 @@ This is my test blog.
</div>
</a>
</li>
<a class="lister_item_link" href="blog2.html">
<li class="lister_item">
<div class="lister_item_text">
<div class="lister_item_title">
Hello, Again!
</div>
<div class="lister_item_date">
28 November 2020
</div>
<div class="lister_item_desc">
This is another test blog.
</div>
</div>
</a>
</li>
</ul>
</div>
+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;
}
}
}