Lists in Static Arrays
Lists in Static Arrays
- Structure of list:
typedef struct list { int count; ListEntry entry[MAXLIST];} List;List this_list;
- List routines don’t need to know what’s in ListEntry type
- Counter and maximum size are relevant to list routines
- this_list.entry[0] is first entry, this_list.entry[1] is second entry, …this_list.entry[this_list.count-1] is last entry
- Main program header life2.h (also included in list routines) defines contents of ListEntry :
typedef struct cell { int row, col; /* grid coordinate */} Cell;typedef Cell ListEntry;
CMPS012B Spring '97 pages maintained by
Mike Goss <goss@cse.ucsc.edu>