forked from Bananymous/banan-os
BAN: Implement StringView::starts_with()
This commit is contained in:
parent
61aa1ea11f
commit
b1869bced4
|
@ -165,6 +165,21 @@ namespace BAN
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr bool starts_with(BAN::StringView target) const
|
||||||
|
{
|
||||||
|
if (target.size() > m_size)
|
||||||
|
return false;
|
||||||
|
for (size_type i = 0; i < m_size - target.size(); i++)
|
||||||
|
{
|
||||||
|
bool valid = true;
|
||||||
|
for (size_type j = 0; j < target.size() && valid; j++)
|
||||||
|
valid = (m_data[i + j] == target[j]);
|
||||||
|
if (valid)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr bool contains(char ch) const
|
constexpr bool contains(char ch) const
|
||||||
{
|
{
|
||||||
for (size_type i = 0; i < m_size; i++)
|
for (size_type i = 0; i < m_size; i++)
|
||||||
|
|
Loading…
Reference in New Issue