Skip to content
Snippets Groups Projects
Commit a75ea75a authored by Jan Trávníček's avatar Jan Trávníček
Browse files

unit build in algo string properties

parent 9f553114
No related branches found
No related tags found
No related merge requests found
/*
* StartsWith.cpp
*
* Created on: 5. 11. 2014
* Author: Jan Travnicek
*/
#include "StartsWith.h"
#include <registration/AlgoRegistration.hpp>
namespace {
auto StartsWithLinearString = registration::AbstractRegister < string::properties::StartsWith, bool, const string::LinearString < > &, const string::LinearString < > & > ( string::properties::StartsWith::startsWith );
} /* namespace */
/*
* StartsWith.h
*
* Created on: 5. 11. 2014
* Author: Jan Travnicek
*/
#ifndef _STRING_STARTS_WITH_H_
#define _STRING_STARTS_WITH_H_
#include <alib/set>
#include <alib/map>
#include <string/LinearString.h>
namespace string {
namespace properties {
class StartsWith {
public:
template < class SymbolType >
static bool startsWith ( const string::LinearString < SymbolType > & string, const string::LinearString < SymbolType > & prefix );
};
template < class SymbolType >
bool StartsWith::startsWith ( const string::LinearString < SymbolType > & string, const string::LinearString < SymbolType > & prefix ) {
for ( auto prefixIterator = prefix.getContent ( ).begin ( ), stringIterator = string.getContent ( ).begin ( ); prefixIterator != prefix.getContent ( ).end ( ); ++ prefixIterator, ++ stringIterator ) {
if ( stringIterator == string.getContent ( ).end ( ) )
return false;
if ( * prefixIterator != * stringIterator )
return false;
}
return true;
}
} /* namespace properties */
} /* namespace string */
#endif /* _STRING_STARTS_WITH_H_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment