ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
FibHeap Class Reference

#include <FibHeap.h>

Detailed Description

Definition at line 166 of file FibHeap.h.

+ Collaboration diagram for FibHeap:

Public Member Functions

int DecreaseKey (FibHeapNode *theNode, NodeKeyValueType keyValue)
 
int Delete (FibHeapNode *theNode)
 
FibHeapNode * ExtractMin ()
 
 FibHeap ()
 
long GetNumMarkedNodes ()
 
long GetNumNodes ()
 
long GetNumTrees ()
 
void Insert (FibHeapNode *NewNode)
 
bool IsEmpty ()
 
FibHeapNode * Minimum ()
 
void Print (FibHeapNode *Tree=nullptr, FibHeapNode *theParent=nullptr)
 
void SetHeapNodes (FibHeapNode *heapNodes)
 
void Union (FibHeap *OtherHeap)
 
virtual ~FibHeap ()
 

Private Member Functions

void AddToRootList (FibHeapNode *)
 
void CascadingCut (FibHeapNode *)
 
void Consolidate ()
 
void Cut (FibHeapNode *, FibHeapNode *)
 
void Exchange (FibHeapNode *&N1, FibHeapNode *&N2)
 
FibHeapNode * HeapNodeFromIndex (NodeIndexType index)
 
void Link (FibHeapNode *, FibHeapNode *)
 

Private Attributes

FibHeapNode * m_HeapNodes
 
FibHeapNode * m_MinRoot
 
long m_NumMarkedNodes
 
long m_NumNodes
 
long m_NumTrees
 

Constructor & Destructor Documentation

◆ FibHeap()

FibHeap::FibHeap ( )

Referenced by Union().

◆ ~FibHeap()

virtual FibHeap::~FibHeap ( )
virtual

Member Function Documentation

◆ AddToRootList()

void FibHeap::AddToRootList ( FibHeapNode * )
private

◆ CascadingCut()

void FibHeap::CascadingCut ( FibHeapNode * )
private

◆ Consolidate()

void FibHeap::Consolidate ( )
private

◆ Cut()

void FibHeap::Cut ( FibHeapNode * ,
FibHeapNode *  )
private

◆ DecreaseKey()

int FibHeap::DecreaseKey ( FibHeapNode * theNode,
NodeKeyValueType keyValue )

DecreaseKey() - O(lg n) actual; O(1) amortized

The O(lg n) actual cost stems from the fact that the depth, and therefore the number of ancestor parents, is bounded by O(lg n).

◆ Delete()

int FibHeap::Delete ( FibHeapNode * theNode)

Delete() - O(lg n) amortized; ExtractMin() dominates

Notice that if we don't own the heap nodes, then we clear the m_NegInfinityFlag on the deleted node. Presumably, the programmer will be reusing the node.

◆ Exchange()

void FibHeap::Exchange ( FibHeapNode *& N1,
FibHeapNode *& N2 )
inlineprivate

Definition at line 257 of file FibHeap.h.

◆ ExtractMin()

FibHeapNode * FibHeap::ExtractMin ( )

ExtractMin() - O(n) worst-case actual; O(lg n) amortized.

◆ GetNumMarkedNodes()

long FibHeap::GetNumMarkedNodes ( )
inline

Definition at line 241 of file FibHeap.h.

References m_NumMarkedNodes.

◆ GetNumNodes()

long FibHeap::GetNumNodes ( )
inline

Definition at line 231 of file FibHeap.h.

References m_NumNodes.

◆ GetNumTrees()

long FibHeap::GetNumTrees ( )
inline

Definition at line 236 of file FibHeap.h.

References m_NumTrees.

◆ HeapNodeFromIndex()

FibHeapNode * FibHeap::HeapNodeFromIndex ( NodeIndexType index)
inlineprivate

Definition at line 304 of file FibHeap.h.

References m_HeapNodes, and FibHeapNode::NullNodeIndex.

◆ Insert()

void FibHeap::Insert ( FibHeapNode * NewNode)

Insert() - O(1) actual; O(2) amortized

I am using O(2) here to indicate that although Insert() is constant time, its amortized rating is more costly because some of the work of inserting is done by other operations such as ExtractMin(), which is where tree-balancing occurs.

The child pointer is deliberately not set to nullptr because Insert() is also used internally to help put whole trees onto the root list.

◆ IsEmpty()

bool FibHeap::IsEmpty ( )
inline

Definition at line 224 of file FibHeap.h.

References m_MinRoot.

◆ Link()

void FibHeap::Link ( FibHeapNode * ,
FibHeapNode *  )
private

◆ Minimum()

FibHeapNode * FibHeap::Minimum ( )
inline

Minimum - O(1) actual; O(1) amortized.

Definition at line 199 of file FibHeap.h.

References m_MinRoot.

◆ Print()

void FibHeap::Print ( FibHeapNode * Tree = nullptr,
FibHeapNode * theParent = nullptr )

Print()

Used internally for debugging purposes. The function prints the key value for each node along the root list, then it calls itself on each child list.

◆ SetHeapNodes()

void FibHeap::SetHeapNodes ( FibHeapNode * heapNodes)

Set array that stores all nodes. The array is not owned by this object and must remain valid while this object is used. Nodes are stored in an array to allow referencing them using a 32-bit index instead of a 64-bit pointer. Since each node stores 4 pointer/index, this saves 16 bytes per node, which is very significant when e.g., one node corresponds to an image voxel and the image contains hundreds of millions of voxels.

◆ Union()

void FibHeap::Union ( FibHeap * OtherHeap)

Union() - O(1) actual; O(1) amortized.

References FibHeap().

Member Data Documentation

◆ m_HeapNodes

FibHeapNode* FibHeap::m_HeapNodes
private

Definition at line 313 of file FibHeap.h.

Referenced by HeapNodeFromIndex().

◆ m_MinRoot

FibHeapNode* FibHeap::m_MinRoot
private

Definition at line 309 of file FibHeap.h.

Referenced by IsEmpty(), and Minimum().

◆ m_NumMarkedNodes

long FibHeap::m_NumMarkedNodes
private

Definition at line 312 of file FibHeap.h.

Referenced by GetNumMarkedNodes().

◆ m_NumNodes

long FibHeap::m_NumNodes
private

Definition at line 310 of file FibHeap.h.

Referenced by GetNumNodes().

◆ m_NumTrees

long FibHeap::m_NumTrees
private

Definition at line 311 of file FibHeap.h.

Referenced by GetNumTrees().


The documentation for this class was generated from the following file: