Function rfind
Summary
#include <include/EASTL/string.h>
(1) size_type rfind(const this_type &x, size_type position=npos) const EA_NOEXCEPT
(2) size_type rfind(const value_type *p, size_type position=npos) const
(3) size_type rfind(const value_type *p, size_type position, size_type n) const
(4) size_type rfind(value_type c, size_type position=npos) const EA_NOEXCEPT
Function overload
Synopsis
#include <include/EASTL/string.h>
size_type rfind(const this_type &x, size_type position=npos) const EA_NOEXCEPT
Description
Reverse find operations.
Source
Lines 2686-2691 in include/EASTL/string.h. Line 688 in include/EASTL/string.h.
template <typename T, typename Allocator>
inline typename basic_string<T, Allocator>::size_type
basic_string<T, Allocator>::rfind(const this_type& x, size_type position) const EA_NOEXCEPT
{
return rfind(x.internalLayout().BeginPtr(), position, x.internalLayout().GetSize());
}
Synopsis
#include <include/EASTL/string.h>
size_type rfind(const value_type *p, size_type position=npos) const
Description
No description yet.
Source
Lines 2694-2699 in include/EASTL/string.h. Line 689 in include/EASTL/string.h.
template <typename T, typename Allocator>
inline typename basic_string<T, Allocator>::size_type
basic_string<T, Allocator>::rfind(const value_type* p, size_type position) const
{
return rfind(p, position, (size_type)CharStrlen(p));
}
Synopsis
#include <include/EASTL/string.h>
size_type rfind(const value_type *p, size_type position, size_type n) const
Description
No description yet.
Source
Lines 2702-2735 in include/EASTL/string.h. Line 690 in include/EASTL/string.h.
template <typename T, typename Allocator>
typename basic_string<T, Allocator>::size_type
basic_string<T, Allocator>::rfind(const value_type* p, size_type position, size_type n) const
{
// Disabled because it's not clear what values are valid for position.
// It is documented that npos is a valid value, though. We return npos and
// don't crash if postion is any invalid value.
//#if EASTL_ASSERT_ENABLED
// if(EASTL_UNLIKELY((position != npos) && (position > (size_type)(mpEnd - mpBegin))))
// EASTL_FAIL_MSG("basic_string::rfind -- invalid position");
//#endif
// Note that a search for a zero length string starting at position = end() returns end() and not npos.
// Note by Paul Pedriana: I am not sure how this should behave in the case of n == 0 and position > size.
// The standard seems to suggest that rfind doesn't act exactly the same as find in that input position
// can be > size and the return value can still be other than npos. Thus, if n == 0 then you can
// never return npos, unlike the case with find.
const size_type nLength = internalLayout().GetSize();
if(EASTL_LIKELY(n <= nLength))
{
if(EASTL_LIKELY(n))
{
const const_iterator pEnd = internalLayout().BeginPtr() + eastl::min_alt(nLength - n, position) + n;
const const_iterator pResult = CharTypeStringRSearch(internalLayout().BeginPtr(), pEnd, p, p + n);
if(pResult != pEnd)
return (size_type)(pResult - internalLayout().BeginPtr());
}
else
return eastl::min_alt(nLength, position);
}
return npos;
}
Synopsis
#include <include/EASTL/string.h>
size_type rfind(value_type c, size_type position=npos) const EA_NOEXCEPT
Description
No description yet.
Source
Lines 2738-2754 in include/EASTL/string.h. Line 691 in include/EASTL/string.h.
template <typename T, typename Allocator>
typename basic_string<T, Allocator>::size_type
basic_string<T, Allocator>::rfind(value_type c, size_type position) const EA_NOEXCEPT
{
// If n is zero or position is >= size, we return npos.
const size_type nLength = internalLayout().GetSize();
if(EASTL_LIKELY(nLength))
{
const value_type* const pEnd = internalLayout().BeginPtr() + eastl::min_alt(nLength - 1, position) + 1;
const value_type* const pResult = CharTypeStringRFind(pEnd, internalLayout().BeginPtr(), c);
if(pResult != internalLayout().BeginPtr())
return (size_type)((pResult - 1) - internalLayout().BeginPtr());
}
return npos;
}