/*
 * DoublyLinkedList - A doubly linked list to contain values of type E which
 * can be cast from any other primitive type.
 *
 *  Created on: Feb 24, 2009
 *      Author: Yama H
 */

/*
 * E's are long doubles because they allocate the most space of all primitive
 * types, therefore ensuring enough space for any other type that could be
 * cast into it.
 */
typedef long double E;
/*
 * A DLLNode (DoublyLinkedListNode) consists of a piece of data of type E
 * (which is really usually some other type cast into an E, and can also be a
 * pointer) and pointers to the next and previous DLLNodes in the list (NULL
 * if the node is a head or tail node.
 */
typedef struct
{
	E data;
	void* next;
	void* prev;
}DLLNode;
/*
 * A DoublyLinkedList is just a head Node, a pointer to a tail node, and an int
 * representing the amount of elements in the list. The head node is not a
 * pointer because it's value never changes unless the list is emptied.
 */
typedef struct
{
	DLLNode head;	// the head isn't a pointer, but the tail is,
	DLLNode* tail;	// because the head is static and the tail is dynamic
	int elements;
}DoublyLinkedList;

/*
 * Initializes List and creates first node.
 */
void DoublyLinkedList_initialize(DoublyLinkedList* dll, E data);
/*
 * Initializes an empty List.
 */
void DoublyLinkedList_init(DoublyLinkedList* dll);
/*
 * Retrieves the data from the node passed.
 */
E DoublyLinkedList_getData(DLLNode node);
/*
 * Retrives the node after the current node. Returns the parameter if the
 * current node is the last entry (the tail).
 */
DLLNode DoublyLinkedList_getNext(DLLNode node);
/*
 * Retrieves the node before the current node. Returns the parameter if the
 * current node is the first entry (the head).
 */
DLLNode DoublyLinkedList_getPrev(DLLNode node);
/*
 * Sets the data in a specified node in the list to a specified value, and
 * updates the node passed in. Nonzero on failure.
 */
int DoublyLinkedList_setData(DoublyLinkedList* dll, DLLNode* node, E data);
/*
 * Adds an entry to the List.
 */
void DoublyLinkedList_addEntry(DoublyLinkedList* dll, E data);
/*
 * Removes an entry from the list. Nonzero if list is empty.
 */
int DoublyLinkedList_removeEntry(DoublyLinkedList* dll);
/*
 * Retrieves the head node.
 */
DLLNode DoublyLinkedList_getHead(DoublyLinkedList* dll);
/*
 * Retrieves the tail node.
 */
DLLNode DoublyLinkedList_getTail(DoublyLinkedList* dll);
/*
 * Returns 1 if node1 is identical to node2 and 0 if not.
 */
int DoublyLinkedList_equals(DLLNode node1, DLLNode node2);
/*
 * Returns the number of elements currently in the list.
 */
int DoublyLinkedList_getElements(DoublyLinkedList* dll);

    Source: geocities.com/yamzta333/DLL

               ( geocities.com/yamzta333)