Example #1
0
        public void SuffixTreeTests(string text, string pattern, string expected)
        {
            var alphabet     = new HashSet <char>((text + pattern).ToCharArray());
            var expectedList = expected.Length > 0
                ? expected.Split(',').Select(int.Parse).ToArray()
                : new int[] {};

            var tree   = new SuffixTree <char>(text.ToCharArray(), alphabet);
            var result = tree.FindAllOccurrences(pattern.ToCharArray());

            CollectionAssert.AreEquivalent(expectedList, result);
        }
        public List <DocumentOccurrences> ReportOccurrences(byte[] pattern)
        {
            var occurrences = tree.FindAllOccurrences(pattern.Select(c => (int)c).ToArray());

            return(MapInsideDocuments(occurrences));
        }