home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_08 / ramey.exe / STACK.H < prev    next >
C/C++ Source or Header  |  1991-10-14  |  1KB  |  59 lines

  1. /*
  2. Postman's Sort (R) Version 1.0
  3. Copyright (c) Robert Ramey 1991. All Rights Reserved
  4. */
  5.  
  6. #ifndef TRUE
  7. #define TRUE 1
  8. #endif
  9. #ifndef FALSE
  10. #define FALSE 0
  11. #endif
  12.  
  13. /*********************************************************************
  14. data structure for memory blocks used to hold records in memory
  15. after they have been read until the space is needed for something else.
  16. **********************************************************************/
  17. typedef struct {
  18.     unsigned int count;
  19.     size_t size;
  20. } STK_BLK;
  21.  
  22. typedef struct {
  23.     STK_BLK current;    /* end of stack */
  24.     STK_BLK pushed;        /* last saved frame of stack */
  25.     STK_BLK previous;    /* previous end of stack */
  26.     unsigned int frame_count;
  27. } STACK;
  28.  
  29.  
  30. /* commented out as these are implemented as macros */
  31. /*
  32. size_t
  33. stk_avl(STACK *);
  34. unsigned int
  35. stk_blks(STACK *);
  36. */
  37. unsigned int
  38. stk_unused();
  39. char *
  40. stk_end(STACK *);
  41. void
  42. stk_windup();
  43. unsigned int
  44. stk_init(size_t, unsigned int);
  45. void
  46. stk_free(STACK *);
  47. STACK *
  48. stk_alloc();
  49. void *
  50. stk_space(STACK *, unsigned int);
  51. void
  52. stk_drop(STACK *);
  53. int
  54. stk_push(STACK *);
  55. int
  56. stk_pop(STACK *);
  57. #define stk_blks(stk) (stk->current.count)
  58. #define stk_avl(stk) (stk_blks(stk) ? stk->current.size : 0)
  59.