Automata Docs Automata Docs
Automata Docs Automata Docs

Search Results for

    Edit this page

    Class Alphabet

    An alphabet associated with a finite state automaton.

    Inheritance
    object
    Alphabet
    Implements
    IEquatable<Alphabet>
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Automata.Core
    Assembly: Automata.Core.dll
    Syntax
    public class Alphabet : IEquatable<Alphabet>
    Remarks

    An Alphabet is a collection of symbols used by a finite state automaton. It can be extended with new symbols, but symbols cannot be removed. This enables multiple automata to share the same alphabet. Furthermore, automata never needs to deals with strings, but can use integer indices instead for all operations. Default behavior for operations that create new automata is to use the existing alphabet of the input automata. If a new alphabet is needed, an explicit creation of a new alphabet is typically required.

    Constructors

    | Edit this page View Source

    Alphabet()

    Initializes a new empty instance of the Alphabet class.

    Declaration
    public Alphabet()
    | Edit this page View Source

    Alphabet(Alphabet)

    Initializes a new cloned instance of the Alphabet class from the specified alphabet.

    Declaration
    public Alphabet(Alphabet alphabet)
    Parameters
    Type Name Description
    Alphabet alphabet

    Alphabet to initialize the alphabet with.

    | Edit this page View Source

    Alphabet(IEnumerable<string>)

    Initializes a new instance of the Alphabet class with the specified symbols.

    Declaration
    public Alphabet(IEnumerable<string> symbols)
    Parameters
    Type Name Description
    IEnumerable<string> symbols

    Symbols to initialize the alphabet with.

    | Edit this page View Source

    Alphabet(params string[])

    Initializes a new instance of the Alphabet class with the specified symbols.

    Symbols to initialize the alphabet with.
    Declaration
    public Alphabet(params string[] symbols)
    Parameters
    Type Name Description
    string[] symbols

    Properties

    | Edit this page View Source

    Count

    Number of symbols in the alphabet.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    this[int]

    Symbol at the specified index.

    Declaration
    public string this[int index] { get; }
    Parameters
    Type Name Description
    int index

    Index of the symbol to get.

    Property Value
    Type Description
    string

    Symbol at the specified index.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    Thrown when the index is out of range.

    | Edit this page View Source

    this[string]

    Index of the specified symbol.

    Declaration
    public int this[string symbol] { get; }
    Parameters
    Type Name Description
    string symbol

    Symbol whose index to get.

    Property Value
    Type Description
    int

    Index of the specified symbol, or InvalidSymbolIndex if not found.

    | Edit this page View Source

    SymbolIndices

    Returns an enumerable collection of indices of the symbols in the alphabet. This is effectively the integers in range [0 .. Count).

    Declaration
    public IEnumerable<int> SymbolIndices { get; }
    Property Value
    Type Description
    IEnumerable<int>
    | Edit this page View Source

    Symbols

    Readonly collection of symbols in the alphabet.

    Declaration
    public IReadOnlyCollection<string> Symbols { get; }
    Property Value
    Type Description
    IReadOnlyCollection<string>

    Methods

    | Edit this page View Source

    AddAll(IEnumerable<string>)

    Adds all the specified symbols to the alphabet that are not already present.

    Declaration
    public void AddAll(IEnumerable<string> symbols)
    Parameters
    Type Name Description
    IEnumerable<string> symbols

    Symbols to add.

    | Edit this page View Source

    Contains(int)

    Indicates whether the alphabet contains the specified symbol as an integer.

    Declaration
    public bool Contains(int symbol)
    Parameters
    Type Name Description
    int symbol

    Symbol index to locate in the alphabet.

    Returns
    Type Description
    bool

    true iff the symbol is found; otherwise, false.

    | Edit this page View Source

    Contains(string)

    Indicates whether the alphabet contains the specified symbol as a string.

    Declaration
    public bool Contains(string symbol)
    Parameters
    Type Name Description
    string symbol

    Symbol string to locate in the alphabet.

    Returns
    Type Description
    bool

    true iff the symbol is found; otherwise, false.

    | Edit this page View Source

    Equals(Alphabet?)

    Indicates whether the current object is equal to another object of the same type.

    Declaration
    public bool Equals(Alphabet? other)
    Parameters
    Type Name Description
    Alphabet other

    An object to compare with this object.

    Returns
    Type Description
    bool

    true if the current object is equal to the other parameter; otherwise, false.

    | Edit this page View Source

    Equals(object?)

    Determines whether the specified object is equal to the current object.

    Declaration
    public override bool Equals(object? obj)
    Parameters
    Type Name Description
    object obj

    The object to compare with the current object.

    Returns
    Type Description
    bool

    true if the specified object is equal to the current object; otherwise, false.

    Overrides
    object.Equals(object)
    | Edit this page View Source

    GetHashCode()

    Serves as the default hash function.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    A hash code for the current object.

    Overrides
    object.GetHashCode()
    | Edit this page View Source

    GetOrAdd(string)

    Index of the specified symbol or adds it if it does not exist.

    Declaration
    public int GetOrAdd(string symbol)
    Parameters
    Type Name Description
    string symbol

    Symbol to get or add.

    Returns
    Type Description
    int

    Index of the specified symbol.

    | Edit this page View Source

    ToString()

    String that represents the current alphabet, including its size.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    A string representation of the alphabet.

    Overrides
    object.ToString()
    | Edit this page View Source

    ToStringExpanded()

    String with each symbol and its index, separated by a newline.

    Declaration
    public string ToStringExpanded()
    Returns
    Type Description
    string

    A string with each symbol and its index, separated by a newline.

    | Edit this page View Source

    TryGetIndex(string, out int)

    Tries to get the index of the specified symbol.

    Declaration
    public bool TryGetIndex(string symbol, out int index)
    Parameters
    Type Name Description
    string symbol

    Symbol whose index to get.

    int index

    When this method returns, contains the index of the specified symbol, if the symbol is found; otherwise, -1.

    Returns
    Type Description
    bool

    true iff the symbol is found; otherwise, false.

    | Edit this page View Source

    UnionWith(Alphabet)

    Add another alphabet to the current alphabet.

    Declaration
    public Dictionary<int, int> UnionWith(Alphabet other)
    Parameters
    Type Name Description
    Alphabet other

    The other alphabet to merge into this.

    Returns
    Type Description
    Dictionary<int, int>

    A dictionary mapping indices from the other alphabet to the current alphabet.

    Operators

    | Edit this page View Source

    operator ==(Alphabet, Alphabet)

    Declaration
    public static bool operator ==(Alphabet left, Alphabet right)
    Parameters
    Type Name Description
    Alphabet left
    Alphabet right
    Returns
    Type Description
    bool
    | Edit this page View Source

    operator !=(Alphabet, Alphabet)

    Declaration
    public static bool operator !=(Alphabet left, Alphabet right)
    Parameters
    Type Name Description
    Alphabet left
    Alphabet right
    Returns
    Type Description
    bool

    Implements

    IEquatable<T>