From 17ca36b9c897981e499a2d7002d86b5174643dd5 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Wed, 9 Aug 2017 15:51:24 +0200 Subject: [PATCH] move forward_list and list to ext namespace --- acompare2/src/AutomatonCompare.h | 12 ++--- acompare2/src/GrammarCompare.cpp | 10 ++-- acompare2/src/GrammarCompare.h | 2 +- .../src/tree/properties/ExactSubtreeRepeats.h | 2 +- .../src/graph/embedding/HopcroftTarjan.cpp | 32 ++++++------- .../src/graph/sort/TopologicalSort.h | 4 +- .../src/graph/spanningtree/Edmonds.cpp | 2 +- alib2common/src/container/ObjectsList.h | 42 ++++++++--------- alib2data/src/common/SparseBoolVector.hpp | 26 +++++------ alib2data/src/tree/common/TreeAuxiliary.h | 2 +- .../directed/AdjacencyListDirectedGraph.cpp | 2 +- .../directed/AdjacencyListDirectedGraph.h | 4 +- .../undirected/AdjacencyListUndirectedGraph.h | 2 +- .../src/graph/undirected/utils.h | 2 +- .../provisioner/MeasurementProvisioner.cpp | 2 +- .../MeasurementProvisionerInputData.cpp | 28 +++++------ .../MeasurementProvisionerInputData.hpp | 18 ++++---- .../MeasurementProvisionerUtils.cpp | 4 +- .../MeasurementProvisionerUtils.hpp | 2 +- alib2std/src/extensions/forward_list.hpp | 46 +++++++++++++++---- alib2std/src/extensions/list.hpp | 46 +++++++++++++++---- alib2std/test-src/extensions/ForeachTest.cpp | 4 +- alib2std/test-src/extensions/RangeTest.cpp | 4 +- 23 files changed, 177 insertions(+), 121 deletions(-) diff --git a/acompare2/src/AutomatonCompare.h b/acompare2/src/AutomatonCompare.h index fdbff99472..9323b24561 100644 --- a/acompare2/src/AutomatonCompare.h +++ b/acompare2/src/AutomatonCompare.h @@ -139,7 +139,7 @@ private: static void printCompare(const automaton::OneTapeDTM < SymbolType, StateType > & a, const automaton::OneTapeDTM < SymbolType, StateType > & b); template <class T> static void setCompare(const ext::set<T> &a, const ext::set<T> &b); - template <class T> static void listCompare(const std::list<T> &a, const std::list<T> &b); + template <class T> static void listCompare(const ext::list<T> &a, const ext::list<T> &b); template <class T, class R> static void mapCompare(const ext::map<T, R> &a, const ext::map<T, R> &b); public: template<class T> @@ -369,18 +369,18 @@ template <class T> void AutomatonCompare::setCompare(const ext::set<T> &a, const } } -template <class T> void AutomatonCompare::listCompare(const std::list<T> &a, const std::list<T> &b) { - std::list<T> aMinusB; +template <class T> void AutomatonCompare::listCompare(const ext::list<T> &a, const ext::list<T> &b) { + ext::list<T> aMinusB; std::set_difference(a.begin(), a.end(), b.begin(), b.end(), std::inserter(aMinusB, aMinusB.begin())); - std::list<T> bMinusA; + ext::list<T> bMinusA; std::set_difference(b.begin(), b.end(), a.begin(), a.end(), std::inserter(bMinusA, bMinusA.begin())); - for(typename std::list<T>::const_iterator iter = aMinusB.begin(); iter != aMinusB.end(); iter++) { + for(typename ext::list<T>::const_iterator iter = aMinusB.begin(); iter != aMinusB.end(); iter++) { std::cout << "< " << *iter << std::endl; } std::cout << "---" << std::endl; - for(typename std::list<T>::const_iterator iter = bMinusA.begin(); iter != bMinusA.end(); iter++) { + for(typename ext::list<T>::const_iterator iter = bMinusA.begin(); iter != bMinusA.end(); iter++) { std::cout << "> " << *iter << std::endl; } } diff --git a/acompare2/src/GrammarCompare.cpp b/acompare2/src/GrammarCompare.cpp index 23038a8e04..c21e83cea4 100644 --- a/acompare2/src/GrammarCompare.cpp +++ b/acompare2/src/GrammarCompare.cpp @@ -138,18 +138,18 @@ template <class T> void GrammarCompare::setCompare(const ext::set<T> &a, const e } } -template <class T> void GrammarCompare::listCompare(const std::list<T> &a, const std::list<T> &b) { - std::list<T> aMinusB; +template <class T> void GrammarCompare::listCompare(const ext::list<T> &a, const ext::list<T> &b) { + ext::list<T> aMinusB; std::set_difference(a.begin(), a.end(), b.begin(), b.end(), std::inserter(aMinusB, aMinusB.begin())); - std::list<T> bMinusA; + ext::list<T> bMinusA; std::set_difference(b.begin(), b.end(), a.begin(), a.end(), std::inserter(bMinusA, bMinusA.begin())); - for(typename std::list<T>::const_iterator iter = aMinusB.begin(); iter != aMinusB.end(); iter++) { + for(typename ext::list<T>::const_iterator iter = aMinusB.begin(); iter != aMinusB.end(); iter++) { std::cout << "< " << *iter << std::endl; } std::cout << "---" << std::endl; - for(typename std::list<T>::const_iterator iter = bMinusA.begin(); iter != bMinusA.end(); iter++) { + for(typename ext::list<T>::const_iterator iter = bMinusA.begin(); iter != bMinusA.end(); iter++) { std::cout << "> " << *iter << std::endl; } } diff --git a/acompare2/src/GrammarCompare.h b/acompare2/src/GrammarCompare.h index 8307e683fd..2cd16a1de3 100644 --- a/acompare2/src/GrammarCompare.h +++ b/acompare2/src/GrammarCompare.h @@ -60,7 +60,7 @@ private: static void printCompare(const grammar::UnrestrictedGrammar < > & a, const grammar::UnrestrictedGrammar < > & b); template <class T> static void setCompare(const ext::set<T> &a, const ext::set<T> &b); - template <class T> static void listCompare(const std::list<T> &a, const std::list<T> &b); + template <class T> static void listCompare(const ext::list<T> &a, const ext::list<T> &b); template <class T, class R> static void mapCompare(const ext::map<T, R> &a, const ext::map<T, R> &b); public: template < class T > diff --git a/alib2algo/src/tree/properties/ExactSubtreeRepeats.h b/alib2algo/src/tree/properties/ExactSubtreeRepeats.h index 0888e87183..147318ffc9 100644 --- a/alib2algo/src/tree/properties/ExactSubtreeRepeats.h +++ b/alib2algo/src/tree/properties/ExactSubtreeRepeats.h @@ -82,7 +82,7 @@ class ExactSubtreeRepeats : public alib::SingleDispatch < ExactSubtreeRepeats, t ext::vector < unsigned > T; /**< Stores ID of the last s-repeat found at this node. */ ext::vector < unsigned > TL; /**< Complements array T. For every i in TL[i] stores length of s-repeat at T[i]. */ ext::vector < std::queue < ext::tuple < std::deque < unsigned >, unsigned, int > > > LA; /**< Level array. At index i stores repeats scheduled for processing at height i. */ - std::list < ext::tuple < std::deque < unsigned >, unsigned, int > > found_repeats; /**< Stores found repeats to be accessed later. */ + ext::list < ext::tuple < std::deque < unsigned >, unsigned, int > > found_repeats; /**< Stores found repeats to be accessed later. */ unsigned alphabetSize; /**< Number of unique ranked symbols. */ unsigned treeSize; /**< Number of nodes in a tree. */ unsigned sc; /**< Tracks IDs of subtree repeats. */ diff --git a/alib2algo_experimental/src/graph/embedding/HopcroftTarjan.cpp b/alib2algo_experimental/src/graph/embedding/HopcroftTarjan.cpp index 1dd4de2511..28203a6ec7 100644 --- a/alib2algo_experimental/src/graph/embedding/HopcroftTarjan.cpp +++ b/alib2algo_experimental/src/graph/embedding/HopcroftTarjan.cpp @@ -142,11 +142,11 @@ const int RIGHT = 2; class Block { private: - std::list<int> Latt, Ratt; // list of attachments - std::list<DirectedEdge> Lseg, Rseg; // list of segments represented by their defining edges + ext::list<int> Latt, Ratt; // list of attachments + ext::list<DirectedEdge> Lseg, Rseg; // list of segments represented by their defining edges public: - Block(const DirectedEdge &e, std::list<int> &A) + Block(const DirectedEdge &e, ext::list<int> &A) { Lseg.push_back(e); conc(Latt, A); @@ -155,8 +155,8 @@ public: void flip() { - std::list<int> ha; - std::list<DirectedEdge> he; + ext::list<int> ha; + ext::list<DirectedEdge> he; // we first interchange |Latt| and |Ratt| and then |Lseg| and |Rseg| conc(ha, Ratt); conc(Ratt, Latt); @@ -241,7 +241,7 @@ public: return true; } - void add_to_Att(std::list<int> &Att, int dfsnum_w0, edge_array<int> &alpha) + void add_to_Att(ext::list<int> &Att, int dfsnum_w0, edge_array<int> &alpha) { // add the block to the rear of |Att|. Flip if necessary if (!Ratt.empty() && head_of_Ratt() > dfsnum_w0) @@ -262,7 +262,7 @@ public: } }; -static void dfs_in_reorder(const GraphWrapper &G, std::list<DirectedEdge> &Del, Node v, int &dfs_count, +static void dfs_in_reorder(const GraphWrapper &G, ext::list<DirectedEdge> &Del, Node v, int &dfs_count, node_array<bool> &reached, node_array<int> &dfsnum, node_array<int> &lowpt1, node_array<int> &lowpt2, @@ -272,7 +272,7 @@ static void reorder(GraphWrapper &G, node_array<int> &dfsnum, node_array<Node> & { node_array<bool> reached; int dfs_count = 0; - std::list<DirectedEdge> Del; + ext::list<DirectedEdge> Del; node_array<int> lowpt1, lowpt2; dfs_in_reorder(G, Del, G.first_node(), dfs_count, reached, dfsnum, lowpt1, lowpt2, parent); @@ -297,7 +297,7 @@ static void reorder(GraphWrapper &G, node_array<int> &dfsnum, node_array<Node> & G.sort_edges(cost); } -static void dfs_in_reorder(const GraphWrapper &G, std::list<DirectedEdge> &Del, Node v, int &dfs_count, +static void dfs_in_reorder(const GraphWrapper &G, ext::list<DirectedEdge> &Del, Node v, int &dfs_count, node_array<bool> &reached, node_array<int> &dfsnum, node_array<int> &lowpt1, node_array<int> &lowpt2, @@ -337,7 +337,7 @@ static void dfs_in_reorder(const GraphWrapper &G, std::list<DirectedEdge> &Del, } } -static bool strongly_planar(DirectedEdge e0, const GraphWrapper &G, std::list<int> &Att, +static bool strongly_planar(DirectedEdge e0, const GraphWrapper &G, ext::list<int> &Att, edge_array<int> &alpha, node_array<int> &dfsnum, node_array<Node> &parent) @@ -366,7 +366,7 @@ static bool strongly_planar(DirectedEdge e0, const GraphWrapper &G, std::list<in for (const DirectedEdge &ed : G.adj_edges(w)) { count++; if (count != 1) { // no action for first edge - std::list<int> A; + ext::list<int> A; if (dfsnum[w] < dfsnum[ed.getToNode()]) { // tree edge if (!strongly_planar(ed, G, A, alpha, dfsnum, parent)) { @@ -447,7 +447,7 @@ static bool strongly_planar(DirectedEdge e0, const GraphWrapper &G, std::list<in static void embedding(DirectedEdge e0, int t, const GraphWrapper &G, edge_array<int> &alpha, node_array<int> &dfsnum, - std::list<DirectedEdge> &T, std::list<DirectedEdge> &A, int &cur_nr, + ext::list<DirectedEdge> &T, ext::list<DirectedEdge> &A, int &cur_nr, edge_array<int> &sort_num, node_array<DirectedEdge> &tree_edge_into, node_array<Node> &parent, edge_array<DirectedEdge> &reversal) { @@ -474,8 +474,8 @@ static void embedding(DirectedEdge e0, int t, const GraphWrapper &G, Node w = wk; - std::list<DirectedEdge> Al, Ar; - std::list<DirectedEdge> Tprime, Aprime; + ext::list<DirectedEdge> Al, Ar; + ext::list<DirectedEdge> Tprime, Aprime; T.clear(); T.push_back(e); // |e = (wk,w0)| at this point, line (2) @@ -604,7 +604,7 @@ bool PLANAR(GraphWrapper &G, bool embed, HopcroftTarjan::Result &res) alpha[e] = 0; { - std::list<int> Att; + ext::list<int> Att; alpha[G.first_adj_edge(G.first_node())] = LEFT; @@ -613,7 +613,7 @@ bool PLANAR(GraphWrapper &G, bool embed, HopcroftTarjan::Result &res) } if (embed) { - std::list<DirectedEdge> T, A; // lists of edges of |H| + ext::list<DirectedEdge> T, A; // lists of edges of |H| int cur_nr = 0; edge_array<int> sort_num; diff --git a/alib2algo_experimental/src/graph/sort/TopologicalSort.h b/alib2algo_experimental/src/graph/sort/TopologicalSort.h index 1ca896890e..cb3cc793d6 100644 --- a/alib2algo_experimental/src/graph/sort/TopologicalSort.h +++ b/alib2algo_experimental/src/graph/sort/TopologicalSort.h @@ -17,9 +17,9 @@ namespace graph { namespace sort { -class TopologicalSort : public alib::SingleDispatch<TopologicalSort, std::list<Node>, const graph::GraphBase & > { +class TopologicalSort : public alib::SingleDispatch<TopologicalSort, ext::list<Node>, const graph::GraphBase & > { public: - typedef std::list<Node> Result; + typedef ext::list<Node> Result; static Result topologicalsort(const Graph &graph); diff --git a/alib2algo_experimental/src/graph/spanningtree/Edmonds.cpp b/alib2algo_experimental/src/graph/spanningtree/Edmonds.cpp index a68a397271..667646db4a 100644 --- a/alib2algo_experimental/src/graph/spanningtree/Edmonds.cpp +++ b/alib2algo_experimental/src/graph/spanningtree/Edmonds.cpp @@ -94,7 +94,7 @@ static AdjacencyListDirectedGraph edmonds_impl( const DirectedGraph & graph ) unsigned nodeCnt = graph.nodeCount(); unsigned edgeCnt = graph.edgeCount(); - std::list<Edge> edges; // just to ease deallocation + ext::list<Edge> edges; // just to ease deallocation std::queue<unsigned> 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 diff --git a/alib2common/src/container/ObjectsList.h b/alib2common/src/container/ObjectsList.h index 94518ea167..e4594bfdfc 100644 --- a/alib2common/src/container/ObjectsList.h +++ b/alib2common/src/container/ObjectsList.h @@ -26,9 +26,9 @@ namespace container { * Contains reason why the container occured. */ template < class ElementType > -class ObjectsList final : public std::list < ElementType >, public ContainerBase { +class ObjectsList final : public ext::list < ElementType >, public ContainerBase { public: - explicit ObjectsList ( std::list < ElementType > ); + explicit ObjectsList ( ext::list < ElementType > ); explicit ObjectsList ( ); virtual ContainerBase * clone ( ) const; @@ -54,15 +54,15 @@ public: } static ObjectsList parse ( std::deque < sax::Token >::iterator & input ); - static std::list < ElementType > parseRaw ( std::deque < sax::Token >::iterator & input ); + static ext::list < ElementType > parseRaw ( std::deque < sax::Token >::iterator & input ); void compose ( std::deque < sax::Token > & out ) const; - static void compose ( std::deque < sax::Token > & out, const std::list < ElementType > & input ); + static void compose ( std::deque < sax::Token > & out, const ext::list < ElementType > & input ); virtual alib::ObjectBase * inc ( ) &&; - static std::list < alib::Object > normalizeRaw ( std::list < ElementType > && source ) { - std::list < alib::Object > res; + static ext::list < alib::Object > normalizeRaw ( ext::list < ElementType > && source ) { + ext::list < alib::Object > res; for ( ElementType & element : source ) { res.push_back ( alib::Object ( alib::AnyObject < ElementType > ( std::move ( element ) ) ) ); } @@ -77,11 +77,11 @@ public: }; template < class ElementType > -ObjectsList < ElementType >::ObjectsList ( std::list < ElementType > raw ) : std::list < ElementType > ( std::move ( raw ) ) { +ObjectsList < ElementType >::ObjectsList ( ext::list < ElementType > raw ) : ext::list < ElementType > ( std::move ( raw ) ) { } template < class ElementType > -ObjectsList < ElementType >::ObjectsList ( ) : std::list < ElementType > ( ) { +ObjectsList < ElementType >::ObjectsList ( ) : ext::list < ElementType > ( ) { } template < class ElementType > @@ -96,14 +96,14 @@ ContainerBase * ObjectsList < ElementType >::plunder ( ) && { template < class ElementType > int ObjectsList < ElementType >::compare ( const ObjectsList & other ) const { - static ext::compare < std::list < ElementType > > comp; + static ext::compare < ext::list < ElementType > > comp; - return comp ( static_cast < const std::list < ElementType > & > ( * this ), static_cast < const std::list < ElementType > & > ( other ) ); + return comp ( static_cast < const ext::list < ElementType > & > ( * this ), static_cast < const ext::list < ElementType > & > ( other ) ); } template < class ElementType > void ObjectsList < ElementType >::operator >>( std::ostream & os ) const { - os << "(ObjectsList " << static_cast < const std::list < ElementType > & > ( * this ) << ")"; + os << "(ObjectsList " << static_cast < const ext::list < ElementType > & > ( * this ) << ")"; } template < class ElementType > @@ -124,10 +124,10 @@ void ObjectsList < ElementType >::compose ( std::deque < sax::Token > & out ) co } template < class ElementType > -std::list < ElementType > ObjectsList < ElementType >::parseRaw ( std::deque < sax::Token >::iterator & input ) { +ext::list < ElementType > ObjectsList < ElementType >::parseRaw ( std::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, ObjectsList < >::getXmlTagName() ); - std::list < ElementType > list; + ext::list < ElementType > list; while ( sax::FromXMLParserHelper::isTokenType ( input, sax::Token::TokenType::START_ELEMENT ) ) list.push_back ( alib::xmlApi < ElementType >::parse ( input ) ); @@ -137,7 +137,7 @@ std::list < ElementType > ObjectsList < ElementType >::parseRaw ( std::deque < s } template < class ElementType > -void ObjectsList < ElementType >::compose ( std::deque < sax::Token > & out, const std::list < ElementType > & input ) { +void ObjectsList < ElementType >::compose ( std::deque < sax::Token > & out, const ext::list < ElementType > & input ) { out.emplace_back ( ObjectsList < >::getXmlTagName(), sax::Token::TokenType::START_ELEMENT ); for ( const ElementType & item : input ) @@ -156,30 +156,30 @@ alib::ObjectBase* ObjectsList < ElementType >::inc() && { namespace alib { template < typename T > -struct xmlApi < std::list < T > > { - static std::list < T > parse ( std::deque < sax::Token >::iterator & input ); +struct xmlApi < ext::list < T > > { + static ext::list < T > parse ( std::deque < sax::Token >::iterator & input ); static bool first ( const std::deque < sax::Token >::const_iterator & input ); static std::string xmlTagName ( ); - static void compose ( std::deque < sax::Token > & output, const std::list < T > & data ); + static void compose ( std::deque < sax::Token > & output, const ext::list < T > & data ); }; template < typename T > -std::list < T > xmlApi < std::list < T > >::parse ( std::deque < sax::Token >::iterator & input ) { +ext::list < T > xmlApi < ext::list < T > >::parse ( std::deque < sax::Token >::iterator & input ) { return container::ObjectsList < T >::parseRaw ( input ); } template < typename T > -bool xmlApi < std::list < T > >::first ( const std::deque < sax::Token >::const_iterator & input ) { +bool xmlApi < ext::list < T > >::first ( const std::deque < sax::Token >::const_iterator & input ) { return sax::FromXMLParserHelper::isToken ( input, sax::Token::TokenType::START_ELEMENT, xmlTagName() ); } template < typename T > -std::string xmlApi < std::list < T > >::xmlTagName ( ) { +std::string xmlApi < ext::list < T > >::xmlTagName ( ) { return container::ObjectsList < >::getXmlTagName(); } template < typename T > -void xmlApi < std::list < T > >::compose ( std::deque < sax::Token > & output, const std::list < T > & input ) { +void xmlApi < ext::list < T > >::compose ( std::deque < sax::Token > & output, const ext::list < T > & input ) { return container::ObjectsList < T >::compose ( output, input ); } diff --git a/alib2data/src/common/SparseBoolVector.hpp b/alib2data/src/common/SparseBoolVector.hpp index dae51930ac..75ca5ff137 100644 --- a/alib2data/src/common/SparseBoolVector.hpp +++ b/alib2data/src/common/SparseBoolVector.hpp @@ -49,7 +49,7 @@ class SparseBoolVector { } }; - std::list < element > m_Data; + ext::list < element > m_Data; size_t m_Size; static inline unsigned getMask ( size_t dist ) { @@ -64,7 +64,7 @@ class SparseBoolVector { unsigned mask = getMask ( sizeWithin ); // crop by size - std::list < element >::iterator elementIter; + ext::list < element >::iterator elementIter; for ( elementIter = m_Data.begin ( ); elementIter != m_Data.end ( ); ++ elementIter ) { sizeBlocks -= elementIter->run + 1; if ( sizeBlocks <= 0 ) @@ -131,7 +131,7 @@ public: size_t sizeWithin = index % ( sizeof ( unsigned ) * 8 ); size_t sizeBlocks = index / ( sizeof ( unsigned ) * 8 ); - std::list < element >::const_iterator elementIter = m_Data.begin ( ); + ext::list < element >::const_iterator elementIter = m_Data.begin ( ); for ( ; elementIter != m_Data.end ( ); ++ elementIter ) { if ( elementIter->run + 1 > sizeBlocks ) break; @@ -145,12 +145,12 @@ public: private: class BitReference { - std::list < element > & data; - std::list < element >::iterator elementIter; + ext::list < element > & data; + ext::list < element >::iterator elementIter; size_t sizeWithin; size_t sizeBlocks; public: - BitReference ( std::list < element > & d, std::list < element >::iterator iter, size_t within, size_t blocks ) : data ( d ), elementIter ( iter ), sizeWithin ( within ), sizeBlocks ( blocks ) { + BitReference ( ext::list < element > & d, ext::list < element >::iterator iter, size_t within, size_t blocks ) : data ( d ), elementIter ( iter ), sizeWithin ( within ), sizeBlocks ( blocks ) { } bool operator = ( bool value ) { @@ -179,7 +179,7 @@ public: size_t sizeWithin = index % ( sizeof ( unsigned ) * 8 ); size_t sizeBlocks = index / ( sizeof ( unsigned ) * 8 ); - std::list < element >::iterator elementIter = m_Data.begin ( ); + ext::list < element >::iterator elementIter = m_Data.begin ( ); for ( ; elementIter != m_Data.end ( ); ++ elementIter ) { if ( elementIter->run + 1 > sizeBlocks ) break; @@ -210,7 +210,7 @@ public: // -------------------------------------------------------------------------------------------------------------------------------------------------- - const std::list < element > & data ( ) { + const ext::list < element > & data ( ) { return m_Data; } @@ -321,12 +321,12 @@ public: // -------------------------------------------------------------------------------------------------------------------------------------------------- class SparseBoolVectorOnesIterator { - std::list < element >::const_iterator underlying; - std::list < element >::const_iterator underlyingEnd; + ext::list < element >::const_iterator underlying; + ext::list < element >::const_iterator underlyingEnd; size_t index; public: - SparseBoolVectorOnesIterator ( std::list < element >::const_iterator iterBegin, std::list < element >::const_iterator iterEnd, size_t ind ) : underlying ( iterBegin ), underlyingEnd ( iterEnd ), index ( ind ) { + SparseBoolVectorOnesIterator ( ext::list < element >::const_iterator iterBegin, ext::list < element >::const_iterator iterEnd, size_t ind ) : underlying ( iterBegin ), underlyingEnd ( iterEnd ), index ( ind ) { if ( underlying == underlyingEnd ) { return; } @@ -416,8 +416,8 @@ public: friend SparseBoolVector & operator &= ( SparseBoolVector & A, const SparseBoolVector & B ) { A.resize ( std::max ( A.size ( ), B.size ( ) ) ); - std::list < element >::iterator iterA = A.m_Data.begin ( ); - std::list < element >::const_iterator iterB = B.m_Data.begin ( ); + ext::list < element >::iterator iterA = A.m_Data.begin ( ); + ext::list < element >::const_iterator iterB = B.m_Data.begin ( ); size_t blocksA = iterA->run; size_t blocksB = iterB->run; diff --git a/alib2data/src/tree/common/TreeAuxiliary.h b/alib2data/src/tree/common/TreeAuxiliary.h index f6a4228450..4e36feb757 100644 --- a/alib2data/src/tree/common/TreeAuxiliary.h +++ b/alib2data/src/tree/common/TreeAuxiliary.h @@ -71,7 +71,7 @@ ext::tree < common::ranked_symbol < SymbolType, RankType > > TreeAuxiliary::toRa tree_stack.push ( ext::tree < common::ranked_symbol < SymbolType, RankType > > ( common::ranked_symbol < SymbolType, RankType > ( x.getSymbol ( ), x.getRank ( ) ), ext::vector < ext::tree < common::ranked_symbol < SymbolType, RankType > > > ( ) ) ); } else { unsigned children_size = ( unsigned ) x.getRank ( ); - std::list < ext::tree < common::ranked_symbol < SymbolType, RankType > > > childrenList; + ext::list < ext::tree < common::ranked_symbol < SymbolType, RankType > > > childrenList; for ( unsigned i = 0; i < children_size; ++i ) { ext::tree < common::ranked_symbol < SymbolType, RankType > > child = tree_stack.top ( ); diff --git a/alib2data_experimental/src/graph/directed/AdjacencyListDirectedGraph.cpp b/alib2data_experimental/src/graph/directed/AdjacencyListDirectedGraph.cpp index 8a290fb4db..ee8e116e53 100644 --- a/alib2data_experimental/src/graph/directed/AdjacencyListDirectedGraph.cpp +++ b/alib2data_experimental/src/graph/directed/AdjacencyListDirectedGraph.cpp @@ -23,7 +23,7 @@ namespace graph { template<typename T> -inline void listRemoveOne(std::list<T> &lst, const T &item) +inline void listRemoveOne(ext::list<T> &lst, const T &item) { lst.erase(std::find(lst.begin(), lst.end(), item)); } diff --git a/alib2data_experimental/src/graph/directed/AdjacencyListDirectedGraph.h b/alib2data_experimental/src/graph/directed/AdjacencyListDirectedGraph.h index 5c4f854c15..065c584e02 100644 --- a/alib2data_experimental/src/graph/directed/AdjacencyListDirectedGraph.h +++ b/alib2data_experimental/src/graph/directed/AdjacencyListDirectedGraph.h @@ -34,8 +34,8 @@ class UndirectedGraph; */ class AdjacencyListDirectedGraph final : public DirectedGraph { - std::unordered_map< Node, std::list< Node > > succ; - std::unordered_map< Node, std::list< Node > > pred; + std::unordered_map< Node, ext::list< Node > > succ; + std::unordered_map< Node, ext::list< Node > > pred; ext::set< DirectedEdge > edges; public: diff --git a/alib2data_experimental/src/graph/undirected/AdjacencyListUndirectedGraph.h b/alib2data_experimental/src/graph/undirected/AdjacencyListUndirectedGraph.h index 04761e3938..a0a5daf458 100644 --- a/alib2data_experimental/src/graph/undirected/AdjacencyListUndirectedGraph.h +++ b/alib2data_experimental/src/graph/undirected/AdjacencyListUndirectedGraph.h @@ -37,7 +37,7 @@ class DirectedGraph; */ class AdjacencyListUndirectedGraph final : public UndirectedGraph { - std::unordered_map< Node, std::list< Node > > adj; + std::unordered_map< Node, ext::list< Node > > adj; ext::set< UndirectedEdge > edges; public: diff --git a/alib2data_experimental/src/graph/undirected/utils.h b/alib2data_experimental/src/graph/undirected/utils.h index e0bd8fc165..7b0b91684d 100644 --- a/alib2data_experimental/src/graph/undirected/utils.h +++ b/alib2data_experimental/src/graph/undirected/utils.h @@ -39,7 +39,7 @@ static bool edgeMatch(const UndirectedEdge &edge, const Node &node, const ext::s } template<typename T> -inline void listRemoveOne(std::list<T> &lst, const T &item) +inline void listRemoveOne(ext::list<T> &lst, const T &item) { lst.erase(std::find(lst.begin(), lst.end(), item)); } diff --git a/alib2measurepp/src/provisioner/MeasurementProvisioner.cpp b/alib2measurepp/src/provisioner/MeasurementProvisioner.cpp index 7f2cd9dd6b..d288ebbf88 100644 --- a/alib2measurepp/src/provisioner/MeasurementProvisioner.cpp +++ b/alib2measurepp/src/provisioner/MeasurementProvisioner.cpp @@ -78,7 +78,7 @@ void MeasurementProvisioner::prepareEnvironment ( const MeasurementProvisionerCo if ( workingDirectory.size ( ) == 0 ) return; - std::list < std::string > workingDirectoryExpansion = MPUtils::shellExpand ( workingDirectory ); + ext::list < std::string > workingDirectoryExpansion = MPUtils::shellExpand ( workingDirectory ); if ( workingDirectoryExpansion.size ( ) != 1 ) throw::exception::CommonException ( "MeasurementProvisioner: binaries directory: \"" + workingDirectory + "\" expansion failed" ); diff --git a/alib2measurepp/src/provisioner/MeasurementProvisionerInputData.cpp b/alib2measurepp/src/provisioner/MeasurementProvisionerInputData.cpp index 8d8e7700e7..4a17f3e91a 100644 --- a/alib2measurepp/src/provisioner/MeasurementProvisionerInputData.cpp +++ b/alib2measurepp/src/provisioner/MeasurementProvisionerInputData.cpp @@ -138,11 +138,11 @@ const MPInputDatum & MPInputData::getMPIDHandle ( const std::string & filename ) return this->mpidHandles.find ( filename )->second; } -const std::list < MPSubstitutionMap > & MPInputData::getSubstitutionMaps ( ) const { +const ext::list < MPSubstitutionMap > & MPInputData::getSubstitutionMaps ( ) const { return this->substitutionMaps; } -const std::list < MPPipeline > & MPInputData::getSubstitutionPipelines ( ) const { +const ext::list < MPPipeline > & MPInputData::getSubstitutionPipelines ( ) const { return this->substitutionPipelines; } @@ -196,8 +196,8 @@ void MPInputData::insertMPInputDatum ( MPInputDatum::Type type, std::string file this->mpidHandles.emplace ( mpid.m_filename, std::move ( mpid ) ); } -void MPInputData::processSimpleBatchFileData ( const MPCInputDatum & inputDatum, std::list < std::string > & mpidList ) { - std::list < std::string > expandedFilename = MPUtils::shellExpand ( inputDatum.value ); +void MPInputData::processSimpleBatchFileData ( const MPCInputDatum & inputDatum, ext::list < std::string > & mpidList ) { + ext::list < std::string > expandedFilename = MPUtils::shellExpand ( inputDatum.value ); for ( int i = 0; i < inputDatum.count; ++i ) for ( const std::string & file : expandedFilename ) { @@ -207,7 +207,7 @@ void MPInputData::processSimpleBatchFileData ( const MPCInputDatum & inputDatum, } -void MPInputData::processSimpleBatchGeneratorData ( const MPCInputDatum & inputDatum, std::list < std::string > & mpidList ) { +void MPInputData::processSimpleBatchGeneratorData ( const MPCInputDatum & inputDatum, ext::list < std::string > & mpidList ) { for ( int i = 0; i < inputDatum.count; ++i ) { std::string filename = MPUtils::generateTmpfileFromCommand ( inputDatum.value ); insertMPInputDatum ( MPInputDatum::Type::GENERATOR, filename, constructGeneratorInputDatumAlias ( inputDatum ) ); @@ -216,10 +216,10 @@ void MPInputData::processSimpleBatchGeneratorData ( const MPCInputDatum & inputD } void MPInputData::processSimpleBatch ( const MPCInputBatch & inputBatch ) { - ext::map < int, std::list < std::string > > distributedMPInputData; + ext::map < int, ext::list < std::string > > distributedMPInputData; for ( const MPCInputDatum & inputDatum : inputBatch.batch ) { - std::list < std::string > & didList = distributedMPInputData[inputDatum.id]; + ext::list < std::string > & didList = distributedMPInputData[inputDatum.id]; switch ( inputDatum.type ) { case MPCInputDatum::Type::FILE: @@ -251,8 +251,8 @@ void MPInputData::processSimpleBatch ( const MPCInputBatch & inputBatch ) { } } -void MPInputData::processDependencyBatchFileData ( const MPCInputDatum & inputDatum, const MPSubstitutionMap & prevSubstitutionMap, std::list < MPSubstitutionMap > & curSubstitutionMaps ) { - std::list < std::string > expandedFilename = MPUtils::shellExpand ( inputDatum.value ); +void MPInputData::processDependencyBatchFileData ( const MPCInputDatum & inputDatum, const MPSubstitutionMap & prevSubstitutionMap, ext::list < MPSubstitutionMap > & curSubstitutionMaps ) { + ext::list < std::string > expandedFilename = MPUtils::shellExpand ( inputDatum.value ); for ( std::string & file : expandedFilename ) { insertMPInputDatum ( MPInputDatum::Type::FILE, file, constructFileInputDatumAlias ( file, inputDatum ) ); @@ -265,7 +265,7 @@ void MPInputData::processDependencyBatchFileData ( const MPCInputDatum & inputDa } } -void MPInputData::processDependencyBatchGeneratorData ( const MPCInputDatum & inputDatum, const MPSubstitutionMap & prevSubstitutionMap, std::list < MPSubstitutionMap > & curSubstitutionMaps ) { +void MPInputData::processDependencyBatchGeneratorData ( const MPCInputDatum & inputDatum, const MPSubstitutionMap & prevSubstitutionMap, ext::list < MPSubstitutionMap > & curSubstitutionMaps ) { for ( int i = 0; i < inputDatum.count; ++i ) { MPSubstitutionMap resultSubstitutionMap = prevSubstitutionMap; @@ -286,19 +286,19 @@ void MPInputData::processDependencyBatch ( const MPCInputBatch & inputBatch ) { // the already processed substitution maps into the batch being processed // distribute MPCInputData by their ids for processing in order - ext::map < int, std::list < MPCInputDatum > > distributedMPCInputData; + ext::map < int, ext::list < MPCInputDatum > > distributedMPCInputData; for ( const MPCInputDatum & inputDatum : inputBatch.batch ) distributedMPCInputData[inputDatum.id].push_back ( inputDatum ); - std::list < MPSubstitutionMap > prevSubstitutionMaps; + ext::list < MPSubstitutionMap > prevSubstitutionMaps; for ( auto & didPair : distributedMPCInputData ) { - std::list < MPSubstitutionMap > curSubstitutionMaps; + ext::list < MPSubstitutionMap > curSubstitutionMaps; // treat first id data like simple batch data, because we forbid them to have substitutions if ( didPair.first == distributedMPCInputData.begin ( )->first ) { - std::list < std::string > filenameList; + ext::list < std::string > filenameList; for ( MPCInputDatum & inputDatum : didPair.second ) switch ( inputDatum.type ) { diff --git a/alib2measurepp/src/provisioner/MeasurementProvisionerInputData.hpp b/alib2measurepp/src/provisioner/MeasurementProvisionerInputData.hpp index 189bd766c2..731b601c6a 100644 --- a/alib2measurepp/src/provisioner/MeasurementProvisionerInputData.hpp +++ b/alib2measurepp/src/provisioner/MeasurementProvisionerInputData.hpp @@ -67,29 +67,29 @@ public: bool getMeasure ( ) const; }; -using MPPipeline = std::list < MPPipelineCommand >; +using MPPipeline = ext::list < MPPipelineCommand >; class MPInputData { ext::map < std::string, MPInputDatum > mpidHandles; - std::list < MPSubstitutionMap > substitutionMaps; + ext::list < MPSubstitutionMap > substitutionMaps; ext::set < int > requiredSubstitutionPattern; - std::list < MPPipeline > substitutionPipelines; + ext::list < MPPipeline > substitutionPipelines; void insertMPInputDatum ( MPInputDatum::Type, std::string, std::string ); public: const MPInputDatum & getMPIDHandle ( const std::string & ) const; - const std::list < MPSubstitutionMap > & getSubstitutionMaps ( ) const; - const std::list < MPPipeline > & getSubstitutionPipelines ( ) const; + const ext::list < MPSubstitutionMap > & getSubstitutionMaps ( ) const; + const ext::list < MPPipeline > & getSubstitutionPipelines ( ) const; MPInputData ( const MeasurementProvisionerConfiguration & ); private: - void processSimpleBatchFileData ( const MPCInputDatum &, std::list < std::string > & ); - void processSimpleBatchGeneratorData ( const MPCInputDatum &, std::list < std::string > & ); + void processSimpleBatchFileData ( const MPCInputDatum &, ext::list < std::string > & ); + void processSimpleBatchGeneratorData ( const MPCInputDatum &, ext::list < std::string > & ); void processSimpleBatch ( const MPCInputBatch & ); - void processDependencyBatchFileData ( const MPCInputDatum &, const MPSubstitutionMap &, std::list < MPSubstitutionMap > & ); - void processDependencyBatchGeneratorData ( const MPCInputDatum &, const MPSubstitutionMap &, std::list < MPSubstitutionMap > & ); + void processDependencyBatchFileData ( const MPCInputDatum &, const MPSubstitutionMap &, ext::list < MPSubstitutionMap > & ); + void processDependencyBatchGeneratorData ( const MPCInputDatum &, const MPSubstitutionMap &, ext::list < MPSubstitutionMap > & ); void processDependencyBatch ( const MPCInputBatch & ); void processMPCInputData ( const MeasurementProvisionerConfiguration & ); diff --git a/alib2measurepp/src/provisioner/MeasurementProvisionerUtils.cpp b/alib2measurepp/src/provisioner/MeasurementProvisionerUtils.cpp index 77b3d73aa8..5ee017f066 100644 --- a/alib2measurepp/src/provisioner/MeasurementProvisionerUtils.cpp +++ b/alib2measurepp/src/provisioner/MeasurementProvisionerUtils.cpp @@ -15,8 +15,8 @@ namespace measurements { -std::list < std::string > MPUtils::shellExpand ( const std::string & str ) { - std::list < std::string > results; +ext::list < std::string > MPUtils::shellExpand ( const std::string & str ) { + ext::list < std::string > results; wordexp_t wexp; diff --git a/alib2measurepp/src/provisioner/MeasurementProvisionerUtils.hpp b/alib2measurepp/src/provisioner/MeasurementProvisionerUtils.hpp index 18ed8557b7..43ee5e4944 100644 --- a/alib2measurepp/src/provisioner/MeasurementProvisionerUtils.hpp +++ b/alib2measurepp/src/provisioner/MeasurementProvisionerUtils.hpp @@ -12,7 +12,7 @@ namespace measurements { class MPUtils { public: - static std::list < std::string > shellExpand ( const std::string & ); + static ext::list < std::string > shellExpand ( const std::string & ); static std::string randomFilename ( ); diff --git a/alib2std/src/extensions/forward_list.hpp b/alib2std/src/extensions/forward_list.hpp index 9efbba57fe..d0b011b971 100644 --- a/alib2std/src/extensions/forward_list.hpp +++ b/alib2std/src/extensions/forward_list.hpp @@ -15,10 +15,42 @@ #include "compare.hpp" -namespace std { +namespace ext { + +template < class T, class Alloc = std::allocator < T > > +class forward_list : public std::forward_list < T, Alloc > { +public: +#ifdef __clang__ + using std::forward_list < T, Alloc >::forward_list; + using std::forward_list < T, Alloc >::operator =; +#else + forward_list ( ) noexcept : std::forward_list < T, Alloc > ( ) { + } + + forward_list ( const forward_list & other ) noexcept : std::forward_list < T, Alloc > ( other ) { + } + + forward_list ( forward_list && other ) noexcept : std::forward_list < T, Alloc > ( std::move ( other ) ) { + } + + using std::forward_list < T, Alloc >::forward_list; + + forward_list & operator = ( forward_list && other ) noexcept { + static_cast < std::forward_list < T, Alloc > & > ( * this ) = std::move ( other ); + return * this; + } + + forward_list & operator = ( const forward_list & other ) noexcept { + static_cast < std::forward_list < T, Alloc > & > ( * this ) = other; + return * this; + } + + using std::forward_list < T, Alloc >::operator =; +#endif +}; template< class T, class ... Ts > -std::ostream& operator<<(std::ostream& out, const std::forward_list<T, Ts ... >& forward_list) { +std::ostream& operator<<(std::ostream& out, const ext::forward_list<T, Ts ... >& forward_list) { out << "["; bool first = true; @@ -32,13 +64,9 @@ std::ostream& operator<<(std::ostream& out, const std::forward_list<T, Ts ... >& return out; } -} /* namespace std */ - -namespace ext { - template<class T, class ... Ts > -struct compare<forward_list<T, Ts ... >> { - int operator()(const forward_list<T, Ts ... >& first, const forward_list<T, Ts ... >& second) const { +struct compare<ext::forward_list<T, Ts ... >> { + int operator()(const ext::forward_list<T, Ts ... >& first, const ext::forward_list<T, Ts ... >& second) const { if(first.size() < second.size()) return -1; if(first.size() > second.size()) return 1; @@ -52,7 +80,7 @@ struct compare<forward_list<T, Ts ... >> { }; template < class T, class ... Ts > -string to_string ( const std::forward_list < T, Ts ... > & value ) { +std::string to_string ( const ext::forward_list < T, Ts ... > & value ) { std::stringstream ss; ss << value; return ss.str(); diff --git a/alib2std/src/extensions/list.hpp b/alib2std/src/extensions/list.hpp index 72ef08dfc7..c515b63973 100644 --- a/alib2std/src/extensions/list.hpp +++ b/alib2std/src/extensions/list.hpp @@ -15,10 +15,42 @@ #include "compare.hpp" -namespace std { +namespace ext { + +template < class T, class Alloc = std::allocator < T > > +class list : public std::list < T, Alloc > { +public: +#ifdef __clang__ + using std::list < T, Alloc >::list; + using std::list < T, Alloc >::operator =; +#else + list ( ) noexcept : std::list < T, Alloc > ( ) { + } + + list ( const list & other ) noexcept : std::list < T, Alloc > ( other ) { + } + + list ( list && other ) noexcept : std::list < T, Alloc > ( std::move ( other ) ) { + } + + using std::list < T, Alloc >::list; + + list & operator = ( list && other ) noexcept { + static_cast < std::list < T, Alloc > & > ( * this ) = std::move ( other ); + return * this; + } + + list & operator = ( const list & other ) noexcept { + static_cast < std::list < T, Alloc > & > ( * this ) = other; + return * this; + } + + using std::list < T, Alloc >::operator =; +#endif +}; template< class T, class ... Ts > -std::ostream& operator<<(std::ostream& out, const std::list<T, Ts ... >& list) { +std::ostream& operator<<(std::ostream& out, const ext::list<T, Ts ... >& list) { out << "["; bool first = true; @@ -32,13 +64,9 @@ std::ostream& operator<<(std::ostream& out, const std::list<T, Ts ... >& list) { return out; } -} /* namespace std */ - -namespace ext { - template < class T, class ... Ts > -struct compare < std::list < T, Ts ... > > { - int operator ( ) ( const std::list < T, Ts ... > & first, const std::list < T, Ts ... > & second) const { +struct compare < ext::list < T, Ts ... > > { + int operator ( ) ( const ext::list < T, Ts ... > & first, const ext::list < T, Ts ... > & second) const { if(first.size() < second.size()) return -1; if(first.size() > second.size()) return 1; @@ -52,7 +80,7 @@ struct compare < std::list < T, Ts ... > > { }; template < class T, class ... Ts > -std::string to_string ( const std::list < T, Ts ... > & value ) { +std::string to_string ( const ext::list < T, Ts ... > & value ) { std::stringstream ss; ss << value; return ss.str(); diff --git a/alib2std/test-src/extensions/ForeachTest.cpp b/alib2std/test-src/extensions/ForeachTest.cpp index 2d16ba24bb..34d5af38b5 100644 --- a/alib2std/test-src/extensions/ForeachTest.cpp +++ b/alib2std/test-src/extensions/ForeachTest.cpp @@ -15,7 +15,7 @@ void ForeachTest::tearDown() { void ForeachTest::testForeach() { ext::vector<int> vector1 {1, 2, 3}; - std::list<int> list1 {2, 3, 4}; + ext::list<int> list1 {2, 3, 4}; int i = 1; for(const ext::tuple<const int&, const int&>& elements : ext::make_tuple_foreach(vector1, list1)) { @@ -27,7 +27,7 @@ void ForeachTest::testForeach() { void ForeachTest::testForeach2() { ext::vector<int> vector1 {1, 2, 3}; - std::list<int> list1 {2, 3, 4}; + ext::list<int> list1 {2, 3, 4}; ext::set<int> set1 {3, 4, 5}; int i = 1; diff --git a/alib2std/test-src/extensions/RangeTest.cpp b/alib2std/test-src/extensions/RangeTest.cpp index 2f76e78914..8973c1c566 100644 --- a/alib2std/test-src/extensions/RangeTest.cpp +++ b/alib2std/test-src/extensions/RangeTest.cpp @@ -41,9 +41,9 @@ void RangeTest::sizeTest ( ) { CPPUNIT_ASSERT ( rv1.size ( ) == 10 ); - std::list < int > l1 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + ext::list < int > l1 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - ext::range < std::list < int >::iterator > rl1 ( l1.begin ( ), l1.end ( ) ); + ext::range < ext::list < int >::iterator > rl1 ( l1.begin ( ), l1.end ( ) ); CPPUNIT_ASSERT ( rl1.size ( ) == 10 ); } -- GitLab