SynchronizedList<T>

Wisej.Core.SynchronizedList<T>

Namespace: Wisej.Core

Assembly: Wisej.Framework (3.0.0.0)

Provides a thread-safe collection that contains objects of a type specified by the generic parameter as elements.

public class SynchronizedList<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, IList, ICollection

Parameters

Constructors

Initializes a new instance of the SynchronizedList class that contains elements copied from the specified collection and has sufficient capacity to accommodate the number of elements copied and uses the specified syncLock object to synchronize its internal operations.

Properties

Int32: Gets the number of elements contained in the thread-safe collection.

T: Gets an element from the thread-safe collection with a specified index.

Throws:

Object: Gets the object used to synchronize access to the thread-safe collection.

Methods

Adds an item to the thread-safe collection.

Adds the elements of the specified collection to the end of the List.

Throws:

Searches the entire sorted List for an element using the default comparer and returns the zero-based index of the element.

Returns: Int32. The zero-based index of item in the sorted List, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than item or, if there is no larger element, the bitwise complement of Count.

Throws:

Searches the entire sorted List for an element using the specified comparer and returns the zero-based index of the element.

Returns: Int32. The zero-based index of item in the sorted List, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than item or, if there is no larger element, the bitwise complement of Count.

Throws:

Removes all items from the collection.

Determines whether the collection contains an element with a specific value.

Returns: Boolean. true if the element value is found in the collection; otherwise false.

Copies the elements of the collection to a specified array, starting at a particular index.

Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire List.

Returns: T. The first element that matches the conditions defined by the specified predicate, if found; otherwise, the default value.

Throws:

Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire List.

Returns: T. The first element that matches the conditions defined by the specified predicate, if found; otherwise, the default value.

Throws:

Retrieves all the elements that match the conditions defined by the specified predicate.

Returns: List<T>. A List containing all the elements that match the conditions defined by the specified predicate, if found; otherwise, an empty List.

Throws:

Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the entire List.

Returns: Int32. The zero-based index of the first occurrence of an element that matches the conditions defined by match , if found; otherwise, –1.

Throws:

Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the range of elements in the List that extends from the specified index to the last element.

Returns: Int32. The zero-based index of the first occurrence of an element that matches the conditions defined by match , if found; otherwise, –1.

Throws:

Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the range of elements in the List that starts at the specified index and contains the specified number of elements.

Returns: Int32. The zero-based index of the first occurrence of an element that matches the conditions defined by match , if found; otherwise, –1.

Throws:

Searches for an element that matches the conditions defined by the specified predicate, and returns the last occurrence within the entire List.

Returns: T. The last element that matches the conditions defined by the specified predicate, if found; otherwise, the default value.

Throws:

Searches for an element that matches the conditions defined by the specified predicate, and returns the last occurrence within the entire List.

Returns: T. The last element that matches the conditions defined by the specified predicate, if found; otherwise, the default value.

Throws:

Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the entire List.

Returns: Int32. The zero-based index of the last occurrence of an element that matches the conditions defined by match , if found; otherwise, –1.

Throws:

Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the range of elements in the List that extends from the specified index to the last element.

Returns: Int32. The zero-based index of the last occurrence of an element that matches the conditions defined by match , if found; otherwise, –1.

Throws:

Performs the specified action on each element of the List.

Throws:

Returns an enumerator that iterates through the synchronized collection.

Returns: IEnumerator<T>. An IEnumerator for objects of the type stored in the collection.

Returns the index of the first occurrence of a value in the collection.

Returns: Int32. The zero-based index of the first occurrence of the value in the collection.

Inserts an item into the collection at a specified index.

Throws:

Inserts the elements of a collection into the List at the specified index.

Throws:

Removes the first occurrence of a specified item from the collection.

Returns: Boolean. true if item was successfully removed from the collection; otherwise, false.

Removes all the elements that match the conditions defined by the specified predicate.

Returns: Int32. The number of elements removed from the List .

Throws:

Removes an item at a specified index from the collection.

Throws:

Sorts the elements in the entire List using the default comparer.

Throws:

Sorts the elements in the entire List using the specified comparer.

Throws:

  • InvalidOperationException comparer is null, and the default comparer Default cannot find implementation of the IComparable generic interface or the IComparable interface for the type of the collection elements.

  • ArgumentException The implementation of comparer caused an error during the sort. For example, comparer might not return 0 when comparing an item with itself.

Sorts the elements in the entire List using the specified Comparison.

Throws:

  • ArgumentNullException comparison is null.

  • ArgumentException The implementation of comparison caused an error during the sort. For example, comparison might not return 0 when comparing an item with itself.

Sorts the elements in the entire List using the specified comparer and a related IList to sort in sync with this collection.

Throws:

  • InvalidOperationException comparer is null, and the default comparer Default cannot find implementation of the IComparable generic interface or the IComparable interface for the type of the collection elements.

  • ArgumentException The implementation of comparer caused an error during the sort. For example, comparer might not return 0 when comparing an item with itself.

Computes the sum of the sequence of System.Int32 values that are obtained by invoking a transform function on each element of the list.

Returns: Int32. The sum of the returned values.

Throws:

Computes the sum of the sequence of System.Int64 values that are obtained by invoking a transform function on each element of the list.

Returns: Int64. The sum of the returned values.

Throws:

Computes the sum of the sequence of System.Single values that are obtained by invoking a transform function on each element of the list.

Returns: Single. The sum of the returned values.

Throws:

Computes the sum of the sequence of System.Double values that are obtained by invoking a transform function on each element of the list.

Returns: Double. The sum of the returned values.

Throws:

Computes the sum of the sequence of System.Decimal values that are obtained by invoking a transform function on each element of the list.

Returns: Decimal. The sum of the returned values.

Throws:

Copies the elements of the List to a new array.

Returns: T[]. An array containing copies of the elements of the List.

Sets the capacity to the actual number of elements in the List, if that number is less than a threshold value.

Last updated