Beispiel #1
0
	/*
	 * Returns true if the specified string is a Palindrome.
	 */
	bool isPalindrome( STR str ) {
		str.erase( std::remove_if( str.begin(), str.end(), ::isspace ), str.end() );
		STR copy = str;
		std::reverse( copy.begin(), copy.end() );
		
		return ( strcmp( str.c_str(), copy.c_str() ) == 0 );
	} 
Beispiel #2
0
	/*
	 * Returns a vector of strings from the specified string, which has
	 * been sliced at each position where the delimiter appears.
	 */
	std::vector<STR> distribute( STR str, CSTR_R delimiter ) {
		std::vector<STR> slices;
		std::size_t pos = 0;

		while ( ( pos = str.find( delimiter ) ) != STR::npos ) {
			slices.push_back( str.substr( 0, pos ) );
			str.erase( 0, ( pos + delimiter.length() ) );
		}

		return slices;
	}