source: branches/libc-0.6/src/emx/include/fibheap.h

Last change on this file was 1506, checked in by bird, 21 years ago

@unixroot. header reviews. ++

  • Property cvs2svn:cvs-rev set to 1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 2.8 KB
Line 
1/* fibheap.h,v 1.2 2004/09/14 22:27:32 bird Exp */
2/** @file
3 * GNU, -liberty.
4 */
5
6/* A Fibonacci heap datatype.
7 Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
8 Contributed by Daniel Berlin (dan@cgsoftware.com).
9
10This file is part of GCC.
11
12GCC is free software; you can redistribute it and/or modify it
13under the terms of the GNU General Public License as published by
14the Free Software Foundation; either version 2, or (at your option)
15any later version.
16
17GCC is distributed in the hope that it will be useful, but
18WITHOUT ANY WARRANTY; without even the implied warranty of
19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20General Public License for more details.
21
22You should have received a copy of the GNU General Public License
23along with GCC; see the file COPYING. If not, write to
24the Free Software Foundation, 59 Temple Place - Suite 330,
25Boston, MA 02111-1307, USA. */
26
27/* Fibonacci heaps are somewhat complex, but, there's an article in
28 DDJ that explains them pretty well:
29
30 http://www.ddj.com/articles/1997/9701/9701o/9701o.htm?topic=algoritms
31
32 Introduction to algorithms by Corman and Rivest also goes over them.
33
34 The original paper that introduced them is "Fibonacci heaps and their
35 uses in improved network optimization algorithms" by Tarjan and
36 Fredman (JACM 34(3), July 1987).
37
38 Amortized and real worst case time for operations:
39
40 ExtractMin: O(lg n) amortized. O(n) worst case.
41 DecreaseKey: O(1) amortized. O(lg n) worst case.
42 Insert: O(2) amortized. O(1) actual.
43 Union: O(1) amortized. O(1) actual. */
44
45#ifndef _FIBHEAP_H_
46#define _FIBHEAP_H_
47
48#include <ansidecl.h>
49
50typedef long fibheapkey_t;
51
52typedef struct fibheap
53{
54 size_t nodes;
55 struct fibnode *min;
56 struct fibnode *root;
57} *fibheap_t;
58
59typedef struct fibnode
60{
61 struct fibnode *parent;
62 struct fibnode *child;
63 struct fibnode *left;
64 struct fibnode *right;
65 fibheapkey_t key;
66 void *data;
67 unsigned int degree : 31;
68 unsigned int mark : 1;
69} *fibnode_t;
70
71extern fibheap_t fibheap_new PARAMS ((void));
72extern fibnode_t fibheap_insert PARAMS ((fibheap_t, fibheapkey_t, void *));
73extern int fibheap_empty PARAMS ((fibheap_t));
74extern fibheapkey_t fibheap_min_key PARAMS ((fibheap_t));
75extern fibheapkey_t fibheap_replace_key PARAMS ((fibheap_t, fibnode_t,
76 fibheapkey_t));
77extern void *fibheap_replace_key_data PARAMS ((fibheap_t, fibnode_t,
78 fibheapkey_t, void *));
79extern void *fibheap_extract_min PARAMS ((fibheap_t));
80extern void *fibheap_min PARAMS ((fibheap_t));
81extern void *fibheap_replace_data PARAMS ((fibheap_t, fibnode_t, void *));
82extern void *fibheap_delete_node PARAMS ((fibheap_t, fibnode_t));
83extern void fibheap_delete PARAMS ((fibheap_t));
84extern fibheap_t fibheap_union PARAMS ((fibheap_t, fibheap_t));
85
86#endif /* _FIBHEAP_H_ */
Note: See TracBrowser for help on using the repository browser.