diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2023-01-26 18:25:37 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2023-01-31 14:27:06 (GMT) |
commit | 91a26ce04136ccafbe37a17afc2efb01abf0992e (patch) | |
tree | 91a84614802b2e83d3d4a60010ae520b6d18e850 /Source/cmComputeComponentGraph.h | |
parent | 65c0a64dc5bc7cb0e13721500bdd754b6630e8ea (diff) | |
download | CMake-91a26ce04136ccafbe37a17afc2efb01abf0992e.zip CMake-91a26ce04136ccafbe37a17afc2efb01abf0992e.tar.gz CMake-91a26ce04136ccafbe37a17afc2efb01abf0992e.tar.bz2 |
cmComputeComponentGraph: use `size_t` for component indices
This avoids using casts everywhere when dealing with the sizes.
Diffstat (limited to 'Source/cmComputeComponentGraph.h')
-rw-r--r-- | Source/cmComputeComponentGraph.h | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/Source/cmComputeComponentGraph.h b/Source/cmComputeComponentGraph.h index 76879c7..878e36d 100644 --- a/Source/cmComputeComponentGraph.h +++ b/Source/cmComputeComponentGraph.h @@ -4,6 +4,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include <cstddef> #include <stack> #include <vector> @@ -35,7 +36,7 @@ public: /** Get the adjacency list of the component graph. */ Graph const& GetComponentGraph() const { return this->ComponentGraph; } - EdgeList const& GetComponentGraphEdges(int c) const + EdgeList const& GetComponentGraphEdges(size_t c) const { return this->ComponentGraph[c]; } @@ -45,15 +46,15 @@ public: { return this->Components; } - NodeList const& GetComponent(int c) const { return this->Components[c]; } + NodeList const& GetComponent(size_t c) const { return this->Components[c]; } /** Get map from original node index to component index. */ - std::vector<int> const& GetComponentMap() const + std::vector<size_t> const& GetComponentMap() const { return this->TarjanComponents; } - static const int INVALID_COMPONENT; + static const size_t INVALID_COMPONENT; private: void TransferEdges(); @@ -64,18 +65,18 @@ private: // Tarjan's algorithm. struct TarjanEntry { - int Root; - int VisitIndex; + size_t Root; + size_t VisitIndex; }; - std::vector<int> TarjanVisited; - std::vector<int> TarjanComponents; + std::vector<size_t> TarjanVisited; + std::vector<size_t> TarjanComponents; std::vector<TarjanEntry> TarjanEntries; std::vector<NodeList> Components; - std::stack<int> TarjanStack; - int TarjanWalkId; - int TarjanIndex; + std::stack<size_t> TarjanStack; + size_t TarjanWalkId; + size_t TarjanIndex; void Tarjan(); - void TarjanVisit(int i); + void TarjanVisit(size_t i); // Connected components. }; |