Search Results for

    Show / Hide Table of Contents

    Class StateCollection

    Represents a collection of states belonging to a Variable.

    Inheritance
    System.Object
    StateCollection
    Implements
    System.Collections.Generic.IList<State>
    System.Collections.Generic.ICollection<State>
    System.Collections.Generic.IEnumerable<State>
    System.Collections.IList
    System.Collections.ICollection
    System.Collections.IEnumerable
    System.Collections.Specialized.INotifyCollectionChanged
    System.ComponentModel.INotifyPropertyChanged
    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: BayesServer
    Assembly: BayesServer.dll
    Syntax
    public sealed class StateCollection : IList<State>, ICollection<State>, IEnumerable<State>, IList, ICollection, IEnumerable, INotifyCollectionChanged, INotifyPropertyChanged
    Remarks

    Note that a continuous variable always has a single state.

    Properties

    Count

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

    IsReadOnly

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

    Item[Int32]

    Gets or sets the State at the specified index.

    Declaration
    public State this[int index] { get; set; }
    Parameters
    Type Name Description
    System.Int32 index
    Property Value
    Type Description
    State

    The state.

    Item[String]

    Performs a case sensitive lookup.

    Declaration
    public State this[string name] { get; }
    Parameters
    Type Name Description
    System.String name

    The name of the State to find.

    Property Value
    Type Description
    State

    A State with the specified name if found; otherwise null.

    Item[String, Boolean]

    Performs a case sensitive lookup.

    Declaration
    public State this[string name, bool throwIfNotFound] { get; }
    Parameters
    Type Name Description
    System.String name

    The name of the State to find.

    System.Boolean throwIfNotFound

    When true throws an exception if the name is not found.

    Property Value
    Type Description
    State

    The State with the specified name; otherwise null.

    Variable

    Gets the Variable this collection belongs to. This is null if this is a child state collection.

    Declaration
    public Variable Variable { get; }
    Property Value
    Type Description
    Variable

    The variable that owns this collection.

    Methods

    Add(State)

    Declaration
    public void Add(State item)
    Parameters
    Type Name Description
    State item
    Exceptions
    Type Condition
    System.ArgumentNullException

    item is null.

    Clear()

    Declaration
    public void Clear()

    Contains(State)

    Determines whether a State is in the collection. The operation is O(1).

    Declaration
    public bool Contains(State item)
    Parameters
    Type Name Description
    State item

    The State to locate in the collection. The value can be null.

    Returns
    Type Description
    System.Boolean

    true if item is found in the collection; otherwise, false.

    CopyTo(State[], Int32)

    Declaration
    public void CopyTo(State[] array, int arrayIndex)
    Parameters
    Type Name Description
    State[] array
    System.Int32 arrayIndex

    FindByValue(Object)

    Finds the state whose value/> matches the given value, or null if a match is not found.

    Declaration
    public State FindByValue(object value)
    Parameters
    Type Name Description
    System.Object value

    The value to match to a Value.

    Returns
    Type Description
    State

    The matching State or null if a match is not found.

    Remarks

    For discretized variables, each Value is an BayesServer.Interval{T}, and this method returns the state whose interval contains the given value.

    GetEnumerator()

    Returns an enumerator that iterates through the collection.

    Declaration
    public IEnumerator<State> GetEnumerator()
    Returns
    Type Description
    System.Collections.Generic.IEnumerator<State>

    A System.Collections.Generic.IEnumerator<T> that can be used to iterate through the collection.

    IndexOf(State)

    Determines the index of a specific State in the collection. This operation is O(1).

    Declaration
    public int IndexOf(State item)
    Parameters
    Type Name Description
    State item

    The state to find. The value can be null.

    Returns
    Type Description
    System.Int32

    The index of the state in the collection, or -1 if not found.

    Insert(Int32, State)

    Inserts an element into the collection at the specified index.

    Declaration
    public void Insert(int index, State item)
    Parameters
    Type Name Description
    System.Int32 index

    The zero based index at which to add the element.

    State item

    The item to insert. Cannot be null.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised when item is null.

    System.InvalidOperationException

    Raised if the state already belongs to a network.

    System.ArgumentOutOfRangeException

    index is less than 0.-or-index is equal to or greater than the collection count.

    Remove(State)

    Declaration
    public bool Remove(State item)
    Parameters
    Type Name Description
    State item
    Returns
    Type Description
    System.Boolean

    RemoveAt(Int32)

    Removes an element from the collection at the specified index.

    Declaration
    public void RemoveAt(int index)
    Parameters
    Type Name Description
    System.Int32 index

    The zero based index at which to remove the element.

    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    index is less than 0.-or-index is equal to or greater than the collection count.

    Events

    CollectionChanged

    Declaration
    public event NotifyCollectionChangedEventHandler CollectionChanged
    Event Type
    Type Description
    System.Collections.Specialized.NotifyCollectionChangedEventHandler

    PropertyChanged

    Declaration
    public event PropertyChangedEventHandler PropertyChanged
    Event Type
    Type Description
    System.ComponentModel.PropertyChangedEventHandler

    Explicit Interface Implementations

    ICollection.CopyTo(Array, Int32)

    Declaration
    void ICollection.CopyTo(Array array, int index)
    Parameters
    Type Name Description
    System.Array array
    System.Int32 index

    ICollection.Count

    Declaration
    int ICollection.Count { get; }
    Returns
    Type Description
    System.Int32

    ICollection.IsSynchronized

    Declaration
    bool ICollection.IsSynchronized { get; }
    Returns
    Type Description
    System.Boolean

    ICollection.SyncRoot

    Declaration
    object ICollection.SyncRoot { get; }
    Returns
    Type Description
    System.Object

    IEnumerable.GetEnumerator()

    Returns an enumerator that iterates through a collection.

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

    An System.Collections.IEnumerator object that can be used to iterate through the collection.

    IList.Add(Object)

    Declaration
    int IList.Add(object value)
    Parameters
    Type Name Description
    System.Object value
    Returns
    Type Description
    System.Int32

    IList.Clear()

    Declaration
    void IList.Clear()

    IList.Contains(Object)

    Declaration
    bool IList.Contains(object value)
    Parameters
    Type Name Description
    System.Object value
    Returns
    Type Description
    System.Boolean

    IList.IndexOf(Object)

    Declaration
    int IList.IndexOf(object value)
    Parameters
    Type Name Description
    System.Object value
    Returns
    Type Description
    System.Int32

    IList.Insert(Int32, Object)

    Declaration
    void IList.Insert(int index, object value)
    Parameters
    Type Name Description
    System.Int32 index
    System.Object value

    IList.IsFixedSize

    Declaration
    bool IList.IsFixedSize { get; }
    Returns
    Type Description
    System.Boolean

    IList.IsReadOnly

    Declaration
    bool IList.IsReadOnly { get; }
    Returns
    Type Description
    System.Boolean

    IList.Item[Int32]

    Declaration
    object IList.this[int index] { get; set; }
    Parameters
    Type Name Description
    System.Int32 index
    Returns
    Type Description
    System.Object

    IList.Remove(Object)

    Declaration
    void IList.Remove(object value)
    Parameters
    Type Name Description
    System.Object value

    IList.RemoveAt(Int32)

    Declaration
    void IList.RemoveAt(int index)
    Parameters
    Type Name Description
    System.Int32 index

    Implements

    System.Collections.Generic.IList<T>
    System.Collections.Generic.ICollection<T>
    System.Collections.Generic.IEnumerable<T>
    System.Collections.IList
    System.Collections.ICollection
    System.Collections.IEnumerable
    System.Collections.Specialized.INotifyCollectionChanged
    System.ComponentModel.INotifyPropertyChanged

    See Also

    State
    In This Article
    Back to top Copyright Bayes Server Ltd. All rights Reserved.