Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## This config file is only relevant for clang-format version 19.1.4
## This config file is only relevant for clang-format version 19.1.7
##
## Examples of each format style can be found on the in the clang-format documentation
## See: https://clang.llvm.org/docs/ClangFormatStyleOptions.html for details of each option
Expand All @@ -10,11 +10,11 @@
## maintaining a consistent code style.
##
## EXAMPLE apply code style enforcement before commit:
# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_19.1.4} --modified
# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_19.1.7} --modified
## EXAMPLE apply code style enforcement after commit:
# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_19.1.4} --last
# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_19.1.7} --last
---
# This configuration requires clang-format version 19.1.4 exactly.
# This configuration requires clang-format version 19.1.7 exactly.
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
Expand Down Expand Up @@ -297,6 +297,7 @@ StatementMacros:
- ITK_CLANG_PRAGMA_PUSH
- ITK_CLANG_PRAGMA_POP
- ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant
- ITK_CLANG_SUPPRESS_Wduplicate_enum
- CLANG_PRAGMA_PUSH
- CLANG_PRAGMA_POP
- CLANG_SUPPRESS_Wfloat_equal
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/clang-format-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v5

- uses: InsightSoftwareConsortium/ITKClangFormatLinterAction@master
- uses: InsightSoftwareConsortium/ITKClangFormatLinterAction@main
with:
itk-branch: main
2 changes: 1 addition & 1 deletion include/itkFastGrowCut.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ template <typename TInputImage, typename TLabelImage, typename TMaskImage>
void
FastGrowCut<TInputImage, TLabelImage, TMaskImage>::GenerateData()
{
auto inputImage = this->GetInput();
auto inputImage = this->GetInput();
// auto seedImage = this->GetSeedImage();
auto outputImage = this->GetOutput();
RegionType inRegion = inputImage->GetLargestPossibleRegion();
Expand Down
94 changes: 53 additions & 41 deletions src/FibHeap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

using namespace std;

#define OK 0
#define NOTOK -1
#define OK 0
#define NOTOK -1

const NodeIndexType FibHeapNode::NullNodeIndex = 0xFFFFFFFF;
const NodeIndexType FibHeapNode::NullNodeIndex = 0xFFFFFFFF;
const NodeKeyValueType FibHeapNode::NegativeInfinity = -std::numeric_limits<NodeKeyValueType>::infinity();

//-----------------------------------------------------------------------------
Expand All @@ -30,13 +30,15 @@ FibHeap::FibHeap()
FibHeap::~FibHeap() = default;

//-----------------------------------------------------------------------------
void FibHeap::SetHeapNodes(FibHeapNode* heapNodes)
void
FibHeap::SetHeapNodes(FibHeapNode * heapNodes)
{
m_HeapNodes = heapNodes;
}

//-----------------------------------------------------------------------------
void FibHeap::Insert(FibHeapNode* NewNode)
void
FibHeap::Insert(FibHeapNode * NewNode)
{
if (NewNode == nullptr)
{
Expand Down Expand Up @@ -74,7 +76,8 @@ void FibHeap::Insert(FibHeapNode* NewNode)
}

//-----------------------------------------------------------------------------
void FibHeap::Union(FibHeap *OtherHeap)
void
FibHeap::Union(FibHeap * OtherHeap)
{
if (OtherHeap == nullptr || OtherHeap->m_MinRoot == nullptr)
{
Expand All @@ -85,10 +88,10 @@ void FibHeap::Union(FibHeap *OtherHeap)
// min node and the node after the min. This code just pulls those
// nodes into temporary variables so we don't get lost as changes
// are made.
FibHeapNode* Min1 = m_MinRoot;
FibHeapNode* Min2 = OtherHeap->m_MinRoot;
FibHeapNode* Next1 = HeapNodeFromIndex(Min1->m_Right);
FibHeapNode* Next2 = HeapNodeFromIndex(Min2->m_Right);
FibHeapNode * Min1 = m_MinRoot;
FibHeapNode * Min2 = OtherHeap->m_MinRoot;
FibHeapNode * Next1 = HeapNodeFromIndex(Min1->m_Right);
FibHeapNode * Next2 = HeapNodeFromIndex(Min2->m_Right);

// To join the two circles, we join the minimum nodes to the next
// nodes on the opposite chains. Conceptually, it looks like the way
Expand All @@ -112,7 +115,7 @@ void FibHeap::Union(FibHeap *OtherHeap)

// Complete the union by setting the other heap to emptiness
// then destroying it
OtherHeap->m_MinRoot = nullptr;
OtherHeap->m_MinRoot = nullptr;
OtherHeap->m_NumNodes = 0;
OtherHeap->m_NumTrees = 0;
OtherHeap->m_NumMarkedNodes = 0;
Expand All @@ -121,10 +124,11 @@ void FibHeap::Union(FibHeap *OtherHeap)
}

//-----------------------------------------------------------------------------
FibHeapNode *FibHeap::ExtractMin()
FibHeapNode *
FibHeap::ExtractMin()
{
FibHeapNode *Result;
FibHeap *ChildHeap = nullptr;
FibHeapNode * Result;
FibHeap * ChildHeap = nullptr;

// Remove minimum node and set m_MinRoot to next node
if ((Result = Minimum()) == nullptr)
Expand All @@ -137,10 +141,10 @@ FibHeapNode *FibHeap::ExtractMin()
m_HeapNodes[Result->m_Left].m_Right = Result->m_Right;
Result->m_Left = Result->m_Right = FibHeapNode::NullNodeIndex;

m_NumNodes --;
m_NumNodes--;
if (Result->m_Mark)
{
m_NumMarkedNodes --;
m_NumMarkedNodes--;
Result->m_Mark = false;
}
Result->m_Degree = 0;
Expand Down Expand Up @@ -196,7 +200,8 @@ FibHeapNode *FibHeap::ExtractMin()
}

//-----------------------------------------------------------------------------
int FibHeap::DecreaseKey(FibHeapNode* theNode, NodeKeyValueType keyValue)
int
FibHeap::DecreaseKey(FibHeapNode * theNode, NodeKeyValueType keyValue)
{
if (theNode == nullptr || theNode->m_Key < keyValue)
{
Expand All @@ -205,7 +210,7 @@ int FibHeap::DecreaseKey(FibHeapNode* theNode, NodeKeyValueType keyValue)

(*theNode) = keyValue;

FibHeapNode* theParent = HeapNodeFromIndex(theNode->m_Parent);
FibHeapNode * theParent = HeapNodeFromIndex(theNode->m_Parent);
if (theParent != nullptr && *theNode < *theParent)
{
Cut(theNode, theParent);
Expand All @@ -221,7 +226,8 @@ int FibHeap::DecreaseKey(FibHeapNode* theNode, NodeKeyValueType keyValue)
}

//-----------------------------------------------------------------------------
int FibHeap::Delete(FibHeapNode *theNode)
int
FibHeap::Delete(FibHeapNode * theNode)
{
if (theNode == nullptr)
{
Expand All @@ -247,14 +253,15 @@ int FibHeap::Delete(FibHeapNode *theNode)
}

//-----------------------------------------------------------------------------
void FibHeap::Print(FibHeapNode *tree, FibHeapNode *theParent)
void
FibHeap::Print(FibHeapNode * tree, FibHeapNode * theParent)
{
if (tree == nullptr)
{
tree = m_MinRoot;
}

FibHeapNode* temp = tree;
FibHeapNode * temp = tree;
do
{
if (temp->m_Left == FibHeapNode::NullNodeIndex)
Expand Down Expand Up @@ -306,7 +313,7 @@ void FibHeap::Print(FibHeapNode *tree, FibHeapNode *theParent)
Print(HeapNodeFromIndex(temp->m_Child), temp);
}
temp = HeapNodeFromIndex(temp->m_Right);
} while (temp !=nullptr && temp != tree);
} while (temp != nullptr && temp != tree);

if (theParent == nullptr)
{
Expand All @@ -317,12 +324,13 @@ void FibHeap::Print(FibHeapNode *tree, FibHeapNode *theParent)
}

//-----------------------------------------------------------------------------
void FibHeap::Consolidate()
void
FibHeap::Consolidate()
{
// Initialize the consolidation detection array
const int Dn = 1 + 8 * sizeof(long);
FibHeapNode *A[Dn]; // 1+lg(n)
for (int i=0; i < Dn; i++)
const int Dn = 1 + 8 * sizeof(long);
FibHeapNode * A[Dn]; // 1+lg(n)
for (int i = 0; i < Dn; i++)
{
A[i] = nullptr;
}
Expand All @@ -338,15 +346,15 @@ void FibHeap::Consolidate()

m_HeapNodes[m_MinRoot->m_Left].m_Right = FibHeapNode::NullNodeIndex;
m_MinRoot->m_Left = FibHeapNode::NullNodeIndex;
FibHeapNode* w = m_MinRoot;
FibHeapNode * w = m_MinRoot;

FibHeapNode* x;
FibHeapNode* y;
short d;
FibHeapNode * x;
FibHeapNode * y;
short d;
do
{
//cout << "Top of Consolidate's loop\n";
//Print(w);
// cout << "Top of Consolidate's loop\n";
// Print(w);

x = w;
d = x->m_Degree;
Expand All @@ -369,8 +377,8 @@ void FibHeap::Consolidate()
Link(y, x);
A[d] = nullptr;
d++;
//cout << "After a round of Linking\n";
//Print(x);
// cout << "After a round of Linking\n";
// Print(x);
}
A[d] = x;

Expand All @@ -391,7 +399,8 @@ void FibHeap::Consolidate()
}

//-----------------------------------------------------------------------------
void FibHeap::Link(FibHeapNode *y, FibHeapNode *x)
void
FibHeap::Link(FibHeapNode * y, FibHeapNode * x)
{
// Remove node y from root list
if (y->m_Right != FibHeapNode::NullNodeIndex)
Expand Down Expand Up @@ -423,7 +432,7 @@ void FibHeap::Link(FibHeapNode *y, FibHeapNode *x)
}

// Increase the degree of node x because it's now a bigger tree
x->m_Degree ++;
x->m_Degree++;

// Node y has just been made a child, so clear its mark
if (y->m_Mark)
Expand All @@ -434,7 +443,8 @@ void FibHeap::Link(FibHeapNode *y, FibHeapNode *x)
}

//-----------------------------------------------------------------------------
void FibHeap::AddToRootList(FibHeapNode *x)
void
FibHeap::AddToRootList(FibHeapNode * x)
{
if (x->m_Mark)
{
Expand All @@ -447,7 +457,8 @@ void FibHeap::AddToRootList(FibHeapNode *x)
}

//-----------------------------------------------------------------------------
void FibHeap::Cut(FibHeapNode *x, FibHeapNode *y)
void
FibHeap::Cut(FibHeapNode * x, FibHeapNode * y)
{
if (y->m_Child == x->m_Index)
{
Expand All @@ -458,7 +469,7 @@ void FibHeap::Cut(FibHeapNode *x, FibHeapNode *y)
y->m_Child = FibHeapNode::NullNodeIndex;
}

y->m_Degree --;
y->m_Degree--;

m_HeapNodes[x->m_Left].m_Right = x->m_Right;
m_HeapNodes[x->m_Right].m_Left = x->m_Left;
Expand All @@ -467,9 +478,10 @@ void FibHeap::Cut(FibHeapNode *x, FibHeapNode *y)
}

//-----------------------------------------------------------------------------
void FibHeap::CascadingCut(FibHeapNode *y)
void
FibHeap::CascadingCut(FibHeapNode * y)
{
FibHeapNode *z = HeapNodeFromIndex(y->m_Parent);
FibHeapNode * z = HeapNodeFromIndex(y->m_Parent);

while (z != nullptr)
{
Expand Down
Loading