home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include "q2.h"
-
- #define LOOPS 20
-
- main()
- {
- int i;
- int k;
- qele_type next;
- qele_type rval;
-
- /* initialization */
- srand(12);
- qele_cpy(next,q_NIL);
-
- for (i=0; i<LOOPS; i++){
- k = rand();
- k &= q_WRAP;
- printf("\n%d positions unused",q_free());
- printf("\nInserting %d items starting with %d",k,next);
- while (k--){
- if (q_put(next) == FULL) {
- printf("\nQueue full");
- break;
- }
- else
- qele_incr(next);
- }
- k = rand();
- k &= q_WRAP;
- printf("\n%d positions used",q_bsy());
- printf("\nRemoving %d items ",k);
- while (k--){
- if ((rval = q_get()) == EMPTY){
- printf("\nQueue Empty");
- break;
- }
- else printf("\n %d",rval);
- }
- }
- }
-