From 38eb914e8005edafef8e7442c6d9c81d65501c12 Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Mon, 14 May 2018 15:23:50 +0200
Subject: [PATCH] document tree indexes

---
 .../arbology/CompressedBitParallelTreeIndex.h | 157 +++++++++++++---
 .../src/indexes/arbology/FullAndLinearIndex.h | 122 +++++++++---
 .../NonlinearCompressedBitParallelTreeIndex.h | 173 +++++++++++++++---
 .../arbology/NonlinearFullAndLinearIndex.h    | 137 +++++++++++---
 4 files changed, 500 insertions(+), 89 deletions(-)

diff --git a/alib2data/src/indexes/arbology/CompressedBitParallelTreeIndex.h b/alib2data/src/indexes/arbology/CompressedBitParallelTreeIndex.h
index 5355c73794..f154e3709a 100644
--- a/alib2data/src/indexes/arbology/CompressedBitParallelTreeIndex.h
+++ b/alib2data/src/indexes/arbology/CompressedBitParallelTreeIndex.h
@@ -1,6 +1,22 @@
 /*
  * CompressedBitParallelTreeIndex.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: Jan 8, 2017
  *      Author: Jan Travnicek
  */
@@ -47,84 +63,148 @@ namespace arbology {
 class GeneralAlphabet;
 
 /**
- * Represents regular expression parsed from the XML. Regular expression is stored
- * as a tree of RegExpElement.
+ * \brief Compressed bit parallel tree index. Stores a bit vector for each symbol of the alphabet. The bit vector of symbol a contains true on index i if symbol a is on i-th position in the indexed string. The class does not check whether the bit vectors actually represent valid index. The bit vectors are compressed with run length encoding packing runs of false values.
+ * Additionally the index contains a subtree jump table representing positions after a jump over a subtree.
+ *
+ * The actual notation of used tree is irelevant. The index, as fas as the data structure is concerned, is not different. Of course tree in postfix notation must be queried with patterns in postfix notation, etc.
+ *
+ * \tparam SymbolType used for the symbol part of the ranked symbol
+ * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType = DefaultSymbolType, class RankType = DefaultRankType >
 class CompressedBitParallelTreeIndex final : public object::ObjectBase, public core::Components < CompressedBitParallelTreeIndex < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet > {
-protected:
+	/**
+	 * Representation of compressed bit vectors for each symbol of the alphabet.
+	 */
 	ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > m_vectors;
+
+	/**
+	 * Representation of the subtree jump table.
+	 */
 	ext::vector < int > m_jumpTable;
 
 public:
 	/**
-	 * @copydoc SuffixTrieNode::clone ( ) const &
+	 * @copydoc ObjectBase::clone ( ) const &
 	 */
-	virtual ObjectBase * clone ( ) const &;
+	virtual ObjectBase * clone ( ) const & override;
 
 	/**
-	 * @copydoc SuffixTrieNode::clone ( ) const &
+	 * @copydoc ObjectBase::clone ( ) &&
 	 */
-	virtual ObjectBase * clone ( ) &&;
+	virtual ObjectBase * clone ( ) && override;
 
+	/**
+	 * Creates a new instance of the index with concrete alphabet, bit vectors, and subtree jump table.
+	 *
+	 * \param alphabet the alphabet of indexed string
+	 * \param vectors the compressed bit vectors
+	 * \param jumpTable the subtree jump table
+	 */
 	explicit CompressedBitParallelTreeIndex ( ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > vectors, ext::vector < int > jumpTable );
 
 	/**
-	 * @return Root node of the trie
+	 * Getter of the compressed bit vectors.
+	 *
+	 * @return compressed bit vectors
 	 */
 	const ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > & getData ( ) const &;
 
+	/**
+	 * Getter of the compressed bit vectors.
+	 *
+	 * @return compressed bit vectors
+	 */
 	ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > && getData ( ) &&;
 
 	/**
-	 * @return subtree jump table
+	 * Getter of the subtree jump table
+	 *
+	 * @return the subtree jump table
 	 */
 	const ext::vector < int > & getJumps ( ) const &;
 
+	/**
+	 * Getter of the subtree jump table
+	 *
+	 * @return the subtree jump table
+	 */
 	ext::vector < int > && getJumps ( ) &&;
 
+	/**
+	 * Reconstructs the indexed string from bit vectors.
+	 *
+	 * @return the original indexed string
+	 */
 	ext::vector < common::ranked_symbol < SymbolType, RankType > > getString ( ) const;
 
+	/**
+	 * Getter of the alphabet of the indexed tree.
+	 *
+	 * \returns the alphabet of the indexed tree
+	 */
 	const ext::set < common::ranked_symbol < SymbolType, RankType > > & getAlphabet ( ) const & {
 		return this->template accessComponent < GeneralAlphabet > ( ).get ( );
 	}
 
+	/**
+	 * Getter of the alphabet of the indexed tree.
+	 *
+	 * \returns the alphabet of the indexed tree
+	 */
 	ext::set < common::ranked_symbol < SymbolType, RankType > > && getAlphabet ( ) && {
 		return std::move ( this->template accessComponent < GeneralAlphabet > ( ).get ( ) );
 	}
 
 	/**
-	 * Sets the compressedBit vector for given symbol
-	 * @param tree root node to set
+	 * Changes the bit vector for concrete symbol.
+	 *
+	 * \param symbol the changed symbol
+	 * \param data the new bit vector
 	 */
 	void setCompressedBitVectorForSymbol ( common::ranked_symbol < SymbolType, RankType > symbol, common::SparseBoolVector data );
 
 	/**
-	 * Removes symbol from the alphabet of symbol available in the regular expression
-	 * @param symbol removed symbol from the alphabet
+	 * Remover of a symbol from the alphabet. The symbol can be removed if it is not used in any of bit vector keys.
+	 *
+	 * \param symbol a symbol to remove.
 	 */
 	bool removeSymbolFromAlphabet ( const common::ranked_symbol < SymbolType, RankType > & symbol ) {
 		return this->template accessComponent < GeneralAlphabet > ( ).remove ( symbol );
 	}
 
 	/**
-	 * Prints XML representation of the tree to the output stream.
-	 * @param out output stream to which print the tree
-	 * @param tree tree to print
+	 * @copydoc alib::CommonBase<ObjectBase>::compare ( const ObjectBase & )
 	 */
-	virtual void operator >>( std::ostream & out ) const;
-
-	virtual int compare ( const ObjectBase & other ) 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 ) );
 	}
 
