monotonic_queue.h 679 B

12345678910111213141516171819202122232425
  1. #ifndef _JUMP_MONOTONIC_QUEUE_H
  2. #define _JUMP_MONOTONIC_QUEUE_H 1
  3. #define MONOTONIC_QUEUE_CAP 80
  4. typedef int (*monotonic_queue_cmp)(float, float);
  5. struct monotonic_queue
  6. {
  7. monotonic_queue_cmp cmp;
  8. float buf[MONOTONIC_QUEUE_CAP];
  9. int h, h_min, t;
  10. int len;
  11. };
  12. extern void monotonic_queue_init(struct monotonic_queue *mq,
  13. monotonic_queue_cmp cmp);
  14. extern int monotonic_queue_push(struct monotonic_queue *mq, float value);
  15. extern int monotonic_queue_pop(struct monotonic_queue *mq);
  16. extern int monotonic_queue_get_min(struct monotonic_queue *mq, float *dest);
  17. extern int monotonic_queue_get_len(struct monotonic_queue *mq);
  18. #endif
  19. /* vim: set ts=8 sw=8 sts=8 noet: */