From 0bc35bd4710683c98b09b6941c23a5b541174017 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Tue, 8 Nov 2016 11:03:36 +0100 Subject: [PATCH] enable and fix additional warnings for alib2data_experimental --- alib2data_experimental/makefile | 4 +- .../src/graph/common/Node.cpp | 14 ++-- .../src/graph/common/Node.h | 4 +- .../src/graph/directed/DirectedEdge.cpp | 20 +++--- .../src/graph/directed/DirectedEdge.h | 8 +-- .../src/graph/directed/DirectedGraph.cpp | 8 +-- .../src/graph/directed/DirectedGraph.h | 2 +- .../src/graph/undirected/UndirectedEdge.cpp | 28 ++++---- .../src/graph/undirected/UndirectedEdge.h | 8 +-- .../src/graph/undirected/UndirectedGraph.cpp | 8 +-- .../src/graph/undirected/UndirectedGraph.h | 2 +- .../suffixTrie/SuffixTrieFinalMark.cpp | 38 +++++------ .../indexes/suffixTrie/SuffixTrieFinalMark.h | 2 +- .../suffixTrie/SuffixTrieNodeFinalMark.cpp | 68 +++++++++---------- .../suffixTrie/SuffixTrieNodeFinalMark.h | 4 +- .../SuffixTrieNodeTerminatingSymbol.cpp | 52 +++++++------- .../SuffixTrieNodeTerminatingSymbol.h | 2 +- .../SuffixTrieTerminatingSymbol.cpp | 36 +++++----- .../suffixTrie/SuffixTrieTerminatingSymbol.h | 2 +- .../string/LinearStringTerminatingSymbol.cpp | 2 +- .../string/LinearStringTerminatingSymbol.h | 10 +-- 21 files changed, 162 insertions(+), 160 deletions(-) diff --git a/alib2data_experimental/makefile b/alib2data_experimental/makefile index 38bca86b66..bf9f76e926 100644 --- a/alib2data_experimental/makefile +++ b/alib2data_experimental/makefile @@ -10,6 +10,8 @@ endef export NEW_LINE +CXX_FLAGS := -Wall -pedantic -Wextra -Werror -Wshadow -Wpointer-arith -Wcast-qual -Wdelete-non-virtual-dtor -Wredundant-decls + space := $(eval) $(eval) LDFLAGS_DEBUG:=-rdynamic -shared @@ -54,7 +56,7 @@ FORCE: $${NEW_LINE}\ export NEW_LINE$${NEW_LINE}\ $${NEW_LINE}\ - CXXFLAGS:= -pipe -std=c++11 \$$(CXX_OTHER_FLAGS) -c -Wall -pedantic -Wextra -Werror -fPIC \$$(addprefix -I, \$$(realpath $(INCLUDE_PATHS))) -I\$$(realpath \$$(SOURCES_BASE_DIR)/../src/)$${NEW_LINE}\ + CXXFLAGS:= -pipe -std=c++11 \$$(CXX_OTHER_FLAGS) -c $(CXX_FLAGS) -fPIC \$$(addprefix -I, \$$(realpath $(INCLUDE_PATHS))) -I\$$(realpath \$$(SOURCES_BASE_DIR)/../src/)$${NEW_LINE}\ $${NEW_LINE}\ SOURCES:= \$$(shell find \$$(SOURCES_BASE_DIR)/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")$${NEW_LINE}\ DEPENDENCIES:= \$$(patsubst \$$(SOURCES_BASE_DIR)/\$$(SRCDIR)%.cpp, \$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d, \$$(SOURCES))$${NEW_LINE}\ diff --git a/alib2data_experimental/src/graph/common/Node.cpp b/alib2data_experimental/src/graph/common/Node.cpp index 32985809ec..8b3e2016cf 100644 --- a/alib2data_experimental/src/graph/common/Node.cpp +++ b/alib2data_experimental/src/graph/common/Node.cpp @@ -12,22 +12,22 @@ namespace graph { Node::Node(label::Label name) - : name(std::move(name)) + : m_name(std::move(name)) { } Node::Node(int number) - : name(label::labelFrom(number)) + : m_name(label::labelFrom(number)) { } Node::Node(char character) - : name(label::labelFrom(character)) + : m_name(label::labelFrom(character)) { } Node::Node(const std::string & name) - : name(label::labelFrom(name)) + : m_name(label::labelFrom(name)) { } @@ -43,7 +43,7 @@ Node * Node::plunder() && const label::Label & Node::getName() const { - return name; + return m_name; } bool Node::operator < (const Node & other) const { @@ -60,7 +60,7 @@ bool Node::operator != (const Node & other) const { int Node::compare(const Node & other) const { - return name.getData().compare(other.name.getData()); + return m_name.getData().compare(other.m_name.getData()); } void Node::operator<<(std::ostream & out) const @@ -83,7 +83,7 @@ Node::operator std::string() const void Node::dump(std::ostream & os) const { - os << "(Node " << name << ")"; + os << "(Node " << m_name << ")"; } } // namespace graph diff --git a/alib2data_experimental/src/graph/common/Node.h b/alib2data_experimental/src/graph/common/Node.h index ada0d52715..a3f4863bac 100644 --- a/alib2data_experimental/src/graph/common/Node.h +++ b/alib2data_experimental/src/graph/common/Node.h @@ -15,13 +15,13 @@ namespace graph { class Node { - label::Label name; + label::Label m_name; void dump(std::ostream & os) const; public: /// should be used only to create variable, to which will be assigned soon - Node() : name(label::labelFrom("uninitialized")) {} + Node() : m_name(label::labelFrom("uninitialized")) {} explicit Node(label::Label name); explicit Node(int number); diff --git a/alib2data_experimental/src/graph/directed/DirectedEdge.cpp b/alib2data_experimental/src/graph/directed/DirectedEdge.cpp index 9996e250d4..50cd54746a 100644 --- a/alib2data_experimental/src/graph/directed/DirectedEdge.cpp +++ b/alib2data_experimental/src/graph/directed/DirectedEdge.cpp @@ -19,9 +19,9 @@ DirectedEdge::DirectedEdge(Node from, Node to) } DirectedEdge::DirectedEdge(Node from, Node to, label::Label name) - : from(std::move(from)) - , to(std::move(to)) - , name(std::move(name)) + : m_from(std::move(from)) + , m_to(std::move(to)) + , m_name(std::move(name)) { } @@ -52,17 +52,17 @@ DirectedEdge * DirectedEdge::plunder() && const Node & DirectedEdge::getFromNode() const { - return from; + return m_from; } const Node & DirectedEdge::getToNode() const { - return to; + return m_to; } const label::Label & DirectedEdge::getName() const { - return name; + return m_name; } bool DirectedEdge::operator < (const DirectedEdge & other) const { @@ -83,11 +83,11 @@ bool DirectedEdge::operator != (const DirectedEdge & other) const { int DirectedEdge::compare(const DirectedEdge & other) const { - int res = name.getData().compare(other.name.getData()); + int res = m_name.getData().compare(other.m_name.getData()); if (res != 0) return res; - res = from.compare(other.from); + res = m_from.compare(other.m_from); if (res != 0) return res; - return to.compare(other.to); + return m_to.compare(other.m_to); } DirectedEdge::operator std::string() const @@ -105,7 +105,7 @@ std::ostream & operator<<(std::ostream & out, const DirectedEdge & node) void DirectedEdge::dump(std::ostream & os) const { - os << "(DirectedEdge " << from << " -> ( " << name << " ) " << to << ")"; + os << "(DirectedEdge " << m_from << " -> ( " << m_name << " ) " << m_to << ")"; } } // namespace graph diff --git a/alib2data_experimental/src/graph/directed/DirectedEdge.h b/alib2data_experimental/src/graph/directed/DirectedEdge.h index fcaf65cf74..0df087f063 100644 --- a/alib2data_experimental/src/graph/directed/DirectedEdge.h +++ b/alib2data_experimental/src/graph/directed/DirectedEdge.h @@ -14,15 +14,15 @@ namespace graph { class DirectedEdge { - Node from; - Node to; - label::Label name; + Node m_from; + Node m_to; + label::Label m_name; void dump(std::ostream & os) const; public: /// should be used only to create variable, to which will be assigned soon - DirectedEdge() : from(), to(), name(label::labelFrom("uninitialized")) {} + DirectedEdge() : m_from(), m_to(), m_name(label::labelFrom("uninitialized")) {} explicit DirectedEdge(Node from, Node to); explicit DirectedEdge(Node from, Node to, label::Label name); diff --git a/alib2data_experimental/src/graph/directed/DirectedGraph.cpp b/alib2data_experimental/src/graph/directed/DirectedGraph.cpp index baafd32cd3..73b4db449c 100644 --- a/alib2data_experimental/src/graph/directed/DirectedGraph.cpp +++ b/alib2data_experimental/src/graph/directed/DirectedGraph.cpp @@ -147,12 +147,12 @@ void DirectedGraph::setEdgeValue( const DirectedEdge & edge, int value ) std::unordered_map< Node, std::vector< Node > > DirectedGraph::getEmbedding() const { - return embedding; + return m_embedding; } void DirectedGraph::setEmbedding( const std::unordered_map< Node, std::vector< Node > > embedding ) { - this->embedding = embedding; + this->m_embedding = embedding; } int DirectedGraph::compare( const DirectedGraph & other ) const @@ -162,8 +162,8 @@ int DirectedGraph::compare( const DirectedGraph & other ) const std::set<Node> otherNodes = other.getNodes(); std::set<DirectedEdge> otherEdges = other.getEdges(); - auto first = std::tie(thisNodes, thisEdges, nodeValues, edgeValues, embedding); - auto second = std::tie(otherNodes, otherEdges, other.nodeValues, other.edgeValues, other.embedding); + auto first = std::tie(thisNodes, thisEdges, nodeValues, edgeValues, m_embedding); + auto second = std::tie(otherNodes, otherEdges, other.nodeValues, other.edgeValues, other.m_embedding); std::compare<decltype(first)> comp; return comp(first, second); diff --git a/alib2data_experimental/src/graph/directed/DirectedGraph.h b/alib2data_experimental/src/graph/directed/DirectedGraph.h index fdddc3148d..7f6ab67220 100644 --- a/alib2data_experimental/src/graph/directed/DirectedGraph.h +++ b/alib2data_experimental/src/graph/directed/DirectedGraph.h @@ -26,7 +26,7 @@ class UndirectedGraph; class DirectedGraph : public GraphBase { std::unordered_map< Node, int > nodeValues; std::unordered_map< DirectedEdge, int > edgeValues; - std::unordered_map< Node, std::vector< Node > > embedding; + std::unordered_map< Node, std::vector< Node > > m_embedding; public: DirectedGraph(); diff --git a/alib2data_experimental/src/graph/undirected/UndirectedEdge.cpp b/alib2data_experimental/src/graph/undirected/UndirectedEdge.cpp index bee17144e9..29ef22c8d5 100644 --- a/alib2data_experimental/src/graph/undirected/UndirectedEdge.cpp +++ b/alib2data_experimental/src/graph/undirected/UndirectedEdge.cpp @@ -19,14 +19,14 @@ UndirectedEdge::UndirectedEdge(Node first, Node second) } UndirectedEdge::UndirectedEdge(Node first, Node second, label::Label name) - : first(std::move(first)) - , second(std::move(second)) - , name(std::move(name)) + : m_first(std::move(first)) + , m_second(std::move(second)) + , m_name(std::move(name)) { - if (this->second < this->first) { - Node tmp = std::move(this->second); - this->second = std::move(this->first); - this->first = std::move(tmp); + if (this->m_second < this->m_first) { + Node tmp = std::move(this->m_second); + this->m_second = std::move(this->m_first); + this->m_first = std::move(tmp); } } @@ -57,17 +57,17 @@ UndirectedEdge * UndirectedEdge::plunder() && const Node & UndirectedEdge::getFirstNode() const { - return first; + return m_first; } const Node & UndirectedEdge::getSecondNode() const { - return second; + return m_second; } const label::Label & UndirectedEdge::getName() const { - return name; + return m_name; } bool UndirectedEdge::operator < (const UndirectedEdge & other) const { @@ -88,11 +88,11 @@ bool UndirectedEdge::operator != (const UndirectedEdge & other) const { int UndirectedEdge::compare(const UndirectedEdge & other) const { - int res = name.getData().compare(other.name.getData()); + int res = m_name.getData().compare(other.m_name.getData()); if (res != 0) return res; - res = first.compare(other.first); + res = m_first.compare(other.m_first); if (res != 0) return res; - return second.compare(other.second); + return m_second.compare(other.m_second); } UndirectedEdge::operator std::string() const @@ -110,7 +110,7 @@ std::ostream & operator<<(std::ostream & out, const UndirectedEdge & node) void UndirectedEdge::dump(std::ostream & os) const { - os << "(UndirectedEdge " << first << " -> ( " << name << " ) " << second << ")"; + os << "(UndirectedEdge " << m_first << " -> ( " << m_name << " ) " << m_second << ")"; } } // namespace graph diff --git a/alib2data_experimental/src/graph/undirected/UndirectedEdge.h b/alib2data_experimental/src/graph/undirected/UndirectedEdge.h index dfbd55e1d6..8aa89df938 100644 --- a/alib2data_experimental/src/graph/undirected/UndirectedEdge.h +++ b/alib2data_experimental/src/graph/undirected/UndirectedEdge.h @@ -14,15 +14,15 @@ namespace graph { class UndirectedEdge { - Node first; - Node second; - label::Label name; + Node m_first; + Node m_second; + label::Label m_name; void dump(std::ostream & os) const; public: /// should be used only to create variable, to which will be assigned soon - UndirectedEdge() : first(), second(), name(label::labelFrom("uninitialized")) {} + UndirectedEdge() : m_first(), m_second(), m_name(label::labelFrom("uninitialized")) {} explicit UndirectedEdge(Node first, Node second); explicit UndirectedEdge(Node first, Node second, label::Label name); diff --git a/alib2data_experimental/src/graph/undirected/UndirectedGraph.cpp b/alib2data_experimental/src/graph/undirected/UndirectedGraph.cpp index 5da48a6540..1c324bf806 100644 --- a/alib2data_experimental/src/graph/undirected/UndirectedGraph.cpp +++ b/alib2data_experimental/src/graph/undirected/UndirectedGraph.cpp @@ -146,12 +146,12 @@ void UndirectedGraph::setEdgeValue( const UndirectedEdge & edge, int value ) std::unordered_map< Node, std::vector< Node > > UndirectedGraph::getEmbedding() const { - return embedding; + return m_embedding; } void UndirectedGraph::setEmbedding( const std::unordered_map< Node, std::vector< Node > > embedding ) { - this->embedding = embedding; + this->m_embedding = embedding; } int UndirectedGraph::compare( const UndirectedGraph & other ) const @@ -161,8 +161,8 @@ int UndirectedGraph::compare( const UndirectedGraph & other ) const std::set<Node> otherNodes = other.getNodes(); std::set<UndirectedEdge> otherEdges = other.getEdges(); - auto first = std::tie(thisNodes, thisEdges, nodeValues, edgeValues, embedding); - auto second = std::tie(otherNodes, otherEdges, other.nodeValues, other.edgeValues, other.embedding); + auto first = std::tie(thisNodes, thisEdges, nodeValues, edgeValues, m_embedding); + auto second = std::tie(otherNodes, otherEdges, other.nodeValues, other.edgeValues, other.m_embedding); std::compare<decltype(first)> comp; return comp(first, second); diff --git a/alib2data_experimental/src/graph/undirected/UndirectedGraph.h b/alib2data_experimental/src/graph/undirected/UndirectedGraph.h index ee4b48723e..f949ffdbde 100644 --- a/alib2data_experimental/src/graph/undirected/UndirectedGraph.h +++ b/alib2data_experimental/src/graph/undirected/UndirectedGraph.h @@ -26,7 +26,7 @@ class DirectedGraph; class UndirectedGraph : public GraphBase { std::unordered_map< Node, int > nodeValues; std::unordered_map< UndirectedEdge, int > edgeValues; - std::unordered_map< Node, std::vector< Node > > embedding; + std::unordered_map< Node, std::vector< Node > > m_embedding; public: UndirectedGraph(); diff --git a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieFinalMark.cpp b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieFinalMark.cpp index 402bdb084e..66865965c5 100644 --- a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieFinalMark.cpp +++ b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieFinalMark.cpp @@ -24,25 +24,25 @@ namespace indexes { SuffixTrieFinalMark::SuffixTrieFinalMark ( std::set < alphabet::Symbol > alphabet ) : SuffixTrieFinalMark ( std::move ( alphabet ), SuffixTrieNodeFinalMark ( { }, true ) ) { } -SuffixTrieFinalMark::SuffixTrieFinalMark ( std::set < alphabet::Symbol > alphabet, SuffixTrieNodeFinalMark tree ) : std::Components < SuffixTrieFinalMark, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ), tree ( NULL ) { +SuffixTrieFinalMark::SuffixTrieFinalMark ( std::set < alphabet::Symbol > alphabet, SuffixTrieNodeFinalMark tree ) : std::Components < SuffixTrieFinalMark, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( alphabet ) ), std::tuple < > ( ) ), m_tree ( NULL ) { setTree ( std::move ( tree ) ); } SuffixTrieFinalMark::SuffixTrieFinalMark ( SuffixTrieNodeFinalMark tree ) : SuffixTrieFinalMark ( tree.computeMinimalAlphabet ( ), tree ) { } -SuffixTrieFinalMark::SuffixTrieFinalMark ( const SuffixTrieTerminatingSymbol & other ) : std::Components < SuffixTrieFinalMark, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( other.getAlphabet ( ) ), std::tuple < > ( ) ), tree ( NULL ) { +SuffixTrieFinalMark::SuffixTrieFinalMark ( const SuffixTrieTerminatingSymbol & other ) : std::Components < SuffixTrieFinalMark, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( other.getAlphabet ( ) ), std::tuple < > ( ) ), m_tree ( NULL ) { this->accessComponent < GeneralAlphabet > ( ).remove ( other.accessElement < TerminatingSymbol > ( ).get ( ) ); setTree ( SuffixTrieNodeFinalMark ( other.getRoot ( ), other.accessElement < TerminatingSymbol > ( ).get ( ) ) ); } -SuffixTrieFinalMark::SuffixTrieFinalMark ( const SuffixTrieFinalMark & other ) : std::Components < SuffixTrieFinalMark, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( other.getAlphabet ( ) ), std::tuple < > ( ) ), tree ( other.tree->clone ( ) ) { - this->tree->attachTree ( this ); +SuffixTrieFinalMark::SuffixTrieFinalMark ( const SuffixTrieFinalMark & other ) : std::Components < SuffixTrieFinalMark, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( other.getAlphabet ( ) ), std::tuple < > ( ) ), m_tree ( other.m_tree->clone ( ) ) { + this->m_tree->attachTree ( this ); } -SuffixTrieFinalMark::SuffixTrieFinalMark ( SuffixTrieFinalMark && other ) noexcept : std::Components < SuffixTrieFinalMark, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( other.accessComponent < GeneralAlphabet > ( ).get ( ) ) ), std::tuple < > ( ) ), tree ( other.tree ) { - this->tree->attachTree ( this ); - other.tree = NULL; +SuffixTrieFinalMark::SuffixTrieFinalMark ( SuffixTrieFinalMark && other ) noexcept : std::Components < SuffixTrieFinalMark, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > ( std::make_tuple ( std::move ( other.accessComponent < GeneralAlphabet > ( ).get ( ) ) ), std::tuple < > ( ) ), m_tree ( other.m_tree ) { + this->m_tree->attachTree ( this ); + other.m_tree = NULL; } alib::ObjectBase * SuffixTrieFinalMark::clone ( ) const { @@ -63,36 +63,36 @@ SuffixTrieFinalMark & SuffixTrieFinalMark::operator =( const SuffixTrieFinalMark } SuffixTrieFinalMark & SuffixTrieFinalMark::operator =( SuffixTrieFinalMark && other ) noexcept { - std::swap ( this->tree, other.tree ); + std::swap ( this->m_tree, other.m_tree ); std::swap ( accessComponent < GeneralAlphabet > ( ).get ( ), other.accessComponent < GeneralAlphabet > ( ).get ( ) ); return * this; } SuffixTrieFinalMark::~SuffixTrieFinalMark ( ) noexcept { - delete tree; + delete m_tree; } const SuffixTrieNodeFinalMark & SuffixTrieFinalMark::getRoot ( ) const { - return * tree; + return * m_tree; } SuffixTrieNodeFinalMark & SuffixTrieFinalMark::getRoot ( ) { - return * tree; + return * m_tree; } void SuffixTrieFinalMark::setTree ( SuffixTrieNodeFinalMark tree ) { - delete this->tree; - this->tree = std::move ( tree ).plunder ( ); + delete this->m_tree; + this->m_tree = std::move ( tree ).plunder ( ); - if ( !this->tree->attachTree ( this ) ) { - delete this->tree; + if ( !this->m_tree->attachTree ( this ) ) { + delete this->m_tree; throw exception::CommonException ( "Input symbols not in the alphabet." ); } } void SuffixTrieFinalMark::operator >>( std::ostream & out ) const { - out << "(SuffixTrieFinalMark " << * ( this->tree ) << ")"; + out << "(SuffixTrieFinalMark " << * ( this->m_tree ) << ")"; } std::ostream & operator <<( std::ostream & out, const SuffixTrieFinalMark & instance ) { @@ -101,8 +101,8 @@ std::ostream & operator <<( std::ostream & out, const SuffixTrieFinalMark & inst } int SuffixTrieFinalMark::compare ( const SuffixTrieFinalMark & other ) const { - auto first = std::tie ( * tree, getAlphabet() ); - auto second = std::tie ( * other.tree, other.getAlphabet() ); + auto first = std::tie ( * m_tree, getAlphabet() ); + auto second = std::tie ( * other.m_tree, other.getAlphabet() ); std::compare < decltype ( first ) > comp; @@ -129,7 +129,7 @@ SuffixTrieFinalMark SuffixTrieFinalMark::parse ( std::deque < sax::Token >::iter void SuffixTrieFinalMark::compose ( std::deque < sax::Token > & out ) const { out.emplace_back ( SuffixTrieFinalMark::getXmlTagName(), sax::Token::TokenType::START_ELEMENT ); IndexToXMLComposer::composeAlphabet ( out, getAlphabet ( ) ); - IndexToXMLComposer::composeNode ( out, * tree ); + IndexToXMLComposer::composeNode ( out, * m_tree ); out.emplace_back ( SuffixTrieFinalMark::getXmlTagName(), sax::Token::TokenType::END_ELEMENT ); } diff --git a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieFinalMark.h b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieFinalMark.h index b36af5d782..390b806444 100644 --- a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieFinalMark.h +++ b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieFinalMark.h @@ -27,7 +27,7 @@ class GeneralAlphabet; */ class SuffixTrieFinalMark : public alib::ObjectBase, public std::Components < SuffixTrieFinalMark, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < > > { protected: - SuffixTrieNodeFinalMark * tree; + SuffixTrieNodeFinalMark * m_tree; public: /** diff --git a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeFinalMark.cpp b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeFinalMark.cpp index d9d27acd46..4d21c42572 100644 --- a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeFinalMark.cpp +++ b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeFinalMark.cpp @@ -13,43 +13,43 @@ namespace indexes { -SuffixTrieNodeFinalMark::SuffixTrieNodeFinalMark ( std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * > children, bool finalMark ) : children ( std::move ( children ) ), finalMark ( finalMark ), parentTree ( NULL ) { - for ( auto & element : this->children ) +SuffixTrieNodeFinalMark::SuffixTrieNodeFinalMark ( std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * > children, bool finalMark ) : m_children ( std::move ( children ) ), m_finalMark ( finalMark ), parentTree ( NULL ) { + for ( auto & element : this->m_children ) element.second->parent = this; this->attachTree ( NULL ); this->parent = NULL; } -SuffixTrieNodeFinalMark::SuffixTrieNodeFinalMark ( const SuffixTrieNodeTerminatingSymbol & other, const alphabet::Symbol & terminatingSymbol ) : finalMark ( false ), parentTree ( NULL ) { +SuffixTrieNodeFinalMark::SuffixTrieNodeFinalMark ( const SuffixTrieNodeTerminatingSymbol & other, const alphabet::Symbol & terminatingSymbol ) : m_finalMark ( false ), parentTree ( NULL ) { for ( auto & element : other.getChildren ( ) ) if ( element.first == terminatingSymbol ) - this->finalMark = true; + this->m_finalMark = true; else - this->children.insert ( std::make_pair ( element.first, new SuffixTrieNodeFinalMark ( * element.second, terminatingSymbol ) ) ); + this->m_children.insert ( std::make_pair ( element.first, new SuffixTrieNodeFinalMark ( * element.second, terminatingSymbol ) ) ); - for ( auto & element : this->children ) + for ( auto & element : this->m_children ) element.second->parent = this; this->attachTree ( NULL ); this->parent = NULL; } -SuffixTrieNodeFinalMark::SuffixTrieNodeFinalMark ( const SuffixTrieNodeFinalMark & other ) : finalMark ( other.finalMark ), parentTree ( NULL ) { - for ( const auto & element : other.children ) - children.insert ( std::make_pair ( element.first, element.second->clone ( ) ) ); +SuffixTrieNodeFinalMark::SuffixTrieNodeFinalMark ( const SuffixTrieNodeFinalMark & other ) : m_finalMark ( other.m_finalMark ), parentTree ( NULL ) { + for ( const auto & element : other.m_children ) + m_children.insert ( std::make_pair ( element.first, element.second->clone ( ) ) ); - for ( auto & element : this->children ) + for ( auto & element : this->m_children ) element.second->parent = this; this->attachTree ( NULL ); this->parent = NULL; } -SuffixTrieNodeFinalMark::SuffixTrieNodeFinalMark ( SuffixTrieNodeFinalMark && other ) noexcept : children ( std::move ( other.children ) ), finalMark ( other.finalMark ), parentTree ( NULL ) { - other.children.clear ( ); +SuffixTrieNodeFinalMark::SuffixTrieNodeFinalMark ( SuffixTrieNodeFinalMark && other ) noexcept : m_children ( std::move ( other.m_children ) ), m_finalMark ( other.m_finalMark ), parentTree ( NULL ) { + other.m_children.clear ( ); - for ( auto & element : this->children ) + for ( auto & element : this->m_children ) element.second->parent = this; this->attachTree ( NULL ); @@ -66,11 +66,11 @@ SuffixTrieNodeFinalMark & SuffixTrieNodeFinalMark::operator =( const SuffixTrieN } SuffixTrieNodeFinalMark & SuffixTrieNodeFinalMark::operator =( SuffixTrieNodeFinalMark && other ) noexcept { - std::swap ( this->children, other.children ); - std::swap ( this->finalMark, other.finalMark ); + std::swap ( this->m_children, other.m_children ); + std::swap ( this->m_finalMark, other.m_finalMark ); std::swap ( this->parentTree, other.parentTree ); // this->parentTree is stored within other.parentTree and it is reattached on the next line - for ( auto & element : this->children ) + for ( auto & element : this->m_children ) element.second->parent = this; this->attachTree ( other.parentTree ); @@ -79,58 +79,58 @@ SuffixTrieNodeFinalMark & SuffixTrieNodeFinalMark::operator =( SuffixTrieNodeFin } SuffixTrieNodeFinalMark::~SuffixTrieNodeFinalMark ( ) noexcept { - for ( auto element : children ) + for ( auto element : m_children ) delete element.second; - children.clear ( ); + m_children.clear ( ); } const std::map < const alphabet::Symbol, const SuffixTrieNodeFinalMark * > & SuffixTrieNodeFinalMark::getChildren ( ) const { - return * reinterpret_cast < const std::map < const alphabet::Symbol, const SuffixTrieNodeFinalMark * > * > ( & children ); + return * reinterpret_cast < const std::map < const alphabet::Symbol, const SuffixTrieNodeFinalMark * > * > ( & m_children ); } bool SuffixTrieNodeFinalMark::getFinalMark ( ) const { - return finalMark; + return m_finalMark; } void SuffixTrieNodeFinalMark::setFinalMark ( bool newFinalMark ) { - finalMark = newFinalMark; + m_finalMark = newFinalMark; } const std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * > & SuffixTrieNodeFinalMark::getChildren ( ) { - return children; + return m_children; } SuffixTrieNodeFinalMark & SuffixTrieNodeFinalMark::getChild ( const alphabet::Symbol & symbol ) { - std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * >::const_iterator iter = children.find ( symbol ); + std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * >::const_iterator iter = m_children.find ( symbol ); - if ( iter == children.end ( ) ) throw exception::CommonException ( "child does not exist" ); + if ( iter == m_children.end ( ) ) throw exception::CommonException ( "child does not exist" ); return * iter->second; } const SuffixTrieNodeFinalMark & SuffixTrieNodeFinalMark::getChild ( const alphabet::Symbol & symbol ) const { - std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * >::const_iterator iter = children.find ( symbol ); + std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * >::const_iterator iter = m_children.find ( symbol ); - if ( iter == children.end ( ) ) throw exception::CommonException ( "child does not exist" ); + if ( iter == m_children.end ( ) ) throw exception::CommonException ( "child does not exist" ); return * iter->second; } bool SuffixTrieNodeFinalMark::hasChild ( const alphabet::Symbol & symbol ) const { - if ( children.find ( symbol ) == children.end ( ) ) return false; + if ( m_children.find ( symbol ) == m_children.end ( ) ) return false; return true; } SuffixTrieNodeFinalMark & SuffixTrieNodeFinalMark::addChild ( alphabet::Symbol symbol, SuffixTrieNodeFinalMark node ) { - std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * >::iterator iter = children.find ( symbol ); + std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * >::iterator iter = m_children.find ( symbol ); - if ( iter != children.end ( ) ) throw exception::CommonException ( "child already exist" ); + if ( iter != m_children.end ( ) ) throw exception::CommonException ( "child already exist" ); if ( ( this->parentTree != NULL ) && ! ( this->parentTree->getAlphabet ( ).count ( symbol ) ) ) throw exception::CommonException ( "Symbol is not in the alphabet" ); - return * children.insert ( std::make_pair ( std::move ( symbol ), new SuffixTrieNodeFinalMark ( std::move ( node ) ) ) ).first->second; + return * m_children.insert ( std::make_pair ( std::move ( symbol ), new SuffixTrieNodeFinalMark ( std::move ( node ) ) ) ).first->second; } SuffixTrieNodeFinalMark * SuffixTrieNodeFinalMark::getParent ( ) { @@ -172,7 +172,7 @@ int SuffixTrieNodeFinalMark::compare ( const SuffixTrieNodeFinalMark & other ) c } void SuffixTrieNodeFinalMark::operator >>( std::ostream & out ) const { - out << "(SuffixTrieNodeFinalMark " << " children = " << this->children << " finalMark = " << this->finalMark << ")"; + out << "(SuffixTrieNodeFinalMark " << " children = " << this->m_children << " finalMark = " << this->m_finalMark << ")"; } std::ostream & operator <<( std::ostream & out, const SuffixTrieNodeFinalMark & node ) { @@ -181,7 +181,7 @@ std::ostream & operator <<( std::ostream & out, const SuffixTrieNodeFinalMark & } bool SuffixTrieNodeFinalMark::testSymbol ( const alphabet::Symbol & symbol ) const { - for ( const auto & child : this->children ) { + for ( const auto & child : this->m_children ) { if ( symbol == child.first ) return true; if ( child.second->testSymbol ( symbol ) ) return true; @@ -195,7 +195,7 @@ bool SuffixTrieNodeFinalMark::attachTree ( const SuffixTrieFinalMark * tree ) { this->parentTree = tree; - for ( const auto & child : this->children ) { + for ( const auto & child : this->m_children ) { if ( ( this->parentTree != NULL ) && ! ( this->parentTree->getAlphabet ( ).count ( child.first ) ) ) return false; if ( !child.second->attachTree ( tree ) ) return false; @@ -211,7 +211,7 @@ std::set < alphabet::Symbol > SuffixTrieNodeFinalMark::computeMinimalAlphabet ( } void SuffixTrieNodeFinalMark::computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const { - for ( const auto & child : this->children ) { + for ( const auto & child : this->m_children ) { alphabet.insert ( child.first ); child.second->computeMinimalAlphabet ( alphabet ); } diff --git a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeFinalMark.h b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeFinalMark.h index 7cf83353da..e38d6e6fa6 100644 --- a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeFinalMark.h +++ b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeFinalMark.h @@ -23,9 +23,9 @@ class SuffixTrieFinalMark; */ class SuffixTrieNodeFinalMark { protected: - std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * > children; + std::map < alphabet::Symbol, SuffixTrieNodeFinalMark * > m_children; - bool finalMark; + bool m_finalMark; SuffixTrieNodeFinalMark * parent; diff --git a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.cpp b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.cpp index d9aa72926a..0c35a339c1 100644 --- a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.cpp +++ b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.cpp @@ -12,8 +12,8 @@ namespace indexes { -SuffixTrieNodeTerminatingSymbol::SuffixTrieNodeTerminatingSymbol ( std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * > children ) : children ( std::move ( children ) ), parentTree ( NULL ) { - for ( auto & element : this->children ) +SuffixTrieNodeTerminatingSymbol::SuffixTrieNodeTerminatingSymbol ( std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * > children ) : m_children ( std::move ( children ) ), parentTree ( NULL ) { + for ( auto & element : this->m_children ) element.second->parent = this; this->attachTree ( NULL ); @@ -21,20 +21,20 @@ SuffixTrieNodeTerminatingSymbol::SuffixTrieNodeTerminatingSymbol ( std::map < al } SuffixTrieNodeTerminatingSymbol::SuffixTrieNodeTerminatingSymbol ( const SuffixTrieNodeTerminatingSymbol & other ) : parentTree ( NULL ) { - for ( const auto & element : other.children ) - children.insert ( std::make_pair ( element.first, element.second->clone ( ) ) ); + for ( const auto & element : other.m_children ) + m_children.insert ( std::make_pair ( element.first, element.second->clone ( ) ) ); - for ( auto & element : this->children ) + for ( auto & element : this->m_children ) element.second->parent = this; this->attachTree ( NULL ); this->parent = NULL; } -SuffixTrieNodeTerminatingSymbol::SuffixTrieNodeTerminatingSymbol ( SuffixTrieNodeTerminatingSymbol && other ) noexcept : children ( std::move ( other.children ) ), parentTree ( NULL ) { - other.children.clear ( ); +SuffixTrieNodeTerminatingSymbol::SuffixTrieNodeTerminatingSymbol ( SuffixTrieNodeTerminatingSymbol && other ) noexcept : m_children ( std::move ( other.m_children ) ), parentTree ( NULL ) { + other.m_children.clear ( ); - for ( auto & element : this->children ) + for ( auto & element : this->m_children ) element.second->parent = this; this->attachTree ( NULL ); @@ -51,10 +51,10 @@ SuffixTrieNodeTerminatingSymbol & SuffixTrieNodeTerminatingSymbol::operator =( c } SuffixTrieNodeTerminatingSymbol & SuffixTrieNodeTerminatingSymbol::operator =( SuffixTrieNodeTerminatingSymbol && other ) noexcept { - std::swap ( this->children, other.children ); + std::swap ( this->m_children, other.m_children ); std::swap ( this->parentTree, other.parentTree ); // this->parentTree is stored within other.parentTree and it is reattached on the next line - for ( auto & element : this->children ) + for ( auto & element : this->m_children ) element.second->parent = this; this->attachTree ( other.parentTree ); @@ -63,50 +63,50 @@ SuffixTrieNodeTerminatingSymbol & SuffixTrieNodeTerminatingSymbol::operator =( S } SuffixTrieNodeTerminatingSymbol::~SuffixTrieNodeTerminatingSymbol ( ) noexcept { - for ( auto element : children ) + for ( auto element : m_children ) delete element.second; - children.clear ( ); + m_children.clear ( ); } const std::map < const alphabet::Symbol, const SuffixTrieNodeTerminatingSymbol * > & SuffixTrieNodeTerminatingSymbol::getChildren ( ) const { - return * reinterpret_cast < const std::map < const alphabet::Symbol, const SuffixTrieNodeTerminatingSymbol * > * > ( & children ); + return * reinterpret_cast < const std::map < const alphabet::Symbol, const SuffixTrieNodeTerminatingSymbol * > * > ( & m_children ); } const std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * > & SuffixTrieNodeTerminatingSymbol::getChildren ( ) { - return children; + return m_children; } SuffixTrieNodeTerminatingSymbol & SuffixTrieNodeTerminatingSymbol::getChild ( const alphabet::Symbol & symbol ) { - std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * >::const_iterator iter = children.find ( symbol ); + std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * >::const_iterator iter = m_children.find ( symbol ); - if ( iter == children.end ( ) ) throw exception::CommonException ( "child does not exist" ); + if ( iter == m_children.end ( ) ) throw exception::CommonException ( "child does not exist" ); return * iter->second; } const SuffixTrieNodeTerminatingSymbol & SuffixTrieNodeTerminatingSymbol::getChild ( const alphabet::Symbol & symbol ) const { - std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * >::const_iterator iter = children.find ( symbol ); + std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * >::const_iterator iter = m_children.find ( symbol ); - if ( iter == children.end ( ) ) throw exception::CommonException ( "child does not exist" ); + if ( iter == m_children.end ( ) ) throw exception::CommonException ( "child does not exist" ); return * iter->second; } bool SuffixTrieNodeTerminatingSymbol::hasChild ( const alphabet::Symbol & symbol ) const { - if ( children.find ( symbol ) == children.end ( ) ) return false; + if ( m_children.find ( symbol ) == m_children.end ( ) ) return false; return true; } SuffixTrieNodeTerminatingSymbol & SuffixTrieNodeTerminatingSymbol::addChild ( alphabet::Symbol symbol, SuffixTrieNodeTerminatingSymbol node ) { - std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * >::iterator iter = children.find ( symbol ); + std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * >::iterator iter = m_children.find ( symbol ); - if ( iter != children.end ( ) ) throw exception::CommonException ( "child already exist" ); + if ( iter != m_children.end ( ) ) throw exception::CommonException ( "child already exist" ); if ( ( this->parentTree != NULL ) && ! ( this->parentTree->getAlphabet ( ).count ( symbol ) ) ) throw exception::CommonException ( "Symbol is not in the alphabet" ); - return * children.insert ( std::make_pair ( std::move ( symbol ), new SuffixTrieNodeTerminatingSymbol ( std::move ( node ) ) ) ).first->second; + return * m_children.insert ( std::make_pair ( std::move ( symbol ), new SuffixTrieNodeTerminatingSymbol ( std::move ( node ) ) ) ).first->second; } SuffixTrieNodeTerminatingSymbol * SuffixTrieNodeTerminatingSymbol::getParent ( ) { @@ -148,7 +148,7 @@ int SuffixTrieNodeTerminatingSymbol::compare ( const SuffixTrieNodeTerminatingSy } void SuffixTrieNodeTerminatingSymbol::operator >>( std::ostream & out ) const { - out << "(SuffixTrieNodeTerminatingSymbol " << " children = " << this->children << ")"; + out << "(SuffixTrieNodeTerminatingSymbol " << " children = " << this->m_children << ")"; } std::ostream & operator <<( std::ostream & out, const SuffixTrieNodeTerminatingSymbol & node ) { @@ -157,7 +157,7 @@ std::ostream & operator <<( std::ostream & out, const SuffixTrieNodeTerminatingS } bool SuffixTrieNodeTerminatingSymbol::testSymbol ( const alphabet::Symbol & symbol ) const { - for ( const auto & child : this->children ) { + for ( const auto & child : this->m_children ) { if ( symbol == child.first ) return true; if ( child.second->testSymbol ( symbol ) ) return true; @@ -171,7 +171,7 @@ bool SuffixTrieNodeTerminatingSymbol::attachTree ( const SuffixTrieTerminatingSy this->parentTree = tree; - for ( const auto & child : this->children ) { + for ( const auto & child : this->m_children ) { if ( ( this->parentTree != NULL ) && ! ( this->parentTree->getAlphabet ( ).count ( child.first ) ) ) return false; if ( !child.second->attachTree ( tree ) ) return false; @@ -187,7 +187,7 @@ std::set < alphabet::Symbol > SuffixTrieNodeTerminatingSymbol::computeMinimalAlp } void SuffixTrieNodeTerminatingSymbol::computeMinimalAlphabet ( std::set < alphabet::Symbol > & alphabet ) const { - for ( const auto & child : this->children ) { + for ( const auto & child : this->m_children ) { alphabet.insert ( child.first ); child.second->computeMinimalAlphabet ( alphabet ); } diff --git a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.h b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.h index 0963abc0b4..86aabe375a 100644 --- a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.h +++ b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieNodeTerminatingSymbol.h @@ -22,7 +22,7 @@ class SuffixTrieTerminatingSymbol; */ class SuffixTrieNodeTerminatingSymbol { protected: - std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * > children; + std::map < alphabet::Symbol, SuffixTrieNodeTerminatingSymbol * > m_children; SuffixTrieNodeTerminatingSymbol * parent; diff --git a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.cpp b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.cpp index 6070e4429e..6da2e7d97b 100644 --- a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.cpp +++ b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.cpp @@ -23,20 +23,20 @@ namespace indexes { SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( std::set < alphabet::Symbol > alphabet, alphabet::Symbol terminatingSymbol ) : SuffixTrieTerminatingSymbol ( std::move ( alphabet ), std::move ( terminatingSymbol ), SuffixTrieNodeTerminatingSymbol ( { } ) ) { } -SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( std::set < alphabet::Symbol > alphabet, alphabet::Symbol terminatingSymbol, SuffixTrieNodeTerminatingSymbol tree ) : std::Components < SuffixTrieTerminatingSymbol, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < TerminatingSymbol > > ( std::make_tuple ( std::move ( alphabet ) ), std::make_tuple ( std::move ( terminatingSymbol ) ) ), tree ( NULL ) { +SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( std::set < alphabet::Symbol > alphabet, alphabet::Symbol terminatingSymbol, SuffixTrieNodeTerminatingSymbol tree ) : std::Components < SuffixTrieTerminatingSymbol, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < TerminatingSymbol > > ( std::make_tuple ( std::move ( alphabet ) ), std::make_tuple ( std::move ( terminatingSymbol ) ) ), m_tree ( NULL ) { setTree ( std::move ( tree ) ); } SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( alphabet::Symbol terminatingSymbol, SuffixTrieNodeTerminatingSymbol tree ) : SuffixTrieTerminatingSymbol ( tree.computeMinimalAlphabet ( ) + std::set < alphabet::Symbol > { terminatingSymbol }, terminatingSymbol, tree ) { } -SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( const SuffixTrieTerminatingSymbol & other ) : std::Components < SuffixTrieTerminatingSymbol, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < TerminatingSymbol > > ( std::make_tuple ( other.getAlphabet ( ) ), std::make_tuple ( other.getTerminatingSymbol ( ) ) ), tree ( other.tree->clone ( ) ) { - this->tree->attachTree ( this ); +SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( const SuffixTrieTerminatingSymbol & other ) : std::Components < SuffixTrieTerminatingSymbol, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < TerminatingSymbol > > ( std::make_tuple ( other.getAlphabet ( ) ), std::make_tuple ( other.getTerminatingSymbol ( ) ) ), m_tree ( other.m_tree->clone ( ) ) { + this->m_tree->attachTree ( this ); } -SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( SuffixTrieTerminatingSymbol && other ) noexcept : std::Components < SuffixTrieTerminatingSymbol, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < TerminatingSymbol > > ( std::make_tuple ( std::move ( other.accessComponent < GeneralAlphabet > ( ).get ( ) ) ), std::make_tuple ( std::move ( other.accessElement < TerminatingSymbol > ( ).get ( ) ) ) ), tree ( other.tree ) { - this->tree->attachTree ( this ); - other.tree = NULL; +SuffixTrieTerminatingSymbol::SuffixTrieTerminatingSymbol ( SuffixTrieTerminatingSymbol && other ) noexcept : std::Components < SuffixTrieTerminatingSymbol, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < TerminatingSymbol > > ( std::make_tuple ( std::move ( other.accessComponent < GeneralAlphabet > ( ).get ( ) ) ), std::make_tuple ( std::move ( other.accessElement < TerminatingSymbol > ( ).get ( ) ) ) ), m_tree ( other.m_tree ) { + this->m_tree->attachTree ( this ); + other.m_tree = NULL; } alib::ObjectBase * SuffixTrieTerminatingSymbol::clone ( ) const { @@ -57,7 +57,7 @@ SuffixTrieTerminatingSymbol & SuffixTrieTerminatingSymbol::operator =( const Suf } SuffixTrieTerminatingSymbol & SuffixTrieTerminatingSymbol::operator =( SuffixTrieTerminatingSymbol && other ) noexcept { - std::swap ( this->tree, other.tree ); + std::swap ( this->m_tree, other.m_tree ); std::swap ( accessComponent < GeneralAlphabet > ( ).get ( ), other.accessComponent < GeneralAlphabet > ( ).get ( ) ); std::swap ( accessElement < TerminatingSymbol > ( ).get ( ), other.accessElement < TerminatingSymbol > ( ).get ( ) ); @@ -65,29 +65,29 @@ SuffixTrieTerminatingSymbol & SuffixTrieTerminatingSymbol::operator =( SuffixTri } SuffixTrieTerminatingSymbol::~SuffixTrieTerminatingSymbol ( ) noexcept { - delete tree; + delete m_tree; } const SuffixTrieNodeTerminatingSymbol & SuffixTrieTerminatingSymbol::getRoot ( ) const { - return * tree; + return * m_tree; } SuffixTrieNodeTerminatingSymbol & SuffixTrieTerminatingSymbol::getRoot ( ) { - return * tree; + return * m_tree; } void SuffixTrieTerminatingSymbol::setTree ( SuffixTrieNodeTerminatingSymbol tree ) { - delete this->tree; - this->tree = std::move ( tree ).plunder ( ); + delete this->m_tree; + this->m_tree = std::move ( tree ).plunder ( ); - if ( !this->tree->attachTree ( this ) ) { - delete this->tree; + if ( !this->m_tree->attachTree ( this ) ) { + delete this->m_tree; throw exception::CommonException ( "Input symbols not in the alphabet." ); } } void SuffixTrieTerminatingSymbol::operator >>( std::ostream & out ) const { - out << "(SuffixTrieTerminatingSymbol " << * ( this->tree ) << ")"; + out << "(SuffixTrieTerminatingSymbol " << * ( this->m_tree ) << ")"; } std::ostream & operator <<( std::ostream & out, const SuffixTrieTerminatingSymbol & instance ) { @@ -96,8 +96,8 @@ std::ostream & operator <<( std::ostream & out, const SuffixTrieTerminatingSymbo } int SuffixTrieTerminatingSymbol::compare ( const SuffixTrieTerminatingSymbol & other ) const { - auto first = std::tie ( * tree, getAlphabet(), getTerminatingSymbol() ); - auto second = std::tie ( * other.tree, other.getAlphabet(), other.getTerminatingSymbol() ); + auto first = std::tie ( * m_tree, getAlphabet(), getTerminatingSymbol() ); + auto second = std::tie ( * other.m_tree, other.getAlphabet(), other.getTerminatingSymbol() ); std::compare < decltype ( first ) > comp; @@ -126,7 +126,7 @@ void SuffixTrieTerminatingSymbol::compose ( std::deque < sax::Token > & out ) co out.emplace_back ( SuffixTrieTerminatingSymbol::getXmlTagName(), sax::Token::TokenType::START_ELEMENT ); IndexToXMLComposer::composeAlphabet ( out, getAlphabet ( ) ); alib::xmlApi < alphabet::Symbol >::compose ( out, getTerminatingSymbol ( ) ); - IndexToXMLComposer::composeNode ( out, * tree ); + IndexToXMLComposer::composeNode ( out, * m_tree ); out.emplace_back ( SuffixTrieTerminatingSymbol::getXmlTagName(), sax::Token::TokenType::END_ELEMENT ); } diff --git a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.h b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.h index 80973e7880..75bea8fbba 100644 --- a/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.h +++ b/alib2data_experimental/src/indexes/suffixTrie/SuffixTrieTerminatingSymbol.h @@ -27,7 +27,7 @@ class TerminatingSymbol; */ class SuffixTrieTerminatingSymbol : public alib::ObjectBase, public std::Components < SuffixTrieTerminatingSymbol, alphabet::Symbol, std::tuple < GeneralAlphabet >, std::tuple < TerminatingSymbol > > { protected: - SuffixTrieNodeTerminatingSymbol * tree; + SuffixTrieNodeTerminatingSymbol * m_tree; public: /** diff --git a/alib2data_experimental/src/string/LinearStringTerminatingSymbol.cpp b/alib2data_experimental/src/string/LinearStringTerminatingSymbol.cpp index cb33cdb695..54efb98850 100644 --- a/alib2data_experimental/src/string/LinearStringTerminatingSymbol.cpp +++ b/alib2data_experimental/src/string/LinearStringTerminatingSymbol.cpp @@ -32,7 +32,7 @@ LinearStringTerminatingSymbol::LinearStringTerminatingSymbol ( alphabet::Symbol LinearStringTerminatingSymbol::LinearStringTerminatingSymbol ( alphabet::Symbol terminatingSymbol, std::vector < alphabet::Symbol > data ) : LinearStringTerminatingSymbol ( std::set < alphabet::Symbol > ( data.begin ( ), data.end ( ) ) + std::set < alphabet::Symbol > { terminatingSymbol }, terminatingSymbol, data ) { } -LinearStringTerminatingSymbol::LinearStringTerminatingSymbol ( alphabet::Symbol terminatingSymbol, const LinearString < > & string ) : LinearStringTerminatingSymbol ( string.getAlphabet( ), std::move ( terminatingSymbol ), string.getContent ( ) ) { +LinearStringTerminatingSymbol::LinearStringTerminatingSymbol ( alphabet::Symbol terminatingSymbol, const LinearString < > & str ) : LinearStringTerminatingSymbol ( str.getAlphabet( ), std::move ( terminatingSymbol ), str.getContent ( ) ) { } StringBase * LinearStringTerminatingSymbol::clone ( ) const { diff --git a/alib2data_experimental/src/string/LinearStringTerminatingSymbol.h b/alib2data_experimental/src/string/LinearStringTerminatingSymbol.h index f5df2c010c..0d7da3741e 100644 --- a/alib2data_experimental/src/string/LinearStringTerminatingSymbol.h +++ b/alib2data_experimental/src/string/LinearStringTerminatingSymbol.h @@ -34,7 +34,7 @@ public: explicit LinearStringTerminatingSymbol ( alphabet::Symbol terminatingSymbol ); explicit LinearStringTerminatingSymbol ( std::set < alphabet::Symbol > alphabet, alphabet::Symbol terminatingSymbol, std::vector < alphabet::Symbol > data ); explicit LinearStringTerminatingSymbol ( alphabet::Symbol terminatingSymbol, std::vector < alphabet::Symbol > data ); - explicit LinearStringTerminatingSymbol ( alphabet::Symbol terminatingSymbol, const LinearString < > & string ); + explicit LinearStringTerminatingSymbol ( alphabet::Symbol terminatingSymbol, const LinearString < > & str ); virtual StringBase * clone ( ) const; virtual StringBase * plunder ( ) &&; @@ -98,8 +98,8 @@ namespace std { template < > class ComponentConstraint< ::string::LinearStringTerminatingSymbol, alphabet::Symbol, ::string::GeneralAlphabet > { public: - static bool used ( const ::string::LinearStringTerminatingSymbol & string, const alphabet::Symbol & symbol ) { - const std::vector<alphabet::Symbol>& content = string.getContent ( ); + static bool used ( const ::string::LinearStringTerminatingSymbol & str, const alphabet::Symbol & symbol ) { + const std::vector<alphabet::Symbol>& content = str.getContent ( ); return std::find(content.begin(), content.end(), symbol) != content.end(); } @@ -114,8 +114,8 @@ public: template < > class ElementConstraint< ::string::LinearStringTerminatingSymbol, alphabet::Symbol, ::string::TerminatingSymbol > { public: - static bool available ( const ::string::LinearStringTerminatingSymbol & string, const alphabet::Symbol & symbol ) { - return string.getAlphabet ( ).count ( symbol ); + static bool available ( const ::string::LinearStringTerminatingSymbol & str, const alphabet::Symbol & symbol ) { + return str.getAlphabet ( ).count ( symbol ); } static void valid ( const ::string::LinearStringTerminatingSymbol &, const alphabet::Symbol & ) { -- GitLab