-	virtual int compare ( const CompressedBitParallelTreeIndex & other ) const;
+	/**
+	 * The actual compare method.
+	 *
+	 * \param other the other instance
+	 *
+	 * \returns the actual relation between two by type same index instances
+	 */
+	int compare ( const CompressedBitParallelTreeIndex & other ) const;
 
-	virtual explicit operator std::string ( ) const;
+	/**
+	 * @copydoc alib::CommonBase<ObjectBase>::operator >> ( std::ostream & )
+	 */
+	virtual void operator >>( std::ostream & out ) const override;
 
-	virtual object::ObjectBase * inc ( ) &&;
+	/**
+	 * @copydoc alib::CommonBase<ObjectBase>::operator std::string ( )
+	 */
+	virtual explicit operator std::string ( ) const override;
+
+	/**
+	 * @copydoc alib::ObjectBase::inc()
+	 */
+	virtual object::ObjectBase * inc ( ) && override;
 };
 
 } /* namespace arbology */
@@ -225,24 +305,57 @@ object::ObjectBase * CompressedBitParallelTreeIndex < SymbolType, RankType >::in
 
 namespace core {
 
+/**
+ * Helper class specifying constraints for the internal alphabet component of the index.
+ *
+ * \tparam SymbolType used for the symbol part of the ranked symbol
+ * \tparam RankType used for the rank part of the ranked symbol
+ */
 template < class SymbolType, class RankType >
 class SetConstraint < indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, indexes::arbology::GeneralAlphabet > {
 public:
+	/**
+	 * Returns true if the symbol is still used as key in mapping symbol to bit vector.
+	 *
+	 * \param index the tested index
+	 * \param symbol the tested symbol
+	 *
+	 * \returns true if the symbol is used, false othervise
+	 */
 	static bool used ( const indexes::arbology::CompressedBitParallelTreeIndex < common::ranked_symbol < SymbolType, RankType > > & index, const common::ranked_symbol < SymbolType, RankType > & symbol ) {
 		const ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > & content = index.getData ( );
 
 		return content.find ( symbol ) != content.end ( );
 	}
 
+	/**
+	 * Returns true as all symbols are possibly available to be elements of the alphabet.
+	 *
+	 * \param index the tested index
+	 * \param symbol the tested symbol
+	 *
+	 * \returns true
+	 */
 	static bool available ( const indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType > &, const common::ranked_symbol < SymbolType, RankType > & ) {
 		return true;
 	}
 
+	/**
+	 * All symbols are valid as symbols of the alphabet.
+	 *
+	 * \param index the tested index
+	 * \param symbol the tested symbol
+	 */
 	static void valid ( const indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType > &, const common::ranked_symbol < SymbolType, RankType > & ) {
 	}
 
 };
 
+/**
+ * Helper for normalisation of types specified by templates used as internal datatypes of symbols.
+ *
+ * \returns new instance of the index with default template parameters or unmodified instance if the template parameters were already the default ones
+ */
 template < class SymbolType, class RankType >
 struct normalize < indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType > > {
 	static indexes::arbology::CompressedBitParallelTreeIndex < > eval ( indexes::arbology::CompressedBitParallelTreeIndex < SymbolType, RankType > && value ) {
diff --git a/alib2data/src/indexes/arbology/FullAndLinearIndex.h b/alib2data/src/indexes/arbology/FullAndLinearIndex.h
index e7d3bac7a0..d041ee829d 100644
--- a/alib2data/src/indexes/arbology/FullAndLinearIndex.h
+++ b/alib2data/src/indexes/arbology/FullAndLinearIndex.h
@@ -1,6 +1,22 @@
 /*
  * FullAndLinearIndex.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: Jan 8, 2017
  *      Author: Jan Travnicek
  */
@@ -36,82 +52,139 @@ namespace arbology {
 class GeneralAlphabet;
 
 /**
- * Represents regular expression parsed from the XML. Regular expression is stored
- * as a tree of RegExpElement.
+ * \brief Full and linear tree index. The index serves as a adaptor of string index so that searching for tree patterns is possible. The representation of the index stores a string index and a subtree jump table. The implementation since parametrized with the string index represents a family of indexes.
+ *
+ * The actual notation of used tree is irelevant. The index, as fas as the data structure is concerned, is not different. Of course tree in postfix notation must be queried with patterns in postfix notation, etc.
+ *
+ * \tparam SymbolType used for the symbol part of the ranked symbol
+ * \tparam RankType used for the rank part of the ranked symbol
+ * \tparam StringIndex a template parameter representing a type of the string index
  */
 template < class SymbolType = DefaultSymbolType, class RankType = DefaultRankType, template < typename > class StringIndex = indexes::stringology::PositionHeap >
 class FullAndLinearIndex final : public object::ObjectBase {
-protected:
+	/**
+	 * Representation of the string index.
+	 */
 	StringIndex < common::ranked_symbol < SymbolType, RankType > > m_StringIndex;
+
+	/**
+	 * Representation of the subtree jump table.
+	 */
 	ext::vector < int > m_JumpTable;
 
 public:
 	/**
-	 * @copydoc SuffixTrieNode::clone ( ) const &
+	 * @copydoc ObjectBase::clone ( ) const &
 	 */
-	virtual ObjectBase * clone ( ) const &;
+	virtual ObjectBase * clone ( ) const & override;
 
 	/**
-	 * @copydoc SuffixTrieNode::clone ( ) const &
+	 * @copydoc ObjectBase::clone ( ) &&
 	 */
-	virtual ObjectBase * clone ( ) &&;
+	virtual ObjectBase * clone ( ) && override;
 
+	/**
+	 * Creates a new instance of the index with concrete alphabet, bit vectors, and subtree jump table.
+	 *
+	 * \param stringIndex the concrete underlying string index.
+	 * \param jumpTable the subtree jump table
+	 */
 	explicit FullAndLinearIndex ( StringIndex < common::ranked_symbol < SymbolType, RankType > > stringIndex, ext::vector < int > jumpTable );
 
 	/**
-	 * @return Root node of the trie
+	 * Getter of the underlying string index.
+	 *
+	 * @return underlying string index
 	 */
 	const StringIndex < common::ranked_symbol < SymbolType, RankType > > & getStringIndex ( ) const &;
 
+	/**
+	 * Getter of the underlying string index.
+	 *
+	 * @return underlying string index
+	 */
 	StringIndex < common::ranked_symbol < SymbolType, RankType > > && getStringIndex ( ) &&;
 
 	/**
-	 * @return subtree jump table
+	 * Getter of the subtree jump table
+	 *
+	 * @return the subtree jump table
 	 */
 	const ext::vector < int > & getJumps ( ) const &;
 
+	/**
+	 * Getter of the subtree jump table
+	 *
+	 * @return the subtree jump table
+	 */
 	ext::vector < int > && getJumps ( ) &&;
 
+	/**
+	 * Getter of the alphabet of the indexed tree.
+	 *
+	 * \returns the alphabet of the indexed tree
+	 */
 	const ext::set < common::ranked_symbol < SymbolType, RankType > > & getAlphabet ( ) const & {
 		return m_StringIndex.getAlphabet ( );
 	}
 
+	/**
+	 * Getter of the alphabet of the indexed tree.
+	 *
+	 * \returns the alphabet of the indexed tree
+	 */
 	ext::set < common::ranked_symbol < SymbolType, RankType > > && getAlphabet ( ) && {
 		return std::move ( m_StringIndex ).getAlphabet ( );
 	}
 
 	/**
-	 * Sets the compressedBit vector for given symbol
-	 * @param tree root node to set
+	 * Changes the underlying string index.
+	 *
+	 * \param stringIndex new string index
 	 */
 	void setStringIndex ( StringIndex < common::ranked_symbol < SymbolType, RankType > > stringIndex );
 
 	/**
-	 * Removes symbol from the alphabet of symbol available in the regular expression
-	 * @param symbol removed symbol from the alphabet
+	 * Remover of a symbol from the alphabet. The symbol can be removed if it is not used in any of bit vector keys.
+	 *
+	 * \param symbol a symbol to remove.
 	 */
 	bool removeSymbolFromAlphabet ( const common::ranked_symbol < SymbolType, RankType > & symbol ) {
 		return m_StringIndex.removeSymbolFromAlphabet ( symbol );
 	}
 
 	/**
-	 * Prints XML representation of the tree to the output stream.
-	 * @param out output stream to which print the tree
-	 * @param tree tree to print
+	 * @copydoc alib::CommonBase<ObjectBase>::compare ( const ObjectBase & )
 	 */
-	virtual void operator >>( std::ostream & out ) const;
-
-	virtual int compare ( const ObjectBase & other ) 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 ) );
 	}
 
-	virtual int compare ( const FullAndLinearIndex & other ) const;
+	/**
+	 * The actual compare method.
+	 *
+	 * \param other the other instance
+	 *
+	 * \returns the actual relation between two by type same index instances
+	 */
+	int compare ( const FullAndLinearIndex & other ) const;
 
-	virtual explicit operator std::string ( ) const;
+	/**
+	 * @copydoc alib::CommonBase<ObjectBase>::operator >> ( std::ostream & )
+	 */
+	virtual void operator >>( std::ostream & out ) const override;
 
-	virtual object::ObjectBase * inc ( ) &&;
+	/**
+	 * @copydoc alib::CommonBase<ObjectBase>::operator std::string ( )
+	 */
+	virtual explicit operator std::string ( ) const override;
+
+	/**
+	 * @copydoc alib::ObjectBase::inc()
+	 */
+	virtual object::ObjectBase * inc ( ) && override;
 };
 
 } /* namespace arbology */
@@ -194,6 +267,11 @@ object::ObjectBase * FullAndLinearIndex < SymbolType, RankType, StringIndex >::i
 
 namespace core {
 
+/**
+ * Helper for normalisation of types specified by templates used as internal datatypes of symbols.
+ *
+ * \returns new instance of the index with default template parameters or unmodified instance if the template parameters were already the default ones
+ */
 template < class SymbolType, class RankType, template < typename > class StringIndex >
 struct normalize < indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > > {
 	static indexes::arbology::FullAndLinearIndex < > eval ( indexes::arbology::FullAndLinearIndex < SymbolType, RankType, StringIndex > && value ) {
diff --git a/alib2data/src/indexes/arbology/NonlinearCompressedBitParallelTreeIndex.h b/alib2data/src/indexes/arbology/NonlinearCompressedBitParallelTreeIndex.h
index 6e4d798c15..5427c6d76a 100644
--- a/alib2data/src/indexes/arbology/NonlinearCompressedBitParallelTreeIndex.h
+++ b/alib2data/src/indexes/arbology/NonlinearCompressedBitParallelTreeIndex.h
@@ -1,6 +1,22 @@
 /*
  * NonlinearCompressedBitParallelTreeIndex.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: 22. 8. 2017
  *      Author: Jan Travnicek
  */
@@ -45,89 +61,169 @@ namespace arbology {
 class GeneralAlphabet;
 
 /**
- * Represents regular expression parsed from the XML. Regular expression is stored
- * as a tree of RegExpElement.
+ * \brief Compressed bit parallel nonlinear tree index. Stores a bit vector for each symbol of the alphabet. The bit vector of symbol a contains true on index i if symbol a is on i-th position in the indexed string. The class does not check whether the bit vectors actually represent valid index. The bit vectors are compressed with run length encoding packing runs of false values.
+ * Additionally the index contains a subtree jump table representing positions after a jump over a subtree.
+ * The index is supposed to be able to provide data to search for nonlinear tree patterns. Therefore it also contains representation of subtree repeats.
+ *
+ * The actual notation of used tree is irelevant. The index, as fas as the data structure is concerned, is not different. Of course tree in postfix notation must be queried with patterns in postfix notation, etc.
+ *
+ * \tparam SymbolType used for the symbol part of the ranked symbol
+ * \tparam RankType used for the rank part of the ranked symbol
  */
 template < class SymbolType = DefaultSymbolType, class RankType = DefaultRankType >
 class NonlinearCompressedBitParallelTreeIndex final : public object::ObjectBase, public core::Components < NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >, ext::set < common::ranked_symbol < SymbolType, RankType > >, component::Set, GeneralAlphabet > {
-protected:
+	/**
+	 * Representation of compressed bit vectors for each symbol of the alphabet.
+	 */
 	ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > m_vectors;
+
+	/**
+	 * Representation of the subtree jump table.
+	 */
 	ext::vector < int > m_jumpTable;
+
+	/**
+	 * Representation of repeats of subtrees in the indexed tree.
+	 */
 	ext::vector < unsigned > m_repeats;
 
 public:
 	/**
-	 * @copydoc SuffixTrieNode::clone ( ) const &
+	 * @copydoc ObjectBase::clone ( ) const &
 	 */
-	virtual ObjectBase * clone ( ) const &;
+	virtual ObjectBase * clone ( ) const & override;
 
 	/**
-	 * @copydoc SuffixTrieNode::clone ( ) const &
+	 * @copydoc ObjectBase::clone ( ) &&
 	 */
-	virtual ObjectBase * clone ( ) &&;
+	virtual ObjectBase * clone ( ) && override;
 
+	/**
+	 * Creates a new instance of the index with concrete alphabet, bit vectors, subtree jump table, and subtree repeats.
+	 *
+	 * \param alphabet the alphabet of indexed string
+	 * \param vectors the compressed bit vectors
+	 * \param jumpTable the subtree jump table
+	 * \param repeats the subtree repeats table
+	 */
 	explicit NonlinearCompressedBitParallelTreeIndex ( ext::set < common::ranked_symbol < SymbolType, RankType > > alphabet, ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > vectors, ext::vector < int > jumpTable, ext::vector < unsigned > repeats );
 
 	/**
-	 * @return Root node of the trie
+	 * Getter of the compressed bit vectors.
+	 *
+	 * @return compressed bit vectors
 	 */
 	const ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > & getData ( ) const &;
 
+	/**
+	 * Getter of the compressed bit vectors.
+	 *
+	 * @return compressed bit vectors
+	 */
 	ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > && getData ( ) &&;
 
 	/**
-	 * @return subtree jump table
+	 * Getter of the subtree jump table
+	 *
+	 * @return the subtree jump table
 	 */
 	const ext::vector < int > & getJumps ( ) const &;
 
+	/**
+	 * Getter of the subtree jump table
+	 *
+	 * @return the subtree jump table
+	 */
 	ext::vector < int > && getJumps ( ) &&;
 
+	/**
+	 * Getter of the subtree repeats table
+	 *
+	 * @return the subtree repeats table
+	 */
 	const ext::vector < unsigned > & getRepeats ( ) const &;
 
+	/**
+	 * Getter of the subtree repeats table
+	 *
+	 * @return the subtree repeats table
+	 */
 	ext::vector < unsigned > && getRepeats ( ) &&;
 
+	/**
+	 * Reconstructs the indexed string from bit vectors.
+	 *
+	 * @return the original indexed string
+	 */
 	ext::vector < common::ranked_symbol < SymbolType, RankType > > getString ( ) const;
 
+	/**
+	 * Getter of the alphabet of the indexed tree.
+	 *
+	 * \returns the alphabet of the indexed tree
+	 */
 	const ext::set < common::ranked_symbol < SymbolType, RankType > > & getAlphabet ( ) const & {
 		return this->template accessComponent < GeneralAlphabet > ( ).get ( );
 	}
 
+	/**
+	 * Getter of the alphabet of the indexed tree.
+	 *
+	 * \returns the alphabet of the indexed tree
+	 */
 	ext::set < common::ranked_symbol < SymbolType, RankType > > && getAlphabet ( ) && {
 		return std::move ( this->template accessComponent < GeneralAlphabet > ( ).get ( ) );
 	}
 
 	/**
-	 * Sets the nonlinearcompressedBit vector for given symbol
-	 * @param tree root node to set
+	 * Changes the bit vector for concrete symbol.
+	 *
+	 * \param symbol the changed symbol
+	 * \param data the new bit vector
 	 */
 	void setNonlinearCompressedBitVectorForSymbol ( common::ranked_symbol < SymbolType, RankType > symbol, common::SparseBoolVector data );
 
 	/**
-	 * Removes symbol from the alphabet of symbol available in the regular expression
-	 * @param symbol removed symbol from the alphabet
+	 * Remover of a symbol from the alphabet. The symbol can be removed if it is not used in any of bit vector keys.
+	 *
+	 * \param symbol a symbol to remove.
 	 */
 	bool removeSymbolFromAlphabet ( const common::ranked_symbol < SymbolType, RankType > & symbol ) {
 		return this->template accessComponent < GeneralAlphabet > ( ).remove ( symbol );
 	}
 
 	/**
-	 * Prints XML representation of the tree to the output stream.
-	 * @param out output stream to which print the tree
-	 * @param tree tree to print
+	 * @copydoc alib::CommonBase<ObjectBase>::compare ( const ObjectBase & )
 	 */
-	virtual void operator >>( std::ostream & out ) const;
-
-	virtual int compare ( const ObjectBase & other ) 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 ) );
 	}
 
-	virtual int compare ( const NonlinearCompressedBitParallelTreeIndex & other ) const;
+	/**
+	 * The actual compare method.
+	 *
+	 * \param other the other instance
+	 *
+	 * \returns the actual relation between two by type same index instances
+	 */
+	int compare ( const NonlinearCompressedBitParallelTreeIndex & other ) const;
 
-	virtual explicit operator std::string ( ) const;
+	/**
+	 * @copydoc alib::CommonBase<ObjectBase>::operator >> ( std::ostream & )
+	 */
+	virtual void operator >>( std::ostream & out ) const override;
+
+	/**
+	 * @copydoc alib::CommonBase<ObjectBase>::operator std::string ( )
+	 */
+	virtual explicit operator std::string ( ) const override;
 
-	virtual object::ObjectBase * inc ( ) &&;
+	/**
+	 * @copydoc alib::ObjectBase::inc()
+	 */
+	virtual object::ObjectBase * inc ( ) && override;
 };
 
 } /* namespace arbology */
@@ -238,24 +334,57 @@ object::ObjectBase * NonlinearCompressedBitParallelTreeIndex < SymbolType, RankT
 
 namespace core {
 
+/**
+ * Helper class specifying constraints for the internal alphabet component of the index.
+ *
+ * \tparam SymbolType used for the symbol part of the ranked symbol
+ * \tparam RankType used for the rank part of the ranked symbol
+ */
 template < class SymbolType, class RankType >
 class SetConstraint < indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType >, common::ranked_symbol < SymbolType, RankType >, indexes::arbology::GeneralAlphabet > {
 public:
+	/**
+	 * Returns true if the symbol is still used as key in mapping symbol to bit vector.
+	 *
+	 * \param index the tested index
+	 * \param symbol the tested symbol
+	 *
+	 * \returns true if the symbol is used, false othervise
+	 */
 	static bool used ( const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType > & index, const common::ranked_symbol < SymbolType, RankType > & symbol ) {
 		const ext::map < common::ranked_symbol < SymbolType, RankType >, common::SparseBoolVector > & content = index.getData ( );
 
 		return content.find ( symbol ) != content.end ( );
 	}
 
+	/**
+	 * Returns true as all symbols are possibly available to be elements of the alphabet.
+	 *
+	 * \param index the tested index
+	 * \param symbol the tested symbol
+	 *
+	 * \returns true
+	 */
 	static bool available ( const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType > &, const common::ranked_symbol < SymbolType, RankType > & ) {
 		return true;
 	}
 
+	/**
+	 * All symbols are valid as symbols of the alphabet.
+	 *
+	 * \param index the tested index
+	 * \param symbol the tested symbol
+	 */
 	static void valid ( const indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType > &, const common::ranked_symbol < SymbolType, RankType > & ) {
 	}
 
 };
 
+/**
+ * Helper for normalisation of types specified by templates used as internal datatypes of symbols.
+ *
+ * \returns new instance of the index with default template parameters or unmodified instance if the template parameters were already the default ones
+ */
 template < class SymbolType, class RankType >
 struct normalize < indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType > > {
 	static indexes::arbology::NonlinearCompressedBitParallelTreeIndex < > eval ( indexes::arbology::NonlinearCompressedBitParallelTreeIndex < SymbolType, RankType > && value ) {
diff --git a/alib2data/src/indexes/arbology/NonlinearFullAndLinearIndex.h b/alib2data/src/indexes/arbology/NonlinearFullAndLinearIndex.h
index 29ec200435..87b7e01d77 100644
--- a/alib2data/src/indexes/arbology/NonlinearFullAndLinearIndex.h
+++ b/alib2data/src/indexes/arbology/NonlinearFullAndLinearIndex.h
@@ -1,6 +1,22 @@
 /*
  * NonlinearFullAndLinearIndex.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 13, 2017
  *      Author: Jan Travnicek
  */
@@ -36,90 +52,160 @@ namespace arbology {
 class GeneralAlphabet;
 
 /**
- * Represents regular expression parsed from the XML. Regular expression is stored
- * as a tree of RegExpElement.
+ * \brief Full and linear tree index. The index serves as a adaptor of string index so that searching for tree patterns is possible. The representation of the index stores a string index and a subtree jump table. The implementation since parametrized with the string index represents a family of indexes.
+ * The index is supposed to be able to provide data to search for nonlinear tree patterns. Therefore it also contains representation of subtree repeats.
+ *
+ * The actual notation of used tree is irelevant. The index, as fas as the data structure is concerned, is not different. Of course tree in postfix notation must be queried with patterns in postfix notation, etc.
+ *
+ * \tparam SymbolType used for the symbol part of the ranked symbol
+ * \tparam RankType used for the rank part of the ranked symbol
+ * \tparam StringIndex a template parameter representing a type of the string index
  */
 template < class SymbolType = DefaultSymbolType, class RankType = DefaultRankType, template < typename > class StringIndex = indexes::stringology::PositionHeap >
 class NonlinearFullAndLinearIndex final : public object::ObjectBase {
-protected:
+	/**
+	 * Representation of the string index.
+	 */
 	StringIndex < common::ranked_symbol < SymbolType, RankType > > m_StringIndex;
+
+	/**
+	 * Representation of the subtree jump table.
+	 */
 	ext::vector < int > m_JumpTable;
+
+	/**
+	 * Representation of repeats of subtrees in the indexed tree.
+	 */
 	ext::vector < unsigned > m_Repeats;
 
 public:
 	/**
-	 * @copydoc SuffixTrieNode::clone ( ) const &
+	 * @copydoc ObjectBase::clone ( ) const &
 	 */
-	virtual ObjectBase * clone ( ) const &;
+	virtual ObjectBase * clone ( ) const & override;
 
 	/**
-	 * @copydoc SuffixTrieNode::clone ( ) const &
+	 * @copydoc ObjectBase::clone ( ) &&
 	 */
-	virtual ObjectBase * clone ( ) &&;
+	virtual ObjectBase * clone ( ) && override;
 
+	/**
+	 * Creates a new instance of the index with concrete alphabet, bit vectors, subtree jump table, and subtree repeats.
+	 *
+	 * \param stringIndex the concrete underlying string index.
+	 * \param jumpTable the subtree jump table
+	 * \param repeats the subtree repeats table
+	 */
 	explicit NonlinearFullAndLinearIndex ( StringIndex < common::ranked_symbol < SymbolType, RankType > > stringIndex, ext::vector < int > jumpTable, ext::vector < unsigned > repeats );
 
 	/**
-	 * @return Root node of the trie
+	 * Getter of the underlying string index.
+	 *
+	 * @return underlying string index
 	 */
 	const StringIndex < common::ranked_symbol < SymbolType, RankType > > & getStringIndex ( ) const &;
 
+	/**
+	 * Getter of the underlying string index.
+	 *
+	 * @return underlying string index
+	 */
 	StringIndex < common::ranked_symbol < SymbolType, RankType > > && getStringIndex ( ) &&;
 
 	/**
-	 * @return subtree jump table
+	 * Getter of the subtree jump table
+	 *
+	 * @return the subtree jump table
 	 */
 	const ext::vector < int > & getJumps ( ) const &;
 
+	/**
+	 * Getter of the subtree jump table
+	 *
+	 * @return the subtree jump table
+	 */
 	ext::vector < int > && getJumps ( ) &&;
 
 	/**
-	 * @return repeats
+	 * Getter of the subtree repeats table
+	 *
+	 * @return the subtree repeats table
 	 */
 	const ext::vector < unsigned > & getRepeats ( ) const &;
 
+	/**
+	 * Getter of the subtree repeats table
+	 *
+	 * @return the subtree repeats table
+	 */
 	ext::vector < unsigned > && getRepeats ( ) &&;
 
+	/**
+	 * Getter of the alphabet of the indexed tree.
+	 *
+	 * \returns the alphabet of the indexed tree
+	 */
 	const ext::set < common::ranked_symbol < SymbolType, RankType > > & getAlphabet ( ) const & {
 		return m_StringIndex.getAlphabet ( );
 	}
 
+	/**
+	 * Getter of the alphabet of the indexed tree.
+	 *
+	 * \returns the alphabet of the indexed tree
+	 */
 	ext::set < common::ranked_symbol < SymbolType, RankType > > && getAlphabet ( ) && {
 		return std::move ( m_StringIndex.getAlphabet ( ) );
 	}
 
 	/**
-	 * Sets the compressedBit vector for given symbol
-	 * @param tree root node to set
+	 * Changes the underlying string index.
+	 *
+	 * \param stringIndex new string index
 	 */
 	void setStringIndex ( StringIndex < common::ranked_symbol < SymbolType, RankType > > stringIndex );
 
 	/**
-	 * Removes symbol from the alphabet of symbol available in the regular expression
-	 * @param symbol removed symbol from the alphabet
+	 * Remover of a symbol from the alphabet. The symbol can be removed if it is not used in any of bit vector keys.
+	 *
+	 * \param symbol a symbol to remove.
 	 */
 	bool removeSymbolFromAlphabet ( const common::ranked_symbol < SymbolType, RankType > & symbol ) {
 		return m_StringIndex.removeSymbolFromAlphabet ( symbol );
 	}
 
 	/**
-	 * Prints XML representation of the tree to the output stream.
-	 * @param out output stream to which print the tree
-	 * @param tree tree to print
+	 * @copydoc alib::CommonBase<ObjectBase>::compare ( const ObjectBase & )
 	 */
-	virtual void operator >>( std::ostream & out ) const;
-
-	virtual int compare ( const ObjectBase & other ) 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 ) );
 	}
 
-	virtual int compare ( const NonlinearFullAndLinearIndex & other ) const;
+	/**
+	 * The actual compare method.
+	 *
+	 * \param other the other instance
+	 *
+	 * \returns the actual relation between two by type same index instances
+	 */
+	int compare ( const NonlinearFullAndLinearIndex & other ) const;
 
-	virtual explicit operator std::string ( ) const;
+	/**
+	 * @copydoc alib::CommonBase<ObjectBase>::operator >> ( std::ostream & )
+	 */
+	virtual void operator >>( std::ostream & out ) const override;
 
-	virtual object::ObjectBase * inc ( ) &&;
+	/**
+	 * @copydoc alib::CommonBase<ObjectBase>::operator std::string ( )
+	 */
+	virtual explicit operator std::string ( ) const override;
+
+	/**
+	 * @copydoc alib::ObjectBase::inc()
+	 */
+	virtual object::ObjectBase * inc ( ) && override;
 };
 
 } /* namespace arbology */
@@ -212,6 +298,11 @@ object::ObjectBase * NonlinearFullAndLinearIndex < SymbolType, RankType, StringI
 
 namespace core {
 
+/**
+ * Helper for normalisation of types specified by templates used as internal datatypes of symbols.
+ *
+ * \returns new instance of the index with default template parameters or unmodified instance if the template parameters were already the default ones
+ */
 template < class SymbolType, class RankType, template < typename > class StringIndex >
 struct normalize < indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > > {
 	static indexes::arbology::NonlinearFullAndLinearIndex < > eval ( indexes::arbology::NonlinearFullAndLinearIndex < SymbolType, RankType, StringIndex > && value ) {
-- 
GitLab