6 * PCB, interactive printed circuit board design
7 * Copyright (C) 1994,1995,1996 Thomas Nau
8 * Copyright (C) 1998,1999,2000,2001 harry eaton
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 * Contact addresses for paper mail and Email:
25 * harry eaton, 6697 Buttonhole Ct, Columbia, MD 21044 USA
26 * haceaton@aplcomm.jhuapl.edu
30 /* this file, heap.h, was written and is
31 * Copyright (c) 2001 C. Scott Ananian.
34 /* prototypes for heap routines.
37 #ifndef __HEAP_INCLUDED__
38 #define __HEAP_INCLUDED__
42 /* type of heap costs */
43 typedef double cost_t
;
44 /* what a heap looks like */
45 typedef struct heap_struct heap_t
;
47 /* create an empty heap */
48 heap_t
*heap_create ();
50 void heap_destroy (heap_t
** heap
);
51 /* free all elements in a heap */
52 void heap_free (heap_t
* heap
, void (*funcfree
) (void *));
55 void heap_insert (heap_t
* heap
, cost_t cost
, void *data
);
56 void *heap_remove_smallest (heap_t
* heap
);
57 /* replace the smallest item with a new item and return the smallest item.
58 * (if the new item is the smallest, than return it, instead.) */
59 void *heap_replace (heap_t
* heap
, cost_t cost
, void *data
);
61 /* -- interrogation -- */
62 int heap_is_empty (heap_t
* heap
);
63 int heap_size (heap_t
* heap
);
65 #endif /* __HEAP_INCLUDED__ */