| | 1 | | namespace MoreStructures.SuffixArrays; |
| | 2 | |
|
| | 3 | | /// <summary> |
| | 4 | | /// The Suffix Array of a terminator-terminated text T is an <see cref="int"/> sequence where the i-th element is the |
| | 5 | | /// index in T of the 1st char of a suffix Si of T, and Si < Sj for each i < j. |
| | 6 | | /// </summary> |
| | 7 | | /// <remarks> |
| | 8 | | /// Suffixes of the terminator-terminated text "mississippi$" are: |
| | 9 | | /// <br/> |
| | 10 | | /// - "mississippi$", at index 0; |
| | 11 | | /// <br/> |
| | 12 | | /// - "ississippi$", at index 1; |
| | 13 | | /// <br/> |
| | 14 | | /// - "ssissippi$", at index 2; |
| | 15 | | /// <br/> |
| | 16 | | /// - etc. |
| | 17 | | /// <br/> |
| | 18 | | /// Sorting suffixes in lexicographic order gives: |
| | 19 | | /// - "$mississippi", at index 11; |
| | 20 | | /// <br/> |
| | 21 | | /// - "i$", at index 10; |
| | 22 | | /// <br/> |
| | 23 | | /// - "ippi$", at index 7; |
| | 24 | | /// <br/> |
| | 25 | | /// - "issippi$", at index 4; |
| | 26 | | /// <br/> |
| | 27 | | /// - etc. |
| | 28 | | /// <br/> |
| | 29 | | /// So the Suffix Array of "mississippi$" is { 11, 10, 7, 4, ... }. |
| | 30 | | /// </remarks> |
| | 31 | | /// <param name="Indexes"> |
| | 32 | | /// The sequence of indexes, each one marking the beginning of a suffix of the text. Is a <see cref="IEnumerable{T}"/>, |
| | 33 | | /// rather than an <see cref="IList{T}"/>, so that values can be generated lazily and dynamically. |
| | 34 | | /// </param> |
| 357 | 35 | | public record struct SuffixArray(IEnumerable<int> Indexes); |