/* ECP: FILEname=fig10_16.c */ /* 1*/ typedef SortedInts QuEtype; /* 2*/ typedef struct QueueStr /* 3*/ { /* 4*/ QuEtype *Array; /* The Array Of Elements */ /* 5*/ int Front; /* Index Of Front Element */ /* 6*/ int Back; /* Index Of Back Element */ /* 7*/ int Size; /* Current Number Of Elements in Queue */ /* 8*/ int MaxSize; /* Maximum Queue Qize */ /* 9*/ } *Queue; /*10*/ static const QuInitSize = 5; /* 1*/ Queue /* 2*/ QuMakeEmpty( Queue Q ) /* 3*/ { /* 4*/ if( Q == NULL ) /* 5*/ { /* 6*/ if( ! ( Q = malloc( sizeof( struct QueueStr ) ) ) ) /* 7*/ return NULL; /* 8*/ Q->Array = malloc( sizeof( QuEtype ) * QuInitSize ); /* 9*/ if( Q->Array == NULL ) /*10*/ return NULL; /*11*/ Q->MaxSize = QuInitSize; /*12*/ } /*13*/ Q->Size = 0; /*14*/ Q->Front = 0; /*15*/ Q->Back = -1; /*16*/ return Q; /*17*/ }