Linked lists

suggest change

The C language does not define a linked list data structure. If you are using C and need a linked list, you either need to use a linked list from an existing library (such as GLib) or write your own linked list interface. This topic shows examples for linked lists and double linked lists that can be used as a starting point for writing your own linked lists.

Singly linked list

The list contains nodes which are composed of one link called next.

Data structure

struct singly_node
{
  struct singly_node * next;
};

Doubly linked list

The list contains nodes which are composed of two links called previous and next. The links are normally referencing to a node with the same structure.

Data structure

struct doubly_node
{
  struct doubly_node * prev;
  struct doubly_node * next;
};
void doubly_node_make_empty_linear_list (struct doubly_node * head, struct doubly_node * tail)
{
  head->prev = NULL;
  tail->next = NULL;
  doubly_node_bind (head, tail);
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents