4.1.6 Get rest

This function is a little difficult to implement because in this implementation (using an array), there is no explicit ``rest'' in the data structure. Consequently, the prototype will look like the following:

struct List *List_getrest(struct List *pOrig, struct List *pRest);

The caller must allocate for and pass the parameter pRest as follows:

struct List *theRest;
// the list to process is given as pList
theRest = List_new();
List_getrest(pList, theRest);
// do something with ``theRest''
free(theRest); // remember to deallocate the list

The implementation is as follows:

struct List *List_getrest(struct List *pOrig, struct List *pRest)
{
  *((struct _List *)pRest) = *((struct _List *)pOrig);
  ((struct _List *)pRest)->index++;
  return pRest;
}



Copyright © 2006-09-27 by Tak Auyeung