4.3.2 Creation

An empty list is represented by a NULL value in the first data member. This is represented graphically by figure 2.

Figure 2: The graphical representation of an empty list.
\includegraphics{emptylist}

The implementation is as follows:

struct List *List_new(void)
{
  struct _List *tmp;

  tmp = (struct _List *)malloc(sizeof(struct _List));
  tmp->first = NULL;
  return (struct List *)tmp;
}



Copyright © 2006-09-27 by Tak Auyeung