// This function returns an integer as follows: // - a negative value if *this < rhs, // - zero if *this == rhs, // - a positive value if *this > rhs, // but if the offset is too large, the result is undefined. int compare(const String &rhs, UInt32 offset = 0) const {
GRN_DAT_DEBUG_THROW_IF(offset > length());
GRN_DAT_DEBUG_THROW_IF(offset > rhs.length());
for (UInt32 i = offset; i < length(); ++i) { if (i >= rhs.length()) { return1;
} elseif ((*this)[i] != rhs[i]) { return (*this)[i] - rhs[i];
}
} return (length() == rhs.length()) ? 0 : -1;
}
bool starts_with(const String &str) const { if (length() < str.length()) { returnfalse;
} for (UInt32 i = 0; i < str.length(); ++i) { if ((*this)[i] != str[i]) { returnfalse;
}
} returntrue;
}
bool ends_with(const String &str) const { if (length() < str.length()) { returnfalse;
}
UInt32 offset = length() - str.length(); for (UInt32 i = 0; i < str.length(); ++i) { if ((*this)[offset + i] != str[i]) { returnfalse;
}
} returntrue;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.