/*
 * Faculty of Applied Science and Engineering, University of Toronto
 * CSC181: Introduction to Computer Programming, Fall 2000
 *
 * Assignment: 3
 * File: list.h
 * Author: Ray Ortigas (rayo@dgp.toronto.edu)
 * Contains: Typedefs and function prototypes for List module.
 */

/*
 * Represents a node in a singly-linked list.
 */
struct listnode {

	/* The data stored in this node. */
	void* data;

	/* The node following this node. */
	struct listnode* next;
};
typedef struct listnode ListNode;
typedef ListNode* ListNodePtr;

/*
 * Represents a list. Implemented using a linked structure of ListNodes.
 */
struct list {

	/* The node at the front of this list. If it is NULL, then the list 
	   is empty. */
	ListNode* front;

	/* The size of this list. */
	int size;
};
typedef struct list List;
typedef List* ListPtr;

/* Returns an empty list. */
ListPtr listInit(void);

/* Returns the size of the given list. */
int listSize(const ListPtr l);

/* Returns the element at index i in list l. The given index must be
   between 0 and n-1 inclusive, where n is the size of the list. */
void* listGet(const ListPtr l, const int i);

/* Adds element d to list l, making it the last element. */
void listAppend(ListPtr l, void* d);
