fix some small issues:

remove empty unit test

remove compiler directives

move trip related files from routing_algorithms to algorithms

run clang-format on files

fix all std::size_t related issues

improve code by adding std::move()s

clean up includes

fixing several code stye and improvement issues

add several small code improvements

return single scc in SplitUnaccessibleLocations() when theres only one

change ComputeRoute() to return an InternalRouteResult by value

improve some code style issues
This commit is contained in:
Huyen Chau Nguyen
2015-08-28 20:18:15 +02:00
parent e773a80b06
commit 74e00cf652
11 changed files with 319 additions and 354 deletions
+22 -32
View File
@@ -31,30 +31,30 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <vector>
#include <utility>
#include <boost/assert.hpp>
#include <cstddef>
//This Wrapper provides an easier access to a distance table that is given as an linear vector
template <typename T> class DistTableWrapper {
public:
// This Wrapper provides an easier access to a distance table that is given as an linear vector
template <typename T> class DistTableWrapper
{
public:
using Iterator = typename std::vector<T>::iterator;
using ConstIterator = typename std::vector<T>::const_iterator;
DistTableWrapper(std::vector<T> table, std::size_t number_of_nodes)
: table_(std::move(table)), number_of_nodes_(number_of_nodes) {
: table_(std::move(table)), number_of_nodes_(number_of_nodes)
{
BOOST_ASSERT_MSG(table.size() == 0, "table is empty");
BOOST_ASSERT_MSG(number_of_nodes_ * number_of_nodes_ <= table_.size(), "number_of_nodes_ is invalid");
BOOST_ASSERT_MSG(number_of_nodes_ * number_of_nodes_ <= table_.size(),
"number_of_nodes_ is invalid");
};
std::size_t GetNumberOfNodes() const {
return number_of_nodes_;
}
std::size_t GetNumberOfNodes() const { return number_of_nodes_; }
std::size_t size() const {
return table_.size();
}
std::size_t size() const { return table_.size(); }
EdgeWeight operator() (NodeID from, NodeID to) const {
EdgeWeight operator()(NodeID from, NodeID to) const
{
BOOST_ASSERT_MSG(from < number_of_nodes_, "from ID is out of bound");
BOOST_ASSERT_MSG(to < number_of_nodes_, "to ID is out of bound");
@@ -62,37 +62,27 @@ public:
BOOST_ASSERT_MSG(index < table_.size(), "index is out of bound");
return table_[index];
return table_[index];
}
ConstIterator begin() const{
return std::begin(table_);
}
ConstIterator begin() const { return std::begin(table_); }
Iterator begin() {
return std::begin(table_);
}
Iterator begin() { return std::begin(table_); }
ConstIterator end() const{
return std::end(table_);
}
ConstIterator end() const { return std::end(table_); }
Iterator end() {
return std::end(table_);
}
Iterator end() { return std::end(table_); }
NodeID GetIndexOfMaxValue() const {
NodeID GetIndexOfMaxValue() const
{
return std::distance(table_.begin(), std::max_element(table_.begin(), table_.end()));
}
std::vector<T> GetTable() const {
return table_;
}
std::vector<T> GetTable() const { return table_; }
private:
private:
std::vector<T> table_;
const std::size_t number_of_nodes_;
};
#endif // DIST_TABLE_WRAPPER_H