Skip to content
Snippets Groups Projects
KnuthMorrisPratt.h 1.36 KiB
Newer Older
/*
 * KnuthMorrisPratt.h
 *
 *  Created on: 5. 11. 2014
 *      Author: Jan Travnicek
 */

#ifndef _ARBOLOGY_KNUTH_MORRIS_PRATT_H_
#define _ARBOLOGY_KNUTH_MORRIS_PRATT_H_

#include <set>
#include <core/multipleDispatch.hpp>
#include <tree/TreeFeatures.h>

namespace arbology {

namespace exact {

/**
 * Implementation of BMH for MI(E+\eps)-EVY course 2014
 * To get rid of zeros in BCS table we ignore last haystack character
 */
class KnuthMorrisPratt : public std::DoubleDispatch < KnuthMorrisPratt, std::set < unsigned >, const tree::TreeBase &, const tree::TreeBase & > {
public:
	/**
	 * Search for pattern in linear string.
	 * @return set set of occurences
	 */
	static std::set < unsigned > match ( const tree::Tree & subject, const tree::Tree & pattern );

	static std::set < unsigned > match ( const tree::PrefixRankedBarTree < > & subject, const tree::PrefixRankedBarTree < > & pattern );
	static std::set < unsigned > match ( const tree::PrefixRankedBarTree < > & subject, const tree::PrefixRankedBarPattern & pattern );
	static std::set < unsigned > match ( const tree::PrefixRankedTree < > & subject, const tree::PrefixRankedTree < > & pattern );
	static std::set < unsigned > match ( const tree::PrefixRankedTree < > & subject, const tree::PrefixRankedPattern < > & pattern );
};

} /* namespace exact */

} /* namespace arbology */

#endif /* _ARBOLOGY_KNUTH_MORRIS_PRATT_H_ */