Description
1 Requirements
This lab is intended to test your ability to work with abstract data types and interface functions. You will
not be provided with a main file in your starter code, and any testing code you produce will not be graded.
In this lab, you will produce a set of interface functions for a list type which starts at index 0.
typedef struct {
void ** array ;
int size ;
int maxSize ;
} List ;
1.1 initList
List * initList (int maxSize ) ;
Info: This function initializes and returns a List with the specified maxSize.
i
1.2 getSize
int getSize ( List * list );
Info: This function takes a List and returns the number of elements on the list.
i
1.3 freeList
void freeList ( List * list ) ;
Info: This function takes a List and frees all memory allocated by the init function.
i
1.4 getAtIndex
void * getAtIndex ( List * list , int index ) ;
Info: This function takes a List and returns the object at the given index, or NULL on error.
i
1.5 insertAtTail
int insertAtTail ( List * list , void * object ) ;
Info: This function takes a List and attempts to insert the given object at the end of the list. It should
return 1 on success and 0 on failure.
i
1
1.6 isEmpty
int isEmpty ( List * list );
Info: This function takes a List and returns 1 if the list is empty, or 0 if it is not.
i
1.7 listContains
int listContains ( List * list , void * object ) ;
Info: This function takes a List and returns 1 if the given object is on the list, or 0 otherwise.
i
1.8 removeFromHead
void * removeFromHead ( List * list ) ;
Info: This function takes a List and removes the object at the start of the list. This function must
return the object to the user.
i
2 Notice
Grading: Total 25 points
1. Write required init function
* 4 points
2. Write required get size function
* 1 point
3. Write required free list function
* 2 points
4. Write required get at index function
* 2 points
5. Write required insert function
* 5 points
6. Write required remove function
* 5 points
7. Write required isEmpty function
* 2 points
8. Write required listContains function
* 4 points
!
2
Notice:
1. All of your lab submissions must compile under GCC using the −W all and −W error flags to be
considered for a grade.
2. You are expected to provide proper documentation in every lab submission, in the form of
code comments. For an example of proper lab documentation and a clear description of our
expectations, see the lab policy document.