source: trunk/src/emx/include/fibheap.h@ 346

Last change on this file since 346 was 123, checked in by zap, 22 years ago

Started the work for re-designing the EMX C runtime library to not require
EMX.DLL. The new design is projected to be as follows:

  • all emx syscalls are replaced with the routines from the old sys.lib library which is now compilable in both a.out and OMF formats.
  • the sys.a library should be made replaceable and selectable by some gcc switch (e.g. -msyslib=emx would link with emx.a instead of sys.a which would give almost full backward compatibility with emx).
  • All C functions names were renamed to not contain the starting underscore (e.g. fopen and not _fopen). The underscored aliases will be added later with the c_alias library (which will be generated automatically from all public symbols of libc; any exported symbol that do not start with an underscore will be given an underscored alias unless such a symbol is already defined).

Also a lot of updates to the building system. It is now much faster (thanks
to Knut's suggestion of using ash's builtin echo).
Also re-wrote thunk1.asm and thunk2.asm to GAS format; this removes the need
for MASM and makes it possible to use 16-bit functions in a.out programs
without the need for EMX.DLL.
Also made a lot of small changes I don't remember now.

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