Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    ConstrainedList<T> Class

    Namespace: Stride.Core.Collections
    Assembly: Stride.Core.dll

    Represent a collection associated with a constraint. When an item is added to this collection, it is tested against the constraint. If the test fails, the item can either be discarded, or an exception can be thrown. The desired behavior can be defined with ThrowException.

    System.Object → ConstrainedList<T>
    Derived from ConstrainedList<T>: SafeList<T>

    [DataSerializer(typeof(ListAllSerializer<, >), Mode = DataSerializerGenericMode.TypeAndGenericArguments)]
    public class ConstrainedList<T> : IList<T>, ICollection<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
    Type Parameters
    Name Description
    T
    Name Description
    Constructors
    ConstrainedList()
    ConstrainedList(Func<ConstrainedList<T>, T, Boolean>, Boolean, String)
    Properties
    Constraint

    Gets or sets the constraint for items added to the collection. If null, this collection behaves like a System.Collections.Generic.List<T>.

    Count
    IsReadOnly
    Item[Int32]
    ThrowException

    Gets or sets whether the collection should throw an System.ArgumentException when an item to add or insert doesn't pass the constraint.

    Methods
    Add(T)
    Clear()
    Contains(T)
    CopyTo(T[], Int32)
    GetEnumerator()
    IndexOf(T)
    Insert(Int32, T)
    Remove(T)
    RemoveAt(Int32)
    Explicit Interface Implementations
    IEnumerable<T>.GetEnumerator()
    IEnumerable.GetEnumerator()
    | Improve this Doc View Source

    Constructors


    ConstrainedList()

    public ConstrainedList()

    ConstrainedList(Func<ConstrainedList<T>, T, Boolean>, Boolean, String)

    public ConstrainedList(Func<ConstrainedList<T>, T, bool> constraint = null, bool throwException = true, string errorMessage = null)
    Parameters
    Type Name Description
    System.Func<ConstrainedList<T>, T, System.Boolean> constraint
    System.Boolean throwException
    System.String errorMessage
    | Improve this Doc View Source

    Properties


    Constraint

    Gets or sets the constraint for items added to the collection. If null, this collection behaves like a System.Collections.Generic.List<T>.

    public Func<ConstrainedList<T>, T, bool> Constraint { get; set; }
    Property Value
    Type Description
    System.Func<ConstrainedList<T>, T, System.Boolean>

    Count

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

    IsReadOnly

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

    Item[Int32]

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

    ThrowException

    Gets or sets whether the collection should throw an System.ArgumentException when an item to add or insert doesn't pass the constraint.

    public bool ThrowException { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Methods


    Add(T)

    public void Add(T item)
    Parameters
    Type Name Description
    T item

    Clear()

    public void Clear()

    Contains(T)

    public bool Contains(T item)
    Parameters
    Type Name Description
    T item
    Returns
    Type Description
    System.Boolean

    CopyTo(T[], Int32)

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

    GetEnumerator()

    public List<T>.Enumerator GetEnumerator()
    Returns
    Type Description
    System.Collections.Generic.List.Enumerator<>

    IndexOf(T)

    public int IndexOf(T item)
    Parameters
    Type Name Description
    T item
    Returns
    Type Description
    System.Int32

    Insert(Int32, T)

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

    Remove(T)

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

    RemoveAt(Int32)

    public void RemoveAt(int index)
    Parameters
    Type Name Description
    System.Int32 index
    | Improve this Doc View Source

    Explicit Interface Implementations


    IEnumerable<T>.GetEnumerator()

    IEnumerator<T> IEnumerable<T>.GetEnumerator()
    Returns
    Type Description
    System.Collections.Generic.IEnumerator<T>

    IEnumerable.GetEnumerator()

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

    Extension Methods

    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    ArrayExtensions.ComputeHash<T>(ICollection<T>, IEqualityComparer<T>)
    CollectionExtensions.SwapRemove<T>(IList<T>, T)
    CollectionExtensions.SwapRemoveAt<T>(IList<T>, Int32)
    CollectionExtensions.IndexOf<T>(IReadOnlyList<T>, T)
    EnumerableExtensions.IsNullOrEmpty(IEnumerable)
    EnumerableExtensions.ForEach<T>(IEnumerable, Action<T>)
    EnumerableExtensions.ForEach<T>(IEnumerable<T>, Action<T>)
    EnumerableExtensions.IndexOf<T>(IEnumerable<T>, Func<T, Boolean>)
    EnumerableExtensions.LastIndexOf<T>(IEnumerable<T>, Func<T, Boolean>)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation