From 5972a2ffc002120f19414d3432f12c55a3e1be3e Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Fri, 27 May 2016 14:43:04 +0200 Subject: [PATCH] fix compilation in clang --- alib2algo/src/graph/spanningtree/Edmonds.cpp | 24 +++++++++---------- alib2data/src/graph/directed/DirectedGraph.h | 4 ++-- .../src/graph/undirected/UndirectedGraph.h | 4 ++-- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/alib2algo/src/graph/spanningtree/Edmonds.cpp b/alib2algo/src/graph/spanningtree/Edmonds.cpp index 7f4ae28f6d..64e59edacb 100644 --- a/alib2algo/src/graph/spanningtree/Edmonds.cpp +++ b/alib2algo/src/graph/spanningtree/Edmonds.cpp @@ -25,8 +25,6 @@ namespace graph { namespace spanningtree { -using namespace std; - //==================================================================================================== // data structures @@ -38,7 +36,7 @@ struct Edge { int weight; int origWeight; Edge * fParent; - vector<Edge*> fChildren; + std::vector<Edge*> fChildren; bool deleted; Edge( const DirectedEdge & edge, uint from, uint to, int weight ) @@ -75,7 +73,7 @@ class EdgeQueue : public BinomialHeap<Edge*> { }; template< typename Type > -void vector_remove( vector<Type> & vec, Type elem ) +void vector_remove( std::vector<Type> & vec, Type elem ) { for (auto it = vec.begin(); it != vec.end(); it++) { if (*it == elem) { @@ -95,17 +93,17 @@ static AdjacencyListDirectedGraph edmonds_impl( const DirectedGraph & graph ) uint nodeCnt = graph.nodeCount(); uint edgeCnt = graph.edgeCount(); - list<Edge> edges; // just to ease deallocation - queue<uint> roots; ///< silne komponenty, ktere jsou koreny v aktualnim grafu (nevede do nich zadny uzel) + std::list<Edge> edges; // just to ease deallocation + std::queue<uint> roots; ///< silne komponenty, ktere jsou koreny v aktualnim grafu (nevede do nich zadny uzel) Array<EdgeQueue> queues( nodeCnt ); ///< vstupni hrany do danych uzlu (razene dle priority) Array<Edge*> enter( nodeCnt ); ///< vstupni hrany do silnych komponent - Array<vector<Edge*>> h( nodeCnt ); ///< hrany, ktere mohou byt v kostre - vector<uint> rset; ///< rooti vyslednych stromu Tarjanovy implementace + Array<std::vector<Edge*>> h( nodeCnt ); ///< hrany, ktere mohou byt v kostre + std::vector<uint> rset; ///< rooti vyslednych stromu Tarjanovy implementace Components2 strong( nodeCnt ); ///< silne komponenty (reprezentanti) Components2 weak( nodeCnt ); ///< slabe komponenty (reprezentanti) Array<uint> min( nodeCnt ); ///< urcuje finalni korenove uzly orientovanych koster - vector<Edge*> fRoots; ///< koreny lesa F - Array<vector<Edge*>> cycles( nodeCnt ); ///< nalezene cykly + std::vector<Edge*> fRoots; ///< koreny lesa F + Array<std::vector<Edge*>> cycles( nodeCnt ); ///< nalezene cykly Array<Edge*> lambda( nodeCnt ); ///< listy lesa F // this algorithm works on number identification of nodes and edges @@ -175,7 +173,7 @@ static AdjacencyListDirectedGraph edmonds_impl( const DirectedGraph & graph ) int maxVal = INT_MIN; int vertex = INT_MIN; - vector<Edge*> & cycle = cycles[ strong.Find( root ) ]; + std::vector<Edge*> & cycle = cycles[ strong.Find( root ) ]; cycle.clear(); while (cycleEdge != NULL) { //hledame hranu v cyklu s maximalni vahou (ktera nejvice poskodi cyklus) cycle.push_back( cycleEdge ); @@ -202,8 +200,8 @@ static AdjacencyListDirectedGraph edmonds_impl( const DirectedGraph & graph ) } - vector<Edge*> b; - vector<uint> r; + std::vector<Edge*> b; + std::vector<uint> r; uint fRootIndex = 0; while (!rset.empty() || fRootIndex < fRoots.size()) { diff --git a/alib2data/src/graph/directed/DirectedGraph.h b/alib2data/src/graph/directed/DirectedGraph.h index f132634b27..6785a0d16e 100644 --- a/alib2data/src/graph/directed/DirectedGraph.h +++ b/alib2data/src/graph/directed/DirectedGraph.h @@ -36,7 +36,7 @@ class DirectedGraph : public GraphBase { DirectedGraph & operator=( DirectedGraph && orig ) noexcept; virtual GRAPH_TYPE getType() const override; - virtual REPRESENTATION getRepresentation() const = 0; + virtual REPRESENTATION getRepresentation() const override = 0 ; /// constructs an directed graph from any representation of other directed graph void fromDirected( const DirectedGraph & orig ); @@ -97,7 +97,7 @@ class DirectedGraph : public GraphBase { // commmon methods - int compare( const ObjectBase & other ) const { + int compare( const ObjectBase & other ) const override { if (std::type_index( typeid( *this ) ) == std::type_index( typeid( other ) )) return this->compare( (decltype( *this ))other ); return std::type_index( typeid( *this ) ) - std::type_index( typeid( other ) ); diff --git a/alib2data/src/graph/undirected/UndirectedGraph.h b/alib2data/src/graph/undirected/UndirectedGraph.h index e622b690c1..18e2197729 100644 --- a/alib2data/src/graph/undirected/UndirectedGraph.h +++ b/alib2data/src/graph/undirected/UndirectedGraph.h @@ -36,7 +36,7 @@ class UndirectedGraph : public GraphBase { UndirectedGraph & operator=( UndirectedGraph && orig ) noexcept; virtual GRAPH_TYPE getType() const override; - virtual REPRESENTATION getRepresentation() const = 0; + virtual REPRESENTATION getRepresentation() const override = 0; /// constructs an undirected graph from any representation of other undirected graph void fromUndirected( const UndirectedGraph & orig ); @@ -89,7 +89,7 @@ class UndirectedGraph : public GraphBase { // common methods - int compare( const ObjectBase & other ) const { + int compare( const ObjectBase & other ) const override { if (std::type_index( typeid( *this ) ) == std::type_index( typeid( other ) )) return this->compare( (decltype( *this ))other ); return std::type_index( typeid( *this ) ) - std::type_index( typeid( other ) ); -- GitLab