BAN: Implement find() for StringView

This commit is contained in:
2023-12-23 18:43:52 +02:00
parent f371fabe35
commit 2e77718f07
2 changed files with 21 additions and 1 deletions

View File

@@ -145,6 +145,22 @@ namespace BAN
return m_data[0];
}
BAN::Optional<StringView::size_type> StringView::find(char ch) const
{
for (size_type i = 0; i < m_size; i++)
if (m_data[i] == ch)
return i;
return {};
}
BAN::Optional<StringView::size_type> StringView::find(bool(*comp)(char)) const
{
for (size_type i = 0; i < m_size; i++)
if (comp(m_data[i]))
return i;
return {};
}
bool StringView::contains(char ch) const
{
for (size_type i = 0; i < m_size; i++)