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/>.
29 // Return number of elements stored in heap
30 IDnum
getDFibHeapSize ( DFibHeap
* heap
)
32 return dfibheap_getSize ( heap
);
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
)
46 res
= dfh_insertkey ( heap
, key
, node
);
50 // Replaces the key for a given node
51 Time
replaceKeyInDHeap ( DFibHeap
* heap
, DFibHeapNode
* node
, Time newKey
)
54 res
= dfh_replacekey ( heap
, node
, newKey
);
59 /*************************************************
61 removeNextNodeFromDHeap
63 Removes the edge from DHeap, then returns it.
70 *************************************************/
71 unsigned int removeNextNodeFromDHeap ( DFibHeap
* heap
)
74 node
= ( unsigned int ) dfh_extractmin ( heap
);
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
);