implemented doubly linked list
This commit is contained in:
@@ -13,7 +13,7 @@ static const Array(u32) __HashMap_heights = ARRAY(u32, {
|
||||
});
|
||||
|
||||
|
||||
void HashMap_construct_size(HashMap_* self, u32 value_t_size, FreeFunction NULLABLE(value_destructor)){
|
||||
void HashMap_construct_size(HashMap_* self, u32 value_t_size, Destructor_t NULLABLE(value_destructor)){
|
||||
self->value_t_size = value_t_size;
|
||||
self->value_destructor = value_destructor;
|
||||
self->height_n = 0;
|
||||
|
||||
58
src/collections/LList.c
Normal file
58
src/collections/LList.c
Normal file
@@ -0,0 +1,58 @@
|
||||
#include "tlibc/collections/LList.h"
|
||||
|
||||
LLNode_* _LList_detatch(LList_* l, LLNode_* n){
|
||||
if(n == l->first){
|
||||
l->first = n->next;
|
||||
}
|
||||
else {
|
||||
assert(n->prev != NULL);
|
||||
n->prev->next = n->next;
|
||||
}
|
||||
|
||||
if(n == l->last){
|
||||
l->last = n->prev;
|
||||
}
|
||||
else {
|
||||
assert(n->next != NULL);
|
||||
n->next->prev = n->prev;
|
||||
}
|
||||
|
||||
l->count--;
|
||||
n->prev = NULL;
|
||||
n->next = NULL;
|
||||
return n;
|
||||
}
|
||||
|
||||
void _LList_insertAfter(LList_* l, NULLABLE(LLNode_*) target, LLNode_* detatched)
|
||||
{
|
||||
if(target == NULL){
|
||||
assert(l->first == NULL && l->last == NULL);
|
||||
l->first = detatched;
|
||||
l->last = detatched;
|
||||
return;
|
||||
}
|
||||
|
||||
detatched->prev = target;
|
||||
detatched->next = target->next;
|
||||
target->next = detatched;
|
||||
if(detatched->next){
|
||||
detatched->next->prev = detatched;
|
||||
}
|
||||
}
|
||||
|
||||
void _LList_insertBefore(LList_* l, NULLABLE(LLNode_*) target, LLNode_* detatched)
|
||||
{
|
||||
if(target == NULL){
|
||||
assert(l->first == NULL && l->last == NULL);
|
||||
l->first = detatched;
|
||||
l->last = detatched;
|
||||
return;
|
||||
}
|
||||
|
||||
detatched->prev = target->prev;
|
||||
detatched->next = target;
|
||||
target->prev = detatched;
|
||||
if(detatched->prev){
|
||||
detatched->prev->next = detatched;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user