2016-03-02 16:18:10 +00:00
|
|
|
/*
|
|
|
|
* Mr. 4th Dimention - Allen Webster
|
|
|
|
*
|
|
|
|
* 01.03.2016
|
|
|
|
*
|
|
|
|
* Templated code.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// TOP
|
|
|
|
|
|
|
|
// NOTE(allen): This is an experiment, BUT remember a lot of people shit on templates.
|
|
|
|
// So if you start getting a wiff of stupidity from this back out immediately!
|
2016-03-04 06:06:11 +00:00
|
|
|
//
|
|
|
|
// experience 1: no badness, haven't seen any anoying template errors
|
|
|
|
// ...
|
2016-03-02 16:18:10 +00:00
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
inline void
|
|
|
|
dll_init_sentinel(T *sentinel){
|
|
|
|
sentinel->next = sentinel;
|
|
|
|
sentinel->prev = sentinel;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
inline void
|
|
|
|
dll_insert(T *pos, T *v){
|
|
|
|
v->next = pos->next;
|
|
|
|
v->prev = pos;
|
|
|
|
pos->next = v;
|
|
|
|
v->next->prev = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
inline void
|
|
|
|
dll_remove(T *v){
|
|
|
|
v->next->prev = v->prev;
|
|
|
|
v->prev->next = v->next;
|
|
|
|
}
|
|
|
|
|
2016-03-04 06:06:11 +00:00
|
|
|
// for(dll_items(iterator, sentinel_ptr)){...}
|
2016-03-02 16:18:10 +00:00
|
|
|
#define dll_items(it, st) ((it) = (st)->next); ((it) != (st)); ((it) = (it)->next)
|
|
|
|
|
|
|
|
// BOTTOM
|
|
|
|
|