Navit SVN

/work/compile/navit/src/navit/fib-1.1/fibpriv.h

00001 /*-
00002  * Copyright 1997, 1999-2003 John-Mark Gurney.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  *
00014  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
00015  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00017  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
00018  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00019  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00020  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00021  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00022  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00023  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00024  * SUCH DAMAGE.
00025  *
00026  *      $Id: fibpriv.h,v 1.1 2005-12-02 10:41:56 martin-s Exp $
00027  *
00028  */
00029 
00030 #ifndef _FIBPRIV_H_
00031 #define _FIBPRIV_H_
00032 
00033 struct fibheap_el;
00034 
00035 /*
00036  * global heap operations
00037  */
00038 struct fibheap {
00039         int     (*fh_cmp_fnct)(void *, void *);
00040         int     fh_n;
00041         int     fh_Dl;
00042         struct  fibheap_el **fh_cons;
00043         struct  fibheap_el *fh_min;
00044         struct  fibheap_el *fh_root;
00045         void    *fh_neginf;
00046         int     fh_keys         : 1;
00047 #ifdef FH_STATS
00048         int     fh_maxn;
00049         int     fh_ninserts;
00050         int     fh_nextracts;
00051 #endif
00052 };
00053 
00054 static void fh_initheap(struct fibheap *);
00055 static void fh_insertrootlist(struct fibheap *, struct fibheap_el *);
00056 static void fh_removerootlist(struct fibheap *, struct fibheap_el *);
00057 static void fh_consolidate(struct fibheap *);
00058 static void fh_heaplink(struct fibheap *h, struct fibheap_el *y,
00059                         struct fibheap_el *x);
00060 static void fh_cut(struct fibheap *, struct fibheap_el *, struct fibheap_el *);
00061 static void fh_cascading_cut(struct fibheap *, struct fibheap_el *);
00062 static struct fibheap_el *fh_extractminel(struct fibheap *);
00063 static void fh_checkcons(struct fibheap *h);
00064 static void fh_destroyheap(struct fibheap *h);
00065 static int fh_compare(struct fibheap *h, struct fibheap_el *a,
00066                         struct fibheap_el *b);
00067 static int fh_comparedata(struct fibheap *h, int key, void *data,
00068                         struct fibheap_el *b);
00069 static void fh_insertel(struct fibheap *h, struct fibheap_el *x);
00070 static void fh_deleteel(struct fibheap *h, struct fibheap_el *x);
00071 
00072 /*
00073  * specific node operations
00074  */
00075 struct fibheap_el {
00076         int     fhe_degree;
00077         int     fhe_mark;
00078         struct  fibheap_el *fhe_p;
00079         struct  fibheap_el *fhe_child;
00080         struct  fibheap_el *fhe_left;
00081         struct  fibheap_el *fhe_right;
00082         int     fhe_key;
00083         void    *fhe_data;
00084 };
00085 
00086 static struct fibheap_el *fhe_newelem(void);
00087 static void fhe_initelem(struct fibheap_el *);
00088 static void fhe_insertafter(struct fibheap_el *a, struct fibheap_el *b);
00089 static void fhe_insertbefore(struct fibheap_el *a, struct fibheap_el *b);
00090 static struct fibheap_el *fhe_remove(struct fibheap_el *a);
00091 #define fhe_destroy(x)  free((x))
00092 
00093 /*
00094  * general functions
00095  */
00096 static int ceillog2(unsigned int a);
00097 
00098 #endif /* _FIBPRIV_H_ */