Doubly-linked list/Element definition

From Rosetta Code
Revision as of 02:29, 8 May 2007 by rosettacode>Jrslepak (Started the double-linked list page, using single-linked list as model.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Task
Doubly-linked list/Element definition
You are encouraged to solve this task according to the task description, using any language you may know.

Define the data structure for a doubly-linked list element. The element should include a data member to hold its value and pointers to both the next element in the list and the previous element in the list. The pointers should be mutable.

C

struct link {
  struct * link next;
  struct * link prev;
  int data;
};