Beispiel #1
0
 internal static int ReverseFind(this IList <byte> bytes, IList <byte> sub, int start, int end)
 {
     if (!PythonOps.TryFixSubsequenceIndices(bytes.Count, ref start, ref end))
     {
         return(-1);
     }
     return(bytes.LastIndexOf(sub, end, end - start));
 }
Beispiel #2
0
        internal static bool EndsWith(this IList <byte> self, IList <byte> suffix, int start, int end)
        {
            int len = self.Count;

            if (!PythonOps.TryFixSubsequenceIndices(len, ref start, ref end))
            {
                return(false);
            }

            if (end - start < suffix.Count)
            {
                return(false);
            }

            for (int i = suffix.Count - 1, j = end - 1; i >= 0; i--, j--)
            {
                if (suffix[i] != self[j])
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #3
0
        internal static bool StartsWith(this IList <byte> self, IList <byte> prefix, int start, int end)
        {
            int len = self.Count;

            if (!PythonOps.TryFixSubsequenceIndices(len, ref start, ref end))
            {
                return(false);
            }

            if (end - start < prefix.Count)
            {
                return(false);
            }

            for (int i = 0, j = start; i < prefix.Count; i++, j++)
            {
                if (prefix[i] != self[j])
                {
                    return(false);
                }
            }

            return(true);
        }