_info 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "config.h"
  2. #include <stdio.h>
  3. #include <string.h>
  4. /**
  5. * heap - a simple heap implementation
  6. *
  7. * Each heap entry is added as a void pointer. This means the implementation
  8. * does _not_ assume you already have an array of entries. Instead, it keeps
  9. * an internal array of pointers to those entries.
  10. *
  11. * Example:
  12. * #include <stdio.h>
  13. *
  14. * #include <ccan/heap/heap.h>
  15. *
  16. * static bool less(const int *i, const int *j)
  17. * {
  18. * return *i < *j;
  19. * }
  20. *
  21. * static bool __less(const void *i, const void *j)
  22. * {
  23. * return less(i, j);
  24. * }
  25. *
  26. * int main(int argc, char *argv[])
  27. * {
  28. * struct heap *h;
  29. * int arr[] = {1, 0, 2};
  30. * int i;
  31. *
  32. * h = heap_init(__less);
  33. * if (h == NULL) {
  34. * perror("heap alloc");
  35. * exit(1);
  36. * }
  37. *
  38. * for (i = 0; i < 3; i++) {
  39. * if (heap_push(h, &arr[i])) {
  40. * perror("heap push");
  41. * exit(1);
  42. * }
  43. * }
  44. * // should print 0, 1, 2
  45. * for (i = 0; i < 3; i++) {
  46. * int *v = heap_pop(h);
  47. * printf("%d\n", *v);
  48. * }
  49. * heap_free(h);
  50. * return 0;
  51. * }
  52. *
  53. * License: BSD-MIT
  54. * Author: Emilio G. Cota <cota@braap.org>
  55. */
  56. int main(int argc, char *argv[])
  57. {
  58. /* Expect exactly one argument */
  59. if (argc != 2)
  60. return 1;
  61. if (strcmp(argv[1], "depends") == 0) {
  62. return 0;
  63. }
  64. return 1;
  65. }