Doubly-linked list/Element definition: Difference between revisions

(Added Algol W)
Line 131:
 
=={{header|C}}==
It basically doesn't matter if we use the name link, node, Node or some other name. These are matters of taste and aesthetics. However, it is important that the C language is case-sensitive and that the namespace for structures is separate.
<lang c>struct linkNode
{
struct linkNode *next;
struct linkNode *prev;
void *data;
size_t type;
};</lang>
An alternative technique is to define a pointer type by typedef as shown below. The advantage here is that you do not have to write struct everywhere - assuming that you will most often need a pointer to a struct Node, not the structure itself.
<lang c>
struct Node;
typedef struct Node* Node;
struct Node
{
Node next;
Node prev;
void* data;
};
</lang>
 
=={{header|C sharp|C#}}==