mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
IndexOfAny
Implemented IndexOfAny for String and StringView.
This commit is contained in:
parent
3714bdb84f
commit
d17b016397
1 changed files with 52 additions and 0 deletions
|
@ -1277,6 +1277,32 @@ namespace System
|
|||
return -1;
|
||||
}
|
||||
|
||||
public int IndexOfAny(char8[] targets)
|
||||
{
|
||||
return IndexOfAny(targets, 0, mLength);
|
||||
}
|
||||
|
||||
public int IndexOfAny(char8[] targets, int startIdx)
|
||||
{
|
||||
return IndexOfAny(targets, startIdx, mLength - startIdx);
|
||||
}
|
||||
|
||||
public int IndexOfAny(char8[] targets, int startIdx, int count)
|
||||
{
|
||||
let ptr = Ptr;
|
||||
for (var i = startIdx; i < count; i++)
|
||||
{
|
||||
let ch = ptr[i];
|
||||
for (let tag in targets)
|
||||
{
|
||||
if (ch == tag)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public bool Contains(String str)
|
||||
{
|
||||
return IndexOf(str) != -1;
|
||||
|
@ -2922,6 +2948,32 @@ namespace System
|
|||
return -1;
|
||||
}
|
||||
|
||||
public int IndexOfAny(char8[] targets)
|
||||
{
|
||||
return IndexOfAny(targets, 0, mLength);
|
||||
}
|
||||
|
||||
public int IndexOfAny(char8[] targets, int startIdx)
|
||||
{
|
||||
return IndexOfAny(targets, startIdx, mLength - startIdx);
|
||||
}
|
||||
|
||||
public int IndexOfAny(char8[] targets, int startIdx, int count)
|
||||
{
|
||||
let ptr = mPtr;
|
||||
for (var i = startIdx; i < count; i++)
|
||||
{
|
||||
let ch = ptr[i];
|
||||
for (let tag in targets)
|
||||
{
|
||||
if (ch == tag)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public bool Contains(char8 c)
|
||||
{
|
||||
for (int i = 0; i < mLength; i++)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue