本文整理汇总了C++中std::string::crend方法的典型用法代码示例。如果您正苦于以下问题:C++ string::crend方法的具体用法?C++ string::crend怎么用?C++ string::crend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::string
的用法示例。
在下文中一共展示了string::crend方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReverseComplement
std::string ReverseComplement(const std::string& seq) {
std::string output;
output.reserve(seq.length());
for (auto it = seq.crbegin(); it != seq.crend(); ++it) {
auto bp = *it;
switch(bp) {
case 'A':
output.push_back('T');
break;
case 'C':
output.push_back('G');
break;
case 'G':
output.push_back('C');
break;
case 'T':
output.push_back('A');
break;
case '-':
output.push_back('-');
break;
default:
Rcpp::stop("Tried to reverse complement sequence with non ATGC-");
}
}
return output;
}
示例2: getCodeTagAttributes
inline void Parser::getCodeTagAttributes( const std::string &text, std::string &data )
{
auto find_iter = std::find( text.cbegin(), text.cend(), ']' );
if( find_iter != text.cend() && find_iter != text.crend().base() ) {
data = std::string( text.cbegin(), find_iter + 1 );
}
}
示例3: is_palindrome
bool is_palindrome(std::string word){
if(word.size() % 2) return false;
boost::algorithm::to_lower(word);
std::string reversedWord{word.crbegin(), word.crend()};
return word == reversedWord;
}
示例4: reverse
/// <summary>
/// Reverses the given std::string.
/// </summary>
/// <param name="original_str">The given std::string</param>
/// <returns>A reverse std::string of the original std::string</returns>
std::string StringFunctions::reverse(const std::string &original_str)
{
std::string working_str = "";
for (std::string::const_reverse_iterator itr = original_str.crbegin(); itr != original_str.crend(); itr++)
{
working_str += *itr;
}
return working_str;
}
示例5: match
string_view_t match(const string_view_t & numview) const {
string_view_t empty_result {numview.str, numview.pos_end, numview.pos_end};
if ( (is_terminal_rule() && !numview.right_aligned())
|| (is_start_rule() && !numview.leftt_aligned()) )
return empty_result;
auto inumber = numview.crbegin();
for (auto ipattern = pattern.crbegin(); ipattern != pattern.crend(); ++ipattern) {
if (::isspace(*ipattern) || *ipattern == '.' || *ipattern == '$') continue;
if (inumber == numview.crend() || (*ipattern == '#' && *inumber == '?')) return empty_result;
if (*ipattern == '#') break;
if (*inumber != *ipattern) return empty_result;
++inumber;
}
if (is_start_rule() && inumber != numview.crend()) return empty_result;
return string_view_t{empty_result}.set_begin(inumber);
}
示例6: sign
BigInt::BigInt(std::string s)
: sign(Sign::positive)
{
if (s == "") {
BigInt::BigInt();
return;
}
if (s[0] == '-') { // handle the leading '-' sign
sign = Sign::negative;
s.erase(0, 1); // leave only numbers in the string
}
// need to read number is reverse order since that's how they are stored
for (auto it = s.crbegin(); it != s.crend(); ++it) {
if (isdigit(*it))
digits.push_back((*it) - '0');
}
}
示例7: inject
std::string insert_finjector::inject(const std::string& chunk) {
std::string output;
auto out_it = std::back_inserter(output);
auto first = chunk.cbegin();
auto end = chunk.cend();
if (skip_ws_) {
// Find the first and last non ws char
first = std::find_if(first, end, isgraph);
end = std::find_if(chunk.crbegin(), chunk.crend(), isgraph).base();
// Still need to copy all the leading ws to the output
std::copy(chunk.cbegin(), first, out_it);
}
if (position_ & position::begining) {
for (size_t i = 0; i < n_; ++i)
std::copy(insert_.cbegin(), insert_.cend(), out_it);
}
if (position_ & position::middle) {
auto mid = first + (end - first) / 2;
std::copy(first, mid, out_it);
for (size_t i = 0; i < n_; ++i)
std::copy(insert_.cbegin(), insert_.cend(), out_it);
std::copy(mid, end, out_it);
}
else
std::copy(first, end, out_it);
if (position_ & position::end) {
for (size_t i = 0; i < n_; ++i)
std::copy(insert_.cbegin(), insert_.cend(), out_it);
}
// In case there was some ws we skipped at the end, add them last
std::copy(end, chunk.cend(), out_it);
return output;
}
示例8: fromString
void Number::fromString(const std::string &input)
{
m_decimals = 0;
m_digits.clear();
m_negative = false;
int numbersAdded = 0;
for (auto it = input.crbegin(); it != input.crend(); it++) {
if (*it == '-' || *it == '+') {
if (numbersAdded == 0)
throw Exception("Invalid number: Sign before any digit read");
m_negative = (*it == '-');
break;
}
if (*it == '.' || *it == ',') {
if (m_decimals != 0)
throw Exception("Invalid number: Multiple decimal seperators found");
m_decimals = numbersAdded;
continue;
}
if (*it < '0' || *it > '9')
throw Exception("Invalid number: Unknown character found");
m_digits.push_back(*it - '0');
++numbersAdded;
}
m_trailingZeros = normalize();
m_precision = m_decimals > 9 ? m_decimals : 10;
}
示例9: BigNumber
explicit BigNumber(std::string const& num)
{
for(auto c = num.crbegin(); c != num.crend(); ++c)
if(std::isdigit(*c)) push_front(*c - 48);
}
示例10: value
CNum::Counter::Counter(const std::string &s) : value() {
if (s.size() == 0) {
setZero();
return;
}
// Parse the correct base
auto rBegin = s.crbegin();
auto rEnd = s.crend();
Unit base = 10;
if (s.size() >= 2 && s[0] == '0') {
if (s[1] == 'x') {
base = 16;
rEnd -= 2;
} else if (s[1] == 'b') {
base = 2;
rEnd -= 2;
}
}
// rBegin and rEnd is set
if (base == 16) {
// 1 character in hex occupied 4 bits
Index shift = 0;
Unit unit = 0;
for (auto itr = rBegin; itr != rEnd; itr++) {
Unit c = *itr;
if ('0' <= c && c <= '9') {
c -= '0';
} else if ('a' <= c && c <= 'f') {
c = c - 'a' + 10;
} else if ('A' <= c && c <= 'F') {
c = c - 'A' + 10;
} else {
throw;
}
unit |= (c << shift);
shift = (shift + HEX_CHAR_SIZE) % UNIT_BIT_SIZE;
if (shift == 0) {
value.push_back(unit);
unit = 0;
}
}
value.push_back(unit);
} else if (base == 10) {
// Naive algorithm that make use of multiplication and addition
*this = 0;
Counter exp = 1;
for (auto itr = rBegin; itr != rEnd; itr++, exp *= base) {
Unit c = *itr;
if ('0' <= c && c <= '9') {
c -= '0';
} else {
throw;
}
*this += (c * exp);
}
} else {
throw;
}
normalize();
assert(isNormalized());
}
示例11: reverse_complement
std::string reverse_complement(const std::string& sequence) {
auto rev = std::string{};
rev.reserve(sequence.length());
std::transform(sequence.crbegin(), sequence.crend(), std::back_inserter(rev), complement_base);
return rev;
}
示例12: oppositeOrder
bool oppositeOrder(std::string input)
{
return std::is_sorted(input.crbegin(), input.crend());
}
示例13: EndsWith
bool EndsWith(const std::string& strData, const std::string& strSearch, bool bIgnoreCase /* = false */)
{
return StartsWithOrEndsWith(strData.crbegin(), strData.crend(), strSearch.crbegin(), strSearch.crend(), bIgnoreCase);
}