#if defined(LLIST_INTERFACE)
/* only the interface is generated */
-#define LLIST_FUNC(proto, ...) proto
+#define LLIST_FUNC(proto, ...) proto;
#elif defined(LLIST_IMPLEMENTATION)
/* generate a non inlined implementation */
#define LLIST_FUNC(proto, ...) proto { __VA_ARGS__ }
*/
LLIST_FUNC (LList llist_init (LList self),
return self->next = self->prev = self;
-);
+)
/**
* Check if a node is not linked with some other node.
*/
LLIST_FUNC (int llist_is_empty (const_LList self),
return self->next == self;
-);
+)
/**
* Check if self is the only node in a list or self is not in a list.
*/
LLIST_FUNC (int llist_is_single (const_LList self),
return self->next->next == self;
-);
+)
/**
* Check for the head of a list.
*/
LLIST_FUNC (int llist_is_head (const_LList self, const_LList head),
return self->next == head;
-);
+)
/**
* Check for the tail of a list.
*/
LLIST_FUNC (int llist_is_tail (const_LList self, const_LList tail),
return self->prev == tail;
-);
+)
/**
* Check for the end of a list.
*/
LLIST_FUNC (int llist_is_end (const_LList self, const_LList end),
return self == end;
-);
+)
/**
* Check if a node is a member of a list.
return 1;
}
return 0;
-);
+)
/**
* Check the order of elements in a list.
return 1;
}
return 0;
-);
+)
/**
* Count the nodes of a list.
const_LList i = self;
for (; i->next != self; ++cnt, i = i->next);
return cnt;
-);
+)
/* private, unlink self some any list but leaves self in a uninitialized state */
LLIST_FUNC (void llist_unlink_fast_ (LList self),
LList nxt = self->next, pre = self->prev;
nxt->prev = pre;
pre->next = nxt;
-);
+)
/**
* Remove a node from a list.
LLIST_FUNC (LList llist_unlink (LList self),
llist_unlink_fast_ (self);
return self->next = self->prev = self;
-);
+)
/**
* Fix a node which got relocated in memory.
*/
LLIST_FUNC (LList llist_relocate (LList self),
return self->next->prev = self->prev->next = self;
-);
+)
/**
next->next = self->next;
self->next = next;
return self;
-);
+)
/**
* Insert a node before another.
prev->prev = self->prev;
self->prev = prev;
return self;
-);
+)
/**
next->prev = next->next = next;
}
return self;
-);
+)
/**
* Move the content of a list before a node in another list.
prev->prev = prev->next = prev;
}
return self;
-);
+)
#if 0 //BUG("needs temporary")
/**
self->next = start;
start->prev = self;
return self;
-);
+)
#endif
#if 0 //BUG("needs temporary")
self->prev = end->prev;
end->prev->next = self;
return self;
-);
+)
#endif
/**
self->next->next = self;
self->next = tmp;
return self;
-);
+)
/**
* Swap a node with its previous node.
self->prev->prev = self;
self->prev = tmp;
return self;
-);
+)
/**
*/
LLIST_FUNC (LList llist_next (const_LList self),
return self->next;
-);
+)
/**
* Get previous node.
*/
LLIST_FUNC (LList llist_prev (const_LList self),
return self->prev;
-);
+)
/**
* Advance a pointer to a node to its next node.
*/
LLIST_FUNC (void llist_forward (LList_ref self),
*self = (*self)->next;
-);
+)
/**
* Retreat a pointer to a node to its previous node.
*/
LLIST_FUNC (void llist_backward (LList_ref self),
*self = (*self)->prev;
-);
+)
/**
* Get the nth element of a list.
while (n++)
self = llist_prev (self);
return self;
-);
+)
/**
* Get the nth element of a list with a stop node.
return NULL;
}
return self;
-);
+)
/**