diff --git a/alib2common/src/container/Container.h b/alib2common/src/container/Container.h deleted file mode 100644 index bd68518c17273f856ad623c83ec7a752ac1db78f..0000000000000000000000000000000000000000 --- a/alib2common/src/container/Container.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Container.h - * - * Created on: Apr 10, 2013 - * Author: Jan Travnicek - */ - -#ifndef CONTAINER_H_ -#define CONTAINER_H_ - -namespace container { - -/** - * Wrapper around containers. - */ -class Container; - -} /* namespace container */ - -#endif /* CONTAINER_H_ */ diff --git a/alib2common/src/container/ContainerBase.h b/alib2common/src/container/ContainerBase.h deleted file mode 100644 index c69357701eff09286418e9c5fd5eb563bbe4477c..0000000000000000000000000000000000000000 --- a/alib2common/src/container/ContainerBase.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ContainerBase.h - * - * This file is part of Algorithms library toolkit. - * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz) - - * Algorithms library toolkit is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * Algorithms library toolkit is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>. - * - * Created on: Mar 26, 2013 - * Author: Jan Travnicek - */ - -#ifndef CONTAINER_BASE_H_ -#define CONTAINER_BASE_H_ - -#include <object/ObjectBase.h> - -namespace container { - -/** - * \brief Represents base for a concrete container type. - */ -class ContainerBase : public object::ObjectBase { -public: - /** - * @copydoc ObjectBase::clone ( ) const & - */ - virtual ContainerBase* clone ( ) const & override = 0; - - /** - * @copydoc ObjectBase::clone ( ) && - */ - virtual ContainerBase* clone() && override = 0; - -}; - -} /* namespace container */ - -#endif /* CONTAINER_BASE_H_ */ diff --git a/alib2common/src/container/ObjectsTree.cpp b/alib2common/src/container/ObjectsTree.cpp deleted file mode 100644 index bc2c842fca5ac6ffb25074886e2291c8754df602..0000000000000000000000000000000000000000 --- a/alib2common/src/container/ObjectsTree.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* - * ObjectsTree.cpp - * - * Created on: Apr 1, 2013 - * Author: Jan Travnicek - */ - -#include "ObjectsTree.h" -#include <registration/ValuePrinterRegistration.hpp> - -namespace { - -static auto valuePrinter = registration::ValuePrinterRegister < container::ObjectsTree < > > ( ); - -} /* namespace */ diff --git a/alib2common/src/container/ObjectsTree.h b/alib2common/src/container/ObjectsTree.h deleted file mode 100644 index 323a70a9ee023bd8845b3a17badc66c86a30d5f9..0000000000000000000000000000000000000000 --- a/alib2common/src/container/ObjectsTree.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - * ObjectsTree.h - * - * This file is part of Algorithms library toolkit. - * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz) - - * Algorithms library toolkit is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * Algorithms library toolkit is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>. - * - * Created on: Apr 1, 2013 - * Author: Jan Travnicek - */ - -#ifndef OBJECTS_TREE_H_ -#define OBJECTS_TREE_H_ - -#include <alib/tree> -#include <alib/string> -#include <sstream> - -#include "ContainerBase.h" - -#include <object/UniqueObject.h> -#include <object/ObjectFactory.h> - -#include <core/normalize.hpp> - -namespace container { - -/** - * \brief - * Represents an adaptor of a tree container from the stl extensions provided by the algorithms library. - * - * The tree is a structured random access container. - * - * \tparam ElementType the type of values in the tree nodes. - */ -template < class ElementType = object::Object > -class ObjectsTree final : public ext::tree < ElementType >, public ContainerBase { -public: - /** - * \brief - * Creates a new instance of the tree container wrapper based on the tree datatype from stl extensions of the algorithms library. - * - * \param raw the extended tree contaier - */ - explicit ObjectsTree ( ext::tree < ElementType > raw ); - - /** - * @copydoc alphabet::ContainerBase::clone ( ) const & - */ - virtual ContainerBase * clone ( ) const & override; - - /** - * @copydoc alphabet::ContainerBase::clone ( ) && - */ - virtual ContainerBase * clone ( ) && override; - - /** - * @copydoc base::CommonBase < ObjectBase >::compare ( const ObjectBase & ) const - */ - virtual int compare ( const ObjectBase & other ) const override { - if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); - - return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) ); - } - - /** - * The actual compare method - * - * \param other the other instance - * - * \returns the actual relation between two by type same containers - */ - int compare ( const ObjectsTree & other ) const; - - /** - * @copydoc base::CommonBase < ObjectBase >::operator >> ( std::ostream & ) const - */ - virtual void operator >>( std::ostream & os ) const override; - - /** - * @copydoc base::CommonBase < ObjectBase >::operator std::string ( ) const - */ - virtual explicit operator std::string ( ) const override; - - /** - * @copydoc object::ObjectBase::inc ( ) && - */ - virtual object::ObjectBase * inc ( ) && override; -}; - -template < class ElementType > -ObjectsTree < ElementType >::ObjectsTree ( ext::tree < ElementType > raw ) : ext::tree < ElementType > ( std::move ( raw ) ) { -} - -template < class ElementType > -ContainerBase * ObjectsTree < ElementType >::clone ( ) const & { - return new ObjectsTree ( * this ); -} - -template < class ElementType > -ContainerBase * ObjectsTree < ElementType >::clone ( ) && { - return new ObjectsTree ( std::move ( * this ) ); -} - -template < class ElementType > -int ObjectsTree < ElementType >::compare ( const ObjectsTree & other ) const { - static ext::compare < ext::tree < ElementType > > comp; - - return comp ( static_cast < const ext::tree < ElementType > & > ( * this ), static_cast < const ext::tree < ElementType > & > ( other ) ); -} - -template < class ElementType > -void ObjectsTree < ElementType >::operator >>( std::ostream & os ) const { - os << "(ObjectsTree " << static_cast < const ext::tree < ElementType > & > ( * this ) << ")"; -} - -template < class ElementType > -ObjectsTree < ElementType >::operator std::string ( ) const { - std::stringstream ss; - ss << * this; - return std::move ( ss ).str ( ); -} - -template < class ElementType > -object::ObjectBase* ObjectsTree < ElementType >::inc() && { - return new object::UniqueObject(object::Object(std::move(*this)), primitive::Integer(0)); -} - -} /* namespace container */ - -namespace core { - -template < class ElementType > -struct normalize < container::ObjectsTree < ElementType > > { - static ext::tree < object::Object > raw ( ext::tree < ElementType > && source ) { - ext::vector < ext::tree < object::Object > > children; - - for ( ext::tree < ElementType > & child : source.getChildren ( ) ) { - children.push_back ( raw ( std::move ( child ) ) ); - } - - return ext::tree < object::Object > ( object::ObjectFactory::make ( std::move ( source.getData ( ) ) ), std::move ( children ) ); - } - - static container::ObjectsTree < > eval ( container::ObjectsTree < ElementType > && value ) { - return container::ObjectsTree < > ( raw ( std::move ( value ) ) ); - } -}; - -} /* namespace core */ - -#endif /* OBJECTS_TREE_H_ */ diff --git a/alib2common/src/container/ObjectsTrie.cpp b/alib2common/src/container/ObjectsTrie.cpp deleted file mode 100644 index 12c1453f22ab943d9daeb5a733526546f566ce8f..0000000000000000000000000000000000000000 --- a/alib2common/src/container/ObjectsTrie.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* - * ObjectsTrie.cpp - * - * Created on: Apr 1, 2013 - * Author: Jan Travnicek - */ - -#include "ObjectsTrie.h" -#include <registration/ValuePrinterRegistration.hpp> - -namespace { - -static auto valuePrinter = registration::ValuePrinterRegister < container::ObjectsTrie < > > ( ); - -} /* namespace */ diff --git a/alib2common/src/container/ObjectsTrie.h b/alib2common/src/container/ObjectsTrie.h deleted file mode 100644 index d357072f03ff5c980283dab3f6577f7473666e7c..0000000000000000000000000000000000000000 --- a/alib2common/src/container/ObjectsTrie.h +++ /dev/null @@ -1,165 +0,0 @@ -/* - * ObjectsTrie.h - * - * This file is part of Algorithms library toolkit. - * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz) - - * Algorithms library toolkit is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * Algorithms library toolkit is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>. - * - * Created on: Apr 1, 2013 - * Author: Jan Travnicek - */ - -#ifndef OBJECTS_TRIE_H_ -#define OBJECTS_TRIE_H_ - -#include <alib/trie> -#include <alib/string> -#include <sstream> - -#include "ContainerBase.h" - -#include <object/UniqueObject.h> -#include <object/ObjectFactory.h> - -#include <core/normalize.hpp> - -namespace container { - -/** - * \brief - * Represents an adaptor of a trie container from the stl extensions provided by the algorithms library. - * - * The trie is an structured associative container. - * - * \tparam KeyType the type of keys to access subnodes of a trie node. - * \tparam ValueType the type of values in the trie nodes. - */ -template < class KeyType = object::Object, class ValueType = object::Object > -class ObjectsTrie final : public ext::trie < KeyType, ValueType >, public ContainerBase { -public: - /** - * \brief - * Creates a new instance of the trie container wrapper based on the tree datatype from stl extensions of the algorithms library. - * - * \param raw the extended tree contaier - */ - explicit ObjectsTrie ( ext::trie < KeyType, ValueType > raw ); - - /** - * @copydoc alphabet::ContainerBase::clone ( ) const & - */ - virtual ContainerBase * clone ( ) const & override; - - /** - * @copydoc alphabet::ContainerBase::clone ( ) && - */ - virtual ContainerBase * clone ( ) && override; - - /** - * @copydoc base::CommonBase < ObjectBase >::compare ( const ObjectBase & ) const - */ - virtual int compare ( const ObjectBase & other ) const override { - if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other ); - - return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) ); - } - - /** - * The actual compare method - * - * \param other the other instance - * - * \returns the actual relation between two by type same containers - */ - int compare ( const ObjectsTrie & other ) const; - - /** - * @copydoc base::CommonBase < ObjectBase >::operator >> ( std::ostream & ) const - */ - virtual void operator >>( std::ostream & os ) const override; - - /** - * @copydoc base::CommonBase < ObjectBase >::operator std::string ( ) const - */ - virtual explicit operator std::string ( ) const override; - - /** - * @copydoc object::ObjectBase::inc ( ) && - */ - virtual object::ObjectBase * inc ( ) && override; -}; - -template < class KeyType, class ValueType > -ObjectsTrie < KeyType, ValueType >::ObjectsTrie ( ext::trie < KeyType, ValueType > raw ) : ext::trie < KeyType, ValueType > ( std::move ( raw ) ) { -} - -template < class KeyType, class ValueType > -ContainerBase * ObjectsTrie < KeyType, ValueType >::clone ( ) const & { - return new ObjectsTrie ( * this ); -} - -template < class KeyType, class ValueType > -ContainerBase * ObjectsTrie < KeyType, ValueType >::clone ( ) && { - return new ObjectsTrie ( std::move ( * this ) ); -} - -template < class KeyType, class ValueType > -int ObjectsTrie < KeyType, ValueType >::compare ( const ObjectsTrie & other ) const { - static ext::compare < ext::trie < KeyType, ValueType > > comp; - - return comp ( static_cast < const ext::trie < KeyType, ValueType > & > ( * this ), static_cast < const ext::trie < KeyType, ValueType > & > ( other ) ); -} - -template < class KeyType, class ValueType > -void ObjectsTrie < KeyType, ValueType >::operator >>( std::ostream & os ) const { - os << "(ObjectsTrie " << static_cast < const ext::trie < KeyType, ValueType > & > ( * this ) << ")"; -} - -template < class KeyType, class ValueType > -ObjectsTrie < KeyType, ValueType >::operator std::string ( ) const { - std::stringstream ss; - ss << * this; - return std::move ( ss ).str ( ); -} - -template < class KeyType, class ValueType > -object::ObjectBase* ObjectsTrie < KeyType, ValueType >::inc() && { - return new object::UniqueObject(object::Object(std::move(*this)), primitive::Integer(0)); -} - -} /* namespace container */ - -namespace core { - -template < class KeyType, class ValueType > -struct normalize < container::ObjectsTrie < KeyType, ValueType > > { - static ext::trie < object::Object, object::Object > raw ( ext::trie < KeyType, ValueType > && source ) { - ext::map < object::Object, ext::trie < object::Object, object::Object > > children; - - for ( std::pair < KeyType, ext::trie < KeyType, ValueType > > && child : ext::make_mover ( source.getChildren ( ) ) ) { - children.insert ( std::make_pair ( object::ObjectFactory::make ( std::move ( child.first ) ), raw ( std::move ( child.second ) ) ) ); - } - - return ext::trie < object::Object, object::Object > ( object::ObjectFactory::make ( std::move ( source.getData ( ) ) ), std::move ( children ) ); - } - - static container::ObjectsTrie < > eval ( container::ObjectsTrie < KeyType, ValueType > && value ) { - return container::ObjectsTrie < > ( raw ( std::move ( value ) ) ); - } -}; - -} /* namespace core */ - -#endif /* OBJECTS_TRIE_H_ */ diff --git a/alib2data/src/indexes/stringology/PositionHeap.h b/alib2data/src/indexes/stringology/PositionHeap.h index 553750e9ac0acb5e801800e638677a3e91830cc9..bea03448bea917c6dfe396b464eaffa0c9033054 100644 --- a/alib2data/src/indexes/stringology/PositionHeap.h +++ b/alib2data/src/indexes/stringology/PositionHeap.h @@ -40,8 +40,6 @@ #include <object/UniqueObject.h> #include <object/ObjectBase.h> -#include <container/ObjectsTrie.h> - #include <primitive/Unsigned.h> #include <string/LinearString.h> diff --git a/alib2data/src/indexes/stringology/SuffixTrie.h b/alib2data/src/indexes/stringology/SuffixTrie.h index e94fd4e2820a1c4f53c66a4983eb418a66634a82..ab15b915a127955a7f9dcd13f313ff4a9b4b682b 100644 --- a/alib2data/src/indexes/stringology/SuffixTrie.h +++ b/alib2data/src/indexes/stringology/SuffixTrie.h @@ -41,12 +41,11 @@ #include <object/UniqueObject.h> #include <object/ObjectBase.h> -#include <container/ObjectsTrie.h> - #include <object/Void.h> #include <primitive/Unsigned.h> +#include <core/normalize.hpp> #include <alphabet/common/SymbolNormalize.h> #include <indexes/common/IndexesNormalize.h> diff --git a/alib2xml/src/container/xml/ObjectsTree.cpp b/alib2xml/src/container/xml/ObjectsTree.cpp index b6e82c50a5c80351c6de5ebdc8b85c78a142430e..7bf2e6475dd1666bae8fc0d79593357e77b605c8 100644 --- a/alib2xml/src/container/xml/ObjectsTree.cpp +++ b/alib2xml/src/container/xml/ObjectsTree.cpp @@ -11,9 +11,9 @@ namespace { -static auto xmlWrite = registration::XmlWriterRegister < container::ObjectsTree < > > ( ); -static auto xmlRead = registration::XmlReaderRegister < container::ObjectsTree < > > ( ); +static auto xmlWrite = registration::XmlWriterRegister < ext::tree < object::Object > > ( ); +static auto xmlRead = registration::XmlReaderRegister < ext::tree < object::Object > > ( ); -static auto xmlGroup = registration::XmlRegisterTypeInGroup < object::Object, container::ObjectsTree < > > ( ); +static auto xmlGroup = registration::XmlRegisterTypeInGroup < object::Object, ext::tree < object::Object > > ( ); } /* namespace */ diff --git a/alib2xml/src/container/xml/ObjectsTree.h b/alib2xml/src/container/xml/ObjectsTree.h index 61e60c9ee3220efa8581290fc05617dd1422e422..58c1cc1f1aee0c85d9a00eec4402d13a10309b27 100644 --- a/alib2xml/src/container/xml/ObjectsTree.h +++ b/alib2xml/src/container/xml/ObjectsTree.h @@ -8,7 +8,7 @@ #ifndef _XML_OBJECTS_TREE_H_ #define _XML_OBJECTS_TREE_H_ -#include <container/ObjectsTree.h> +#include <alib/tree> #include <core/xmlApi.hpp> namespace core { @@ -95,34 +95,6 @@ void xmlApi < ext::tree < T > >::compose ( ext::deque < sax::Token > & output, c output.emplace_back ( xmlTagName ( ), sax::Token::TokenType::END_ELEMENT ); } -template < typename T > -struct xmlApi < container::ObjectsTree < T > > { - static container::ObjectsTree < T > parse ( ext::deque < sax::Token >::iterator & input ); - static bool first ( const ext::deque < sax::Token >::const_iterator & input ); - static const std::string & xmlTagName ( ); - static void compose ( ext::deque < sax::Token > & output, const container::ObjectsTree < T > & data ); -}; - -template < typename T > -container::ObjectsTree < T > xmlApi < container::ObjectsTree < T > >::parse ( ext::deque < sax::Token >::iterator & input ) { - return container::ObjectsTree < T > ( xmlApi < ext::tree < T > >::parse ( input ) ); -} - -template < typename T > -bool xmlApi < container::ObjectsTree < T > >::first ( const ext::deque < sax::Token >::const_iterator & input ) { - return xmlApi < ext::tree < T > >::first ( input ); -} - -template < typename T > -const std::string & xmlApi < container::ObjectsTree < T > >::xmlTagName ( ) { - return xmlApi < ext::tree < T > >::xmlTagName ( ); -} - -template < typename T > -void xmlApi < container::ObjectsTree < T > >::compose ( ext::deque < sax::Token > & output, const container::ObjectsTree < T > & input ) { - xmlApi < ext::tree < T > >::compose ( output, input ); -} - } /* namespace core */ #endif /* _XML_OBJECTS_TREE_H_ */ diff --git a/alib2xml/src/container/xml/ObjectsTrie.cpp b/alib2xml/src/container/xml/ObjectsTrie.cpp index c535b403628230ec78289ceab27e93baaeb6878e..c76263a6c7004924cf8e1a1d34cecafdea8c2ea0 100644 --- a/alib2xml/src/container/xml/ObjectsTrie.cpp +++ b/alib2xml/src/container/xml/ObjectsTrie.cpp @@ -11,9 +11,9 @@ namespace { -static auto xmlWrite = registration::XmlWriterRegister < container::ObjectsTrie < > > ( ); -static auto xmlRead = registration::XmlReaderRegister < container::ObjectsTrie < > > ( ); +static auto xmlWrite = registration::XmlWriterRegister < ext::trie < object::Object, object::Object > > ( ); +static auto xmlRead = registration::XmlReaderRegister < ext::trie < object::Object, object::Object > > ( ); -static auto xmlGroup = registration::XmlRegisterTypeInGroup < object::Object, container::ObjectsTrie < > > ( ); +static auto xmlGroup = registration::XmlRegisterTypeInGroup < object::Object, ext::trie < object::Object, object::Object > > ( ); } /* namespace */ diff --git a/alib2xml/src/container/xml/ObjectsTrie.h b/alib2xml/src/container/xml/ObjectsTrie.h index 52e6fc4d8afa62859bab739cea96fe1743d709f2..58ecd2ac24f56f9e16aa6a5eaf17b9605861b33c 100644 --- a/alib2xml/src/container/xml/ObjectsTrie.h +++ b/alib2xml/src/container/xml/ObjectsTrie.h @@ -8,7 +8,7 @@ #ifndef _XML_OBJECTS_TRIE_H_ #define _XML_OBJECTS_TRIE_H_ -#include <container/ObjectsTrie.h> +#include <alib/trie> #include <core/xmlApi.hpp> namespace core { @@ -89,34 +89,6 @@ void xmlApi < ext::trie < T, R > >::compose ( ext::deque < sax::Token > & output output.emplace_back ( xmlTagName ( ), sax::Token::TokenType::END_ELEMENT ); } -template < typename T, typename R > -struct xmlApi < container::ObjectsTrie < T, R > > { - static container::ObjectsTrie < T, R > parse ( ext::deque < sax::Token >::iterator & input ); - static bool first ( const ext::deque < sax::Token >::const_iterator & input ); - static const std::string & xmlTagName ( ); - static void compose ( ext::deque < sax::Token > & output, const container::ObjectsTrie < T, R > & data ); -}; - -template < typename T, typename R > -container::ObjectsTrie < T, R > xmlApi < container::ObjectsTrie < T, R > >::parse ( ext::deque < sax::Token >::iterator & input ) { - return container::ObjectsTrie < T, R > ( xmlApi < ext::trie < T, R > >::parse ( input ) ); -} - -template < typename T, typename R > -bool xmlApi < container::ObjectsTrie < T, R > >::first ( const ext::deque < sax::Token >::const_iterator & input ) { - return sax::FromXMLParserHelper::isToken ( input, sax::Token::TokenType::START_ELEMENT, xmlTagName ( ) ); -} - -template < typename T, typename R > -const std::string & xmlApi < container::ObjectsTrie < T, R > >::xmlTagName ( ) { - return xmlApi < ext::trie < T, R > >::xmlTagName ( ); -} - -template < typename T, typename R > -void xmlApi < container::ObjectsTrie < T, R > >::compose ( ext::deque < sax::Token > & output, const container::ObjectsTrie < T, R > & input ) { - xmlApi < ext::trie < T, R > >::compose ( output, input ); -} - } /* namespace core */ #endif /* _XML_OBJECTS_TRIE_H_ */