📄 sstr_04.cc
字号:
// for (long i = (end_a - str_a.length()); i >= 0; i--) { // find the string // if (isip_wcsstr(&value_d[i], str_a.value_d) != (unichar*)NULL) { value_d[end_a + 1] = c; return i; } } // restore the temporary null // value_d[end_a + 1] = c; // exit ungracefully // return Integral::NO_POS;}// method: firstChr//// arguments:// const SysString& chrs: (input) a set of characters// long start: (input) where to start looking//// return: long index within the string//// this method finds the first instance of a character in chrs_a// within the object//long SysString::firstChr(const SysString& chrs_a, long start_a) const { // check the arguments // if (start_a > length()) { return Integral::NO_POS; } if (start_a == Integral::NO_POS) { start_a = 0; } // find the index // for (long i = start_a; i < length(); i++) { if (isip_wcschr(chrs_a.value_d, value_d[i]) != (unichar*)NULL) { return i; } } // exit ungracefully // return Integral::NO_POS;}// method: lastChr//// arguments:// const SysString& chrs: (input) a set of characters// long end: (input) where to stop looking//// return: long index within the string//// this method finds the last instance of a character in chrs_a// within the object//long SysString::lastChr(const SysString& chrs_a, long end_a) const { // length can't be less than or equal to zero // if (length() < 1) { return Integral::NO_POS; } // check the arguments // if ((end_a == Integral::NO_POS) || (end_a >= length())) { end_a = length() - 1; } // find the index // for (long i = end_a; i >= 0; i--) { if (isip_wcschr(chrs_a.value_d, value_d[i]) != (unichar*)NULL) { return i; } } // exit ungracefully // return Integral::NO_POS;}// method: firstChr//// arguments:// unichar chr: (input) a character// long start: (input) where to start looking//// return: long index within the string//// this method finds the first instance of a character chr_a within the object//long SysString::firstChr(unichar chr_a, long start_a) const { // length can't be less than or equal to zero // if (start_a > length()) { return Integral::NO_POS; } // check the arguments // if (start_a == Integral::NO_POS) { start_a = 0; } // find the index // for (long i = start_a; i < length(); i++) { if (chr_a == (unichar)value_d[i]) { return i; } } // exit ungracefully // return Integral::NO_POS;}// method: lastChr//// arguments:// unichar chr: (input) a character// long end: (input) where to stop looking//// return: long index within the string//// this method finds the last instance of a character chr_a within the object//long SysString::lastChr(unichar chr_a, long end_a) const { // length can't be less than or equal to zero // if (length() < 1) { return Integral::NO_POS; } // check the arguments // if ((end_a == Integral::NO_POS) || (end_a >= length())) { end_a = length() - 1; } // find the index // for (long i = end_a; i >= 0; i--) { if (chr_a == value_d[i]) { return i; } } // exit ungracefully // return Integral::NO_POS;}// method: firstNotChr//// arguments:// const SysString& chrs: (input) a set of characters// long start: (input) where to start looking//// return: long index within the string//// this method finds the first instance of a character not equal to a character// within chrs_a within the object//long SysString::firstNotChr(const SysString& chrs_a, long start_a) const { // length can't be less than or equal to zero // if (start_a > length()) { return Integral::NO_POS; } // check the arguments // if (start_a == Integral::NO_POS) { start_a = 0; } // find the index // for (long i = start_a; i < length(); i++) { if (isip_wcschr(chrs_a.value_d, value_d[i]) == (unichar*)NULL) { return i; } } // exit ungracefully // return Integral::NO_POS;}// method: lastNotChr//// arguments:// const SysString& chrs: (input) a set of characters// long end: (input) where to stop looking//// return: long index within the string//// this method finds the last instance of a character not equal to a character// within chrs_a within the object//long SysString::lastNotChr(const SysString& chrs_a, long end_a) const { // length can't be less than or equal to zero // if (length() < 1) { return Integral::NO_POS; } // check the arguments // if ((end_a == Integral::NO_POS) || (end_a >= length())) { end_a = length() - 1; } // find the index // for (long i = end_a; i >= 0; i--) { if (isip_wcschr(chrs_a.value_d, value_d[i]) == (unichar*)NULL) { return i; } } // exit ungracefully // return Integral::NO_POS;}// method: firstNotChr//// arguments:// unichar chr: (input) a character// long start: (input) where to start looking//// return: long index within the string//// this method finds the first instance of a character not equal to a character// within chr_a within the object//long SysString::firstNotChr(unichar chr_a, long start_a) const { // check the arguments // if (start_a > length()) { return Integral::NO_POS; } if (start_a == Integral::NO_POS) { start_a = 0; } // find the index // for (long i = start_a; i < length(); i++) { if (chr_a != (unichar)value_d[i]) { return i; } } // exit ungracefully // return Integral::NO_POS;}// method: lastNotChr//// arguments:// unichar chr: (input) a character// long end: (input) where to stop looking//// return: long index within the string//// this method finds the last instance of a character not equal to a character// within chr_a within the object//long SysString::lastNotChr(unichar chr_a, long end_a) const { // length can't be less than or equal to zero // if (length() < 1) { return Integral::NO_POS; } // check the arguments // if ((end_a == Integral::NO_POS) || (end_a >= length())) { end_a = length() - 1; } // loop over elements and find the last instance // for (long i = end_a; i >= 0; i--) { if (chr_a != value_d[i]) { return i; } } // exit ungracefully // return Integral::NO_POS;}// method: firstChar//// arguments:// long start: (input) where to start looking// boolean (SysChar::*method) (void) const: (input) a global function pointer//// return: long index within the string//// this method finds the first instance of character specified by// method_a within the object. this is a special method which is used// for all the methods of the type firstAlpha, firstAlnum etc. method_a// is a function pointer for SysChar class, which can be of the type// isAlpha, isAlnum etc.//long SysString::firstChar(long start_a, boolean (SysChar::*method_a) (void) const) const { // declare a SysChar object // SysChar c; // check the arguments // if (start_a > length()) { return Integral::NO_POS; } if (start_a == Integral::NO_POS) { start_a = 0; } // find the index // for (long i = start_a; i < length(); i++) { // assign unichar value to the SysChar object // c.assign(value_d[i]); // call the specified method of SysChar // if ((c.*method_a)()) { // return the index // return i; } } // exit ungracefully // return Integral::NO_POS;}// method: firstNotChar//// arguments:// long start: (input) where to start looking// boolean (SysChar::*method) (void) const: (input) a global function pointer//// return: long index within the string//// this method finds the first instance of character not specified by// method_a within the object. this is a special method which is used// for all the methods of the type firstNotAlpha, firstNotAlnum// etc. method_a is a function pointer for SysChar class, which can be// of the type isAlpha, isAlnum etc.//long SysString::firstNotChar(long start_a, boolean (SysChar::*method_a) (void) const) const { // declare a SysChar object // SysChar c; // check the arguments // if (start_a > length()) { return Integral::NO_POS; } if (start_a == Integral::NO_POS) { start_a = 0; } // find the index // for (long i = start_a; i < length(); i++) { // assign unichar value to the SysChar object // c.assign(value_d[i]); // call the specified method of SysChar // if (!(c.*method_a)()) { // return the index // return i; } } // exit ungracefully // return Integral::NO_POS;}// method: lastChar//// arguments:// long end: (input) where to stop looking// boolean (SysChar::*method) (void) const: (input) a global function pointer//// return: long index within the string//// this method finds the last instance of character specified by// method_a within the object. this is a special method which is used// for all the methods of the type lastAlpha, lastAlnum etc. method_a// is a function pointer for SysChar class, which can be of the type// isAlpha, isAlnum etc.//long SysString::lastChar(long end_a, boolean (SysChar::*method_a) (void) const) const { // declare a SysChar object // SysChar c; // length can't be less than or equal to zero // if (length() < 1) { return Integral::NO_POS; } // check the arguments // if ((end_a == Integral::NO_POS) || (end_a >= length())) { end_a = length() - 1; } // find the index // for (long i = end_a; i >= 0; i--) { // assign unichar value to the SysChar object // c.assign(value_d[i]); // call the specified method of SysChar // if ((c.*method_a)()) { // return the index // return i; } } // exit ungracefully // return Integral::NO_POS;}// method: lastNotChar//// arguments:// long end: (input) where to stop looking// boolean (SysChar::*method) (void) const: (input) a global function pointer//// return: long index within the string//// this method finds the last instance of character not specified by// method_a within the object. this is a special method which is used// for all the methods of the type lastNotAlpha, lastNotAlnum etc. method_a// is a function pointer for SysChar class, which can be of the type// isAlpha, isAlnum etc.//long SysString::lastNotChar(long end_a, boolean (SysChar::*method_a) (void) const) const { // declare a SysChar object // SysChar c; // length can't be less than or equal to zero // if (length() < 1) { return Integral::NO_POS; } // check the arguments // if ((end_a == Integral::NO_POS) || (end_a >= length())) { end_a = length() - 1; } // find the index // for (long i = end_a; i >= 0; i--) { // assign unichar value to the SysChar object // c.assign(value_d[i]); // call the specified method of SysChar // if (!(c.*method_a)()) { // return the index // return i; } } // exit ungracefully // return Integral::NO_POS;}// method: numEqual//// arguments:// unichar arg: (input) character to test for//// return: the number of characters equal to arg//// find the number of characters equal to arg//long SysString::numEqual(unichar arg_a) const { // initialize a counter // long i = 0; // loop through the string // for (long j = 0; j < length(); j++) { // if the character is equal, increment count // if (arg_a == value_d[j]) { i++; } } // return the number // return i;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -