CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
95 lines
2.9 KiB
C
95 lines
2.9 KiB
C
/* A Fibonacci heap datatype.
|
|
Copyright (C) 1998-2024 Free Software Foundation, Inc.
|
|
Contributed by Daniel Berlin (dan@cgsoftware.com).
|
|
|
|
This file is part of GCC.
|
|
|
|
GCC is free software; you can redistribute it and/or modify it
|
|
under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
any later version.
|
|
|
|
GCC is distributed in the hope that it will be useful, but
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with GCC; see the file COPYING. If not, write to
|
|
the Free Software Foundation, 51 Franklin Street - Fifth Floor,
|
|
Boston, MA 02110-1301, USA. */
|
|
|
|
/* Fibonacci heaps are somewhat complex, but, there's an article in
|
|
DDJ that explains them pretty well:
|
|
|
|
http://www.ddj.com/articles/1997/9701/9701o/9701o.htm?topic=algoritms
|
|
|
|
Introduction to algorithms by Corman and Rivest also goes over them.
|
|
|
|
The original paper that introduced them is "Fibonacci heaps and their
|
|
uses in improved network optimization algorithms" by Tarjan and
|
|
Fredman (JACM 34(3), July 1987).
|
|
|
|
Amortized and real worst case time for operations:
|
|
|
|
ExtractMin: O(lg n) amortized. O(n) worst case.
|
|
DecreaseKey: O(1) amortized. O(lg n) worst case.
|
|
Insert: O(2) amortized. O(1) actual.
|
|
Union: O(1) amortized. O(1) actual. */
|
|
|
|
#ifndef _FIBHEAP_H_
|
|
#define _FIBHEAP_H_
|
|
|
|
#include "ansidecl.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef long fibheapkey_t;
|
|
|
|
typedef struct fibheap
|
|
{
|
|
size_t nodes;
|
|
struct fibnode *min;
|
|
struct fibnode *root;
|
|
} *fibheap_t;
|
|
|
|
typedef struct fibnode
|
|
{
|
|
struct fibnode *parent;
|
|
struct fibnode *child;
|
|
struct fibnode *left;
|
|
struct fibnode *right;
|
|
fibheapkey_t key;
|
|
void *data;
|
|
#if defined (__GNUC__) && (!defined (SIZEOF_INT) || SIZEOF_INT < 4)
|
|
__extension__ unsigned long int degree : 31;
|
|
__extension__ unsigned long int mark : 1;
|
|
#else
|
|
unsigned int degree : 31;
|
|
unsigned int mark : 1;
|
|
#endif
|
|
} *fibnode_t;
|
|
|
|
extern fibheap_t fibheap_new (void);
|
|
extern fibnode_t fibheap_insert (fibheap_t, fibheapkey_t, void *);
|
|
extern int fibheap_empty (fibheap_t);
|
|
extern fibheapkey_t fibheap_min_key (fibheap_t);
|
|
extern fibheapkey_t fibheap_replace_key (fibheap_t, fibnode_t,
|
|
fibheapkey_t);
|
|
extern void *fibheap_replace_key_data (fibheap_t, fibnode_t,
|
|
fibheapkey_t, void *);
|
|
extern void *fibheap_extract_min (fibheap_t);
|
|
extern void *fibheap_min (fibheap_t);
|
|
extern void *fibheap_replace_data (fibheap_t, fibnode_t, void *);
|
|
extern void *fibheap_delete_node (fibheap_t, fibnode_t);
|
|
extern void fibheap_delete (fibheap_t);
|
|
extern fibheap_t fibheap_union (fibheap_t, fibheap_t);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _FIBHEAP_H_ */
|