Search Results for

    Show / Hide Table of Contents

    Class TextWithTerminator

    A text string with a terminator character, not present in the text.

    Inheritance
    System.Object
    TextWithTerminator
    Implements
    IValueEnumerable<System.Char>
    IEnumerable<System.Char>
    System.IEquatable<TextWithTerminator>
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: MoreStructures
    Assembly: MoreStructures.dll
    Syntax
    public class TextWithTerminator : IValueEnumerable<char>, IEquatable<TextWithTerminator>
    Remarks

    USECASES
    - A terminator-terminated text is required by data structures like Suffix Tries, Trees or Arrays.
    - This object provides type safety, as it allows to tell apart terminator-terminated strings from generic ones.
    - Consistently using TextWithTerminator, rather than System.String, in all library functionalities ensures that the invariant of a terminator-terminated string is always respected.
    - Most string-related functionalities provided by TextWithTerminator, such as Length and Item[Index], as well as and System.Collections.IEnumerable support, are delegated to the underlying string.

    Constructors

    | Improve this Doc View Source

    TextWithTerminator(IEnumerable<Char>, Char, Boolean)

    A text string with a terminator character, not present in the text.

    Declaration
    public TextWithTerminator(IEnumerable<char> Text, char Terminator = '$', bool ValidateInput = true)
    Parameters
    Type Name Description
    System.Collections.IEnumerable<System.Char> Text

    A sequence of chars, of any length (including the empty sequence).

    System.Char Terminator

    A terminator character, not present in Text. If not specified DefaultTerminator is used.

    System.Boolean ValidateInput

    Whether the input, and in particular Text should be validated, while this object is created. Validation takes O(n) time, where n = number of chars in Text and can be an heavy operation.

    Remarks

    USECASES
    - A terminator-terminated text is required by data structures like Suffix Tries, Trees or Arrays.
    - This object provides type safety, as it allows to tell apart terminator-terminated strings from generic ones.
    - Consistently using TextWithTerminator, rather than System.String, in all library functionalities ensures that the invariant of a terminator-terminated string is always respected.
    - Most string-related functionalities provided by TextWithTerminator, such as Length and Item[Index], as well as and System.Collections.IEnumerable support, are delegated to the underlying string.

    Fields

    | Improve this Doc View Source

    DefaultTerminator

    The special character used as a default terminator for the text to build the Suffix Tree of, when no custom terminator is specified. Should not be present in the text.

    Declaration
    public const char DefaultTerminator = '$'
    Field Value
    Type Description
    System.Char

    A single char.

    Properties

    | Improve this Doc View Source

    Item[Index]

    Select a part of this text by the provided index (either w.r.t. the start or to the end of the text).

    Declaration
    public char this[Index index] { get; }
    Parameters
    Type Name Description
    Index index

    The index applied to the underlying string.

    Property Value
    Type Description
    System.Char

    A char containing the selected part.

    | Improve this Doc View Source

    Item[TextWithTerminator.ISelector]

    Select a part of this text by the provided selector.

    Declaration
    public string this[TextWithTerminator.ISelector selector] { get; }
    Parameters
    Type Name Description
    TextWithTerminator.ISelector selector

    Any selector acting on a TextWithTerminator.

    Property Value
    Type Description
    System.String

    A string containing the selected part.

    | Improve this Doc View Source

    Item[Range]

    Select a part of this text by the provided range (start index included, end index excluded).

    Declaration
    public IEnumerable<char> this[Range range] { get; }
    Parameters
    Type Name Description
    Range range

    The range applied to the underlying string.

    Property Value
    Type Description
    System.Collections.IEnumerable<System.Char>

    An of chars containing the selected part.

    | Improve this Doc View Source

    Length

    The total length of this text, including the terminator.

    Declaration
    public int Length { get; }
    Property Value
    Type Description
    System.Int32

    A positive integer (at least 1).

    Remarks

    CACHING
    Calculated just once, and cached for later use.
    Immutability guarantees correctness.

    COMPLEXITY
    - If the text was built with a System.String as input, the operation is O(1) in time.
    - If the text was built with a type optimized by CountO1<TSource>(IEnumerable<TSource>), such as an System.Collections.IList or the operation is O(1) as well.
    - Otherwise, the operation is O(n), where n is the length of Text.

    | Improve this Doc View Source

    Terminator

    Declaration
    public char Terminator { get; set; }
    Property Value
    Type Description
    System.Char

    A single char.

    | Improve this Doc View Source

    TerminatorIndex

    Returns the index of Terminator in this MoreStructures.TextWithTerminator.TextAndTerminator.

    Declaration
    public int TerminatorIndex { get; }
    Property Value
    Type Description
    System.Int32

    A 0-based index. 0 when Text is empty, positive otherwise.

    | Improve this Doc View Source

    Text

    Declaration
    public IEnumerable<char> Text { get; set; }
    Property Value
    Type Description
    System.Collections.IEnumerable<System.Char>

    A sequence of chars.

    Remarks

    Wrapped into a IValueEnumerable<T> to preserve value equality.

    | Improve this Doc View Source

    ValidateInput

    Declaration
    public bool ValidateInput { get; set; }
    Property Value
    Type Description
    System.Boolean

    Methods

    | Improve this Doc View Source

    EndsWith(IEnumerable<Char>)

    Whether this text ends with the provided suffix.

    Declaration
    public bool EndsWith(IEnumerable<char> suffix)
    Parameters
    Type Name Description
    System.Collections.IEnumerable<System.Char> suffix

    A terminator-included of System.Char.

    Returns
    Type Description
    System.Boolean

    True if this text ends by the suffix.

    | Improve this Doc View Source

    GetEnumerator()

    Returns an enumerator that iterates through the collection of chars of the underlying Text string, including the Terminator char.

    Declaration
    public IEnumerator<char> GetEnumerator()
    Returns
    Type Description
    System.Collections.IEnumerator<System.Char>
    | Improve this Doc View Source

    StartsWith(IEnumerable<Char>)

    Whether this text starts with the provided suffix.

    Declaration
    public bool StartsWith(IEnumerable<char> prefix)
    Parameters
    Type Name Description
    System.Collections.IEnumerable<System.Char> prefix

    A terminator-included of System.Char.

    Returns
    Type Description
    System.Boolean

    True if this text starts by the prefix.

    Explicit Interface Implementations

    | Improve this Doc View Source

    IEnumerable.GetEnumerator()

    Returns an enumerator that iterates through the collection of chars of the underlying Text string, including the Terminator char.

    Declaration
    IEnumerator IEnumerable.GetEnumerator()
    Returns
    Type Description
    System.Collections.IEnumerator

    Implements

    IValueEnumerable<T>
    IEnumerable<>
    System.IEquatable<T>

    Extension Methods

    TextWithTerminatorExtensions.ToVirtuallyRotated(TextWithTerminator, Int32)
    SuffixStructureNodeExtensions.GetAllSuffixesFor<TEdge, TNode>(TNode, TextWithTerminator)
    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX