pqueue.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* Priority queue functions.
  2. Copyright (C) 2003 Yasuhiro Ohara
  3. This file is part of GNU Zebra.
  4. GNU Zebra is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 2, or (at your
  7. option) any later version.
  8. GNU Zebra is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Zebra; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA. */
  16. #ifndef _ZEBRA_PQUEUE_H
  17. #define _ZEBRA_PQUEUE_H
  18. struct pqueue
  19. {
  20. void **array;
  21. int array_size;
  22. int size;
  23. int (*cmp) (void *, void *);
  24. void (*update) (void * node, int actual_position);
  25. };
  26. #define PQUEUE_INIT_ARRAYSIZE 32
  27. extern struct pqueue *pqueue_create (void);
  28. extern void pqueue_delete (struct pqueue *queue);
  29. extern void pqueue_enqueue (void *data, struct pqueue *queue);
  30. extern void *pqueue_dequeue (struct pqueue *queue);
  31. extern void pqueue_remove_at (int index, struct pqueue *queue);
  32. extern void trickle_down (int index, struct pqueue *queue);
  33. extern void trickle_up (int index, struct pqueue *queue);
  34. #endif /* _ZEBRA_PQUEUE_H */