_info 1.2 KB

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