当前位置: 首页>>代码示例>>C++>>正文


C++ STR::end方法代码示例

本文整理汇总了C++中STR::end方法的典型用法代码示例。如果您正苦于以下问题:C++ STR::end方法的具体用法?C++ STR::end怎么用?C++ STR::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在STR的用法示例。


在下文中一共展示了STR::end方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: isPalindrome

	/*
	 * 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 );
	} 
开发者ID:c4po187,项目名称:libstrct,代码行数:10,代码来源:libstrct.hpp

示例2: EndsWithT

bool EndsWithT(const STR& str, const STR& search, bool case_sensitive) {
	size_t str_length = str.length();
	size_t search_length = search.length();
	if (search_length > str_length)
		return false;
	if (case_sensitive)
		return str.compare(str_length - search_length, search_length, search) == 0;
	return std::equal(search.begin(), search.end(),
		str.begin() + (str_length - search_length),
		base::CaseInsensitiveCompare<typename STR::value_type>());
}
开发者ID:623442733,项目名称:cef,代码行数:11,代码来源:string_util.cpp

示例3: StartsWithT

bool StartsWithT(const STR& str, const STR& search, bool case_sensitive) {
	if (case_sensitive) {
		return str.compare(0, search.length(), search) == 0;
	}
	else {
		if (search.size() > str.size())
			return false;
		return std::equal(search.begin(), search.end(), str.begin(),
			base::CaseInsensitiveCompare<typename STR::value_type>());
	}
}
开发者ID:623442733,项目名称:cef,代码行数:11,代码来源:string_util.cpp

示例4: scramble

	/*
	 * Returns a scrambled string.
	 */
	STR scramble( STR str ) {
		std::seed_seq sd( str.begin(), str.end() );
		std::default_random_engine gen;

		for ( int i = str.size() - 1; i > 0; --i ) {
			gen.seed( sd );
			std::uniform_int_distribution<int> dist( 0, i );
			std::swap( str[i], str[dist( gen )] );
		}

		return str;
	}
开发者ID:c4po187,项目名称:libstrct,代码行数:15,代码来源:libstrct.hpp

示例5: ContainsOnlyCharsT

static bool ContainsOnlyCharsT(const STR& input, const STR& characters)
{
    for(typename STR::const_iterator iter=input.begin();
        iter!=input.end(); ++iter)
    {
        if(characters.find(*iter) == STR::npos)
        {
            return false;
        }
    }
    return true;
}
开发者ID:Strongc,项目名称:Chrome_Library,代码行数:12,代码来源:string_util.cpp

示例6: CollapseWhitespaceT

STR CollapseWhitespaceT(const STR& text,
                        bool trim_sequences_with_line_breaks)
{
    STR result;
    result.resize(text.size());

    // 设置标志位为true假设已经在连续空白中, 这样可以移除开头的全部空白.
    bool in_whitespace = true;
    bool already_trimmed = true;

    int chars_written = 0;
    for(typename STR::const_iterator i=text.begin(); i!=text.end(); ++i)
    {
        if(IsWhitespace(*i))
        {
            if(!in_whitespace)
            {
                // 减少连续空白至一个空白.
                in_whitespace = true;
                result[chars_written++] = L' ';
            }
            if(trim_sequences_with_line_breaks && !already_trimmed &&
                ((*i=='\n') || (*i=='\r')))
            {
                // 包含回车换行的空白序列全部移除.
                already_trimmed = true;
                --chars_written;
            }
        }
        else
        {
            // 非空白字符直接拷贝.
            in_whitespace = false;
            already_trimmed = false;
            result[chars_written++] = *i;
        }
    }

    if(in_whitespace && !already_trimmed)
    {
        // 忽略末尾的全部空白.
        --chars_written;
    }

    result.resize(chars_written);
    return result;
}
开发者ID:Strongc,项目名称:Chrome_Library,代码行数:47,代码来源:string_util.cpp

示例7: CollapseWhitespaceT

	STR CollapseWhitespaceT(const STR& text,
		bool trim_sequences_with_line_breaks) {
		STR result;
		result.resize(text.size());

		// Set flags to pretend we're already in a trimmed whitespace sequence, so we
		// will trim any leading whitespace.
		bool in_whitespace = true;
		bool already_trimmed = true;

		int chars_written = 0;
		for (typename STR::const_iterator i(text.begin()); i != text.end(); ++i) {
			if (IsWhitespace(*i)) {
				if (!in_whitespace) {
					// Reduce all whitespace sequences to a single space.
					in_whitespace = true;
					result[chars_written++] = L' ';
				}
				if (trim_sequences_with_line_breaks && !already_trimmed &&
					((*i == '\n') || (*i == '\r'))) {
					// Whitespace sequences containing CR or LF are eliminated entirely.
					already_trimmed = true;
					--chars_written;
				}
			}
			else {
				// Non-whitespace chracters are copied straight across.
				in_whitespace = false;
				already_trimmed = false;
				result[chars_written++] = *i;
			}
		}

		if (in_whitespace && !already_trimmed) {
			// Any trailing whitespace is eliminated.
			--chars_written;
		}

		result.resize(chars_written);
		return result;
	}
开发者ID:623442733,项目名称:cef,代码行数:41,代码来源:string_util.cpp

示例8: reverse_all

	/*
	 * Returns the whole specified string, reversed.
	 */
	STR reverse_all( STR str ) {
		std::reverse( str.begin(), str.end() );

		return str;
	}
开发者ID:c4po187,项目名称:libstrct,代码行数:8,代码来源:libstrct.hpp


注:本文中的STR::end方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。