modified: makefile
[GalaxyCodeBases.git] / BGI / SOAPdenovo2 / standardPregraph / dfibHeap.c
blob900171de53f24aa9e679ff8e3e51882a612f14b3
1 /*
2 * dfibHeap.c
4 * Copyright (c) 2008-2012 BGI-Shenzhen <soap at genomics dot org dot cn>.
6 * This file is part of SOAPdenovo.
8 * SOAPdenovo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * SOAPdenovo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with SOAPdenovo. If not, see <http://www.gnu.org/licenses/>.
23 #include <stdlib.h>
24 #include <stdio.h>
26 #include "def2.h"
27 #include "dfib.h"
29 // Return number of elements stored in heap
30 IDnum getDFibHeapSize ( DFibHeap * heap )
32 return dfibheap_getSize ( heap );
35 // Constructor
36 // Memory allocated
37 DFibHeap * newDFibHeap ()
39 return dfh_makekeyheap ();
42 // Add new node into heap with a key, and a pointer to the specified node
43 DFibHeapNode * insertNodeIntoDHeap ( DFibHeap * heap, Time key, unsigned int node )
45 DFibHeapNode * res;
46 res = dfh_insertkey ( heap, key, node );
47 return res;
50 // Replaces the key for a given node
51 Time replaceKeyInDHeap ( DFibHeap * heap, DFibHeapNode * node, Time newKey )
53 Time res;
54 res = dfh_replacekey ( heap, node, newKey );
55 return res;
59 /*************************************************
60 Function:
61 removeNextNodeFromDHeap
62 Description:
63 Removes the edge from DHeap, then returns it.
64 Input:
65 1. heap : the heap
66 Output:
67 None.
68 Return:
69 The key.
70 *************************************************/
71 unsigned int removeNextNodeFromDHeap ( DFibHeap * heap )
73 unsigned int node;
74 node = ( unsigned int ) dfh_extractmin ( heap );
75 return node;
78 // Destructor
79 void destroyDHeap ( DFibHeap * heap )
81 dfh_deleteheap ( heap );
84 // Replace the node pointed to by a heap node
85 void replaceValueInDHeap ( DFibHeapNode * node, unsigned int newValue )
87 dfh_replacedata ( node, newValue );
90 // Remove unwanted node
91 void destroyNodeInDHeap ( DFibHeapNode * node, DFibHeap * heap )
93 dfh_delete ( heap, node );
96 Time getKey ( DFibHeapNode * node )
98 return dfibheap_el_getKey ( node );