コード例 #1
0
ファイル: Samples.cs プロジェクト: sohas/Kontur.LogPacker
        internal readonly BMSearcher[] searchers;   //поисковики бойера-мура по каждому образцу00

        internal Samples(IEnumerable <byte[]> words)
        {
            var args = words.ToArray();

            if (args.Length == 0 || args.Length > 255)
            {
                throw new ArgumentNullException("must use at least 1 and not more than 255 words");
            }
            Length            = args.Length + 1;
            sizes00           = new int[Length];
            searchers         = new BMSearcher[Length];
            sizes00[0]        = 1;
            searchers[0]      = null;//not use in search
            allSamplesAsBytes = new ByteLiner(words).byteLine;

            for (var i = 1; i < Length; i++)
            {
                var temp = new List <byte>();
                foreach (var b in args[i - 1])
                {
                    temp.Add(b);
                    if (b == marker)
                    {
                        temp.Add(b);
                    }
                }
                sizes00[i]   = temp.Count;
                searchers[i] = new BMSearcher(temp.ToArray());
            }
        }
コード例 #2
0
        internal ByteLiner(byte[] byteLine)
        {
            this.byteLine = byteLine;
            var res  = new List <byte[]>();
            int temp = 0;

            var finder = new BMSearcher(devideKey).Search(byteLine, 0, byteLine.Length);

            foreach (var position in finder)
            {
                if (position != temp)
                {
                    continue;
                }

                temp = BitConverter.ToInt32(byteLine, position + 4);
                var bytes = new byte[temp - position - 8];
                Array.Copy(byteLine, position + 8, bytes, 0, temp - position - 8);
                res.Add(bytes);
            }

            if (temp != byteLine.Length)
            {
                success = false;
                bytess  = null;
            }
            else
            {
                success = true;
            }

            bytess = res.ToArray();
        }