MCPcopy Create free account
hub / github.com/apache/impala / FindNth

Function FindNth

be/src/gutil/strings/util.cc:1027–1037  ·  view source on GitHub ↗

------------------------------------------------------------------------ FindNth() return index of nth occurrence of c in the string, or string::npos if n > number of occurrences of c. (returns string::npos = -1 if n <= 0) ------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1025// (returns string::npos = -1 if n <= 0)
1026//------------------------------------------------------------------------
1027int FindNth(StringPiece s, char c, int n) {
1028 size_t pos = string::npos;
1029
1030 for ( int i = 0; i < n; ++i ) {
1031 pos = s.find_first_of(c, pos + 1);
1032 if ( pos == StringPiece::npos ) {
1033 break;
1034 }
1035 }
1036 return pos;
1037}
1038
1039//------------------------------------------------------------------------
1040// ReverseFindNth()

Callers

nothing calls this directly

Calls 1

find_first_ofMethod · 0.45

Tested by

no test coverage detected