Skip to content
Snippets Groups Projects
BoyerMooreHorspool.h 1.17 KiB
Newer Older
  • Learn to ignore specific revisions
  • /*
     * BoyerMooreHorspool.h
     *
     *  Created on: 5. 11. 2014
     *      Author: Jan Travnicek
     */
    
    #ifndef _ARBOLOGY_BOYER_MOORE_HORSPOOL_H_
    #define _ARBOLOGY_BOYER_MOORE_HORSPOOL_H_
    
    #include <set>
    #include <common/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 BoyerMooreHorspool : public std::DoubleDispatch < std::set < unsigned >, tree::TreeBase, 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 BoyerMooreHorspool & getInstance ( ) {
    		static BoyerMooreHorspool res;
    
    		return res;
    	}
    
    };
    
    } /* namespace exact */
    
    } /* namespace arbology */
    
    #endif /* _ARBOLOGY_BOYER_MOORE_HORSPOOL_H_ */