5 entity sort = new_pure(sortlist);
11 entity Sort_New(float(entity,entity) cmp)
16 sort.sort_next = NULL;
21 void Sort_Remove(entity sort)
26 next = sort.sort_next;
33 void Sort_Add(entity sort, entity ent)
37 next = sort.sort_next;
40 if(!sort.sort_cmp(next, ent))
43 next = next.sort_next;
46 ent.sort_prev = parent;
47 parent.sort_next = ent;
52 void Sort_Reset(entity sort)
57 float Sort_HasNext(entity sort)
59 return (sort.chain.sort_next != NULL);
62 entity Sort_Next(entity sort)
65 next = sort.chain.sort_next;
68 sort.chain.sort_next = next;
69 next.sort_prev = sort.chain;
70 next.sort_next = NULL;
76 void Sort_Finish(entity sort)
85 sort = next.sort_next;
86 next.sort_next = sort.sort_next;
91 entity Sort_Get(entity sort, float i)
93 for (; sort.sort_next && i > 0; --i)
94 sort = sort.sort_next;
100 void Sort_Erase(entity ent)
102 ent.sort_prev.sort_next = ent.sort_next;
104 ent.sort_next.sort_prev = ent.sort_prev;
108 void Sort_RemoveOld(entity sort)
111 for(tmp = sort.sort_next; tmp; tmp = tmp.sort_next)
116 Sort_Erase(tmp.sort_next);