Skip to content

Commit c001f0a

Browse files
committed
Release 1.290.2025
1 parent 8ffbcb1 commit c001f0a

35 files changed

+4138
-180
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* All intellectual rights of this framework, including this source file belong to Appicacy, René Vaessen.
3+
* Customers of Appicacy, may copy and change it, as long as this header remains.
4+
*
5+
*/
6+
7+
namespace GenXdev.Buffers
8+
{
9+
public static class BufferExtensions
10+
{
11+
public static int IndexOf(byte[] Buffer, byte[] SearchSequence, int StartPosition = 0)
12+
{
13+
int matchCount = 0;
14+
15+
for (var i = StartPosition; i < Buffer.Length; i++)
16+
{
17+
if (Buffer[i] == SearchSequence[matchCount])
18+
{
19+
matchCount++;
20+
21+
if (matchCount == SearchSequence.Length) return (i + 1) - SearchSequence.Length;
22+
}
23+
else
24+
{
25+
matchCount = 0;
26+
}
27+
}
28+
29+
return -1;
30+
}
31+
32+
public static int IndexOf(byte[] Buffer, byte SearchValue, int StartPosition = 0)
33+
{
34+
for (var i = StartPosition; i < Buffer.Length; i++)
35+
{
36+
if (Buffer[i] == SearchValue)
37+
{
38+
return i;
39+
}
40+
}
41+
42+
return -1;
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)