| | 1 | | using MoreStructures.RecImmTrees.Paths; |
| | 2 | | using MoreStructures.Utilities; |
| | 3 | |
|
| | 4 | | namespace MoreStructures.SuffixStructures; |
| | 5 | |
|
| | 6 | | /// <summary> |
| | 7 | | /// Extension methods for all <see cref="ISuffixStructureNode{TEdge, TNode}"/> node concretions. |
| | 8 | | /// </summary> |
| | 9 | | public static class SuffixStructureNodeExtensions |
| | 10 | | { |
| 1 | 11 | | private static readonly INodeToLeafPathsBuilder NodeToLeafPathsBuilder = |
| 1 | 12 | | new FullyIterativeNodeToLeafPathsBuilder(); |
| | 13 | |
|
| | 14 | | /// <summary> |
| | 15 | | /// Returns all suffixes for the provided text from the node down the |
| | 16 | | /// <see cref="ISuffixStructureNode{TEdge, TNode}"/>, up to leaves. |
| | 17 | | /// </summary> |
| | 18 | | /// <param name="node">The node, to start the structure traversal from.</param> |
| | 19 | | /// <param name="text">The text with terminator, whose suffixes have to be extracted.</param> |
| | 20 | | /// <typeparam name="TEdge"> |
| | 21 | | /// <inheritdoc cref="ISuffixStructureEdge{TEdge, TNode}" path="/typeparam[@name='TEdge']"/> |
| | 22 | | /// </typeparam> |
| | 23 | | /// <typeparam name="TNode"> |
| | 24 | | /// <inheritdoc cref="ISuffixStructureNode{TEdge, TNode}" path="/typeparam[@name='TNode']"/> |
| | 25 | | /// </typeparam> |
| | 26 | | /// <returns>A sequence of <see cref="IValueEnumerable{T}"/>, each one being a suffix.</returns> |
| | 27 | | public static IEnumerable<IEnumerable<char>> GetAllSuffixesFor<TEdge, TNode>( |
| | 28 | | this TNode node, TextWithTerminator text) |
| | 29 | | where TEdge : ISuffixStructureEdge<TEdge, TNode> |
| | 30 | | where TNode : ISuffixStructureNode<TEdge, TNode> => |
| | 31 | |
|
| 6 | 32 | | NodeToLeafPathsBuilder |
| 6 | 33 | | .GetAllNodeToLeafPaths<TEdge, TNode>(node) |
| 52 | 34 | | .Select(rootToLeafPath => rootToLeafPath.SuffixFor(text)) |
| 6 | 35 | | .AsValue(); |
| | 36 | | } |