home *** CD-ROM | disk | FTP | other *** search
/ Really Useful CD 1 / ReallyUsefulCD1.iso / extras / progutils / c_utils / h / bag next >
Encoding:
Text File  |  1989-04-02  |  1.2 KB  |  47 lines

  1. /*      > H.Bag - Bag data type header file */
  2.  
  3. #ifndef __bag_h
  4.  
  5. #define __bag_h
  6.  
  7. struct bag
  8. {
  9.         void *first;    /* pointer to first element of bag */
  10.         int obj_size;   /* size of one element */
  11. };
  12.  
  13. typedef struct bag *bag;
  14.  
  15. /* General component routines */
  16.  
  17. bag bag_new (int obj_len);
  18. void bag_free (bag b);
  19. void bag_clear (bag b);
  20. int bag_copy (bag b1, const bag b2);
  21. int bag_equal (const bag b1, const bag b2);
  22. int bag_empty (const bag b);
  23. int bag_size (const bag b);
  24.  
  25. /* Iterator */
  26.  
  27. #define STATUS_CONTINUE 0       /* Continue processing */
  28. #define STATUS_STOP     1       /* Stop processing */
  29. #define STATUS_ERROR    (-1)    /* Error - terminate */
  30.  
  31. int bag_iterate (const bag b, int (*process)(void *, int));
  32.  
  33. /* Bag-specific routines */
  34.  
  35. int bag_add (bag b, const void *object);
  36. int bag_remove (bag b, const void *object);
  37. int bag_member (const bag b, const void *object);
  38. int bag_count (const bag b, const void *object);
  39. int bag_union (bag b1, const bag b2, const bag b3);
  40. int bag_intersection (bag b1, const bag b2, const bag b3);
  41. int bag_difference (bag b1, const bag b2, const bag b3);
  42. int bag_unique_count (const bag b);
  43. int bag_subset (const bag b1, const bag b2);
  44. int bag_proper_subset (const bag b1, const bag b2);
  45.  
  46. #endif
  47.