From 8f3766c9fbb4ceb6537b6fd0c23ced2ca96f5116 Mon Sep 17 00:00:00 2001 From: Karsten Rink <karsten.rink@ufz.de> Date: Mon, 17 Mar 2014 12:51:48 +0100 Subject: [PATCH] changed iterators to constant functions where possible --- MeshLib/ElementStatus.cpp | 14 +++++++------- MeshLib/ElementStatus.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/MeshLib/ElementStatus.cpp b/MeshLib/ElementStatus.cpp index 25dde6b1d16..556e9c35b16 100644 --- a/MeshLib/ElementStatus.cpp +++ b/MeshLib/ElementStatus.cpp @@ -24,7 +24,7 @@ ElementStatus::ElementStatus(Mesh const*const mesh) : _mesh(mesh), _element_status(mesh->getNElements(), true) { const std::vector<MeshLib::Node*> &nodes (_mesh->getNodes()); - for (auto node = nodes.begin(); node != nodes.end(); ++node) + for (auto node = nodes.cbegin(); node != nodes.cend(); ++node) _active_nodes.push_back((*node)->getNElements()); } @@ -51,17 +51,17 @@ std::vector<std::size_t> ElementStatus::getActiveNodes() const return active_nodes; } -std::vector<std::size_t> ElementStatus::getActiveElementsAtNode(unsigned node_id) const +std::vector<std::size_t> ElementStatus::getActiveElementsAtNode(std::size_t node_id) const { - const unsigned nActiveElements (_active_nodes[node_id]); + const std::size_t nActiveElements (_active_nodes[node_id]); const std::vector<Element*> &elements (_mesh->getNode(node_id)->getElements()); std::vector<std::size_t> active_elements; active_elements.reserve(nActiveElements); - for (auto elem = elements.begin(); elem != elements.end(); ++elem) + for (auto elem = elements.cbegin(); elem != elements.cend(); ++elem) { if (active_elements.size() == nActiveElements) return active_elements; - const unsigned id ((*elem)->getID()); + const std::size_t id ((*elem)->getID()); if (_element_status[id]) active_elements.push_back(id); } @@ -70,12 +70,12 @@ std::vector<std::size_t> ElementStatus::getActiveElementsAtNode(unsigned node_id std::size_t ElementStatus::getNActiveNodes() const { - return _active_nodes.size() - std::count(_active_nodes.begin(), _active_nodes.end(), 0); + return _active_nodes.size() - std::count(_active_nodes.cbegin(), _active_nodes.cend(), 0); } std::size_t ElementStatus::getNActiveElements() const { - return static_cast<unsigned>(std::count(_element_status.begin(), _element_status.end(), true)); + return static_cast<std::size_t>(std::count(_element_status.cbegin(), _element_status.cend(), true)); } void ElementStatus::setAll(bool status) diff --git a/MeshLib/ElementStatus.h b/MeshLib/ElementStatus.h index 367bcda8f54..a838daa039e 100644 --- a/MeshLib/ElementStatus.h +++ b/MeshLib/ElementStatus.h @@ -41,7 +41,7 @@ public: bool getElementStatus(std::size_t i) const { return _element_status[i]; } /// Returns a vector of active elements connected to a node - std::vector<std::size_t> getActiveElementsAtNode(unsigned node_id) const; + std::vector<std::size_t> getActiveElementsAtNode(std::size_t node_id) const; /// Returns the total number of active nodes std::size_t getNActiveNodes() const; -- GitLab