SynchronizedList<T>
Wisej.Core.SynchronizedList<T>
Namespace: Wisej.Core
Assembly: Wisej.Framework (3.2.0.0)
Provides a thread-safe collection that contains objects of a type specified by the generic parameter as elements.
C#
VB.NET
public class SynchronizedList<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, IList, ICollection
Public Class SynchronizedList(Of T)
Inherits IList(Of T)
Implements ICollection(Of T), IEnumerable(Of T), IEnumerable, IList, ICollection
Name | Description |
---|---|
T | The type of object contained as items in the thread-safe collection. |
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.
Name | Type | Description |
---|---|---|
capacity | The optional number of element that the list can initially store. | |
collection | The optional collection whose elements are copied to the new list. | |
syncLock | The optional lock reference. |
Throws:
- ArgumentOutOfRangeException The index specified is less than zero or greater than the number of items in the collection.
Adds an item to the thread-safe collection.
Parameter | Type | Description |
---|---|---|
item | The element to be added to the collection. |
Parameter | Type | Description |
---|---|---|
collection | The collection whose elements should be added to the end of the List. The collection itself cannot be null, but it can contain elements that are null, for reference types. |
Throws:
Searches the entire sorted List for an element using the default comparer and returns the zero-based index of the element.
Parameter | Type | Description |
---|---|---|
item | The object to locate. The value can be null for reference types. |
Throws:
- InvalidOperationException The default comparer Default cannot find an implementation of the IComparable generic interface or the IComparable interface for the type of the collection elements.
Searches the entire sorted List for an element using the specified comparer and returns the zero-based index of the element.
Parameter | Type | Description |
---|---|---|
item | The object to locate. The value can be null for reference types. | |
comparer |
Throws:
- InvalidOperationException comparer is null, and the default comparer Default cannot find an implementation of the IComparable generic interface or the IComparable interface for the type of the collection elements.
Removes all items from the collection.
Determines whether the collection contains an element with a specific value.
Parameter | Type | Description |
---|---|---|
item | The object to locate in the collection. |
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.
Parameter | Type | Description |
---|---|---|
match |
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.
Parameter | Type | Description |
---|---|---|
startIndex | The zero-based starting index of the search. | |
match |
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.
Parameter | Type | Description |
---|---|---|
match |
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.
Parameter | Type | Description |
---|---|---|
match |
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.
Parameter | Type | Description |
---|---|---|
startIndex | The zero-based starting index of the search. | |
match |
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.
Parameter | Type | Description |
---|---|---|
startIndex | The zero-based starting index of the search. | |
count | The number of elements in the section to search. | |
match |
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:
- ArgumentOutOfRangeException startIndex is outside the range of valid indexes for the List; or count is less than 0; or startIndex and count do not specify a valid section in the List.
Searches for an element that matches the conditions defined by the specified predicate, and returns the last occurrence within the entire List.
Parameter | Type | Description |
---|---|---|
match |
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.
Parameter | Type | Description |
---|---|---|
startIndex | The zero-based starting index of the search. | |
match |
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.
Parameter | Type | Description |
---|---|---|
match |
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.
Parameter | Type | Description |
---|---|---|
startIndex | The zero-based starting index of the search. | |
match |
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:
Throws:
Returns an enumerator that iterates through the synchronized collection.
Returns the index of the first occurrence of a value in the collection.
Parameter | Type | Description |
---|---|---|
item | Removes all items from the collection. |
Inserts an item into the collection at a specified index.
Throws:
- ArgumentOutOfRangeException The index specified is less than zero or greater than the number of items in the collection.
Parameter | Type | Description |
---|---|---|
index | The zero-based index at which the new elements should be inserted. | |
collection | The collection whose elements should be inserted into the List. The collection itself cannot be null, but it can contain elements that are null, for reference types. |
Throws:
Removes the first occurrence of a specified item from the collection.
Parameter | Type | Description |
---|---|---|
item | The object to remove from the collection. |
Removes all the elements that match the conditions defined by the specified predicate.
Parameter | Type | Description |
---|---|---|
match |
Throws:
Removes an item at a specified index from the collection.
Parameter | Type | Description |
---|---|---|
index | The zero-based index of the element to be retrieved from the collection. |
Throws:
- ArgumentOutOfRangeException The index specified is less than zero or greater than the number of items in the collection.
Throws:
- InvalidOperationException The default comparer Default cannot find an implementation of the IComparable generic interface or the IComparable interface for the type of the collection elements.
Parameter | Type | Description |
---|---|---|
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.
Parameter | Type | Description |
---|---|---|
comparison |
Throws:
- ArgumentException The implementation of comparison caused an error during the sort. For example, comparison might not return 0 when comparing an item with itself.
Parameter | Type | Description |
---|---|---|
comparer | ||
swapCallback | An optional callback method, invoked on every swap. If the callback returns true to indicate that it handled the swap, the default swap is not performed. |
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.
Parameter | Type | Description |
---|---|---|
selector | A transform function to apply to each element. |
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.
Parameter | Type | Description |
---|---|---|
selector | A transform function to apply to each element. |
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.
Parameter | Type | Description |
---|---|---|
selector | A transform function to apply to each element. |
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.
Parameter | Type | Description |
---|---|---|
selector | A transform function to apply to each element. |
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.
Parameter | Type | Description |
---|---|---|
selector | A transform function to apply to each element. |
Throws:
Sets the capacity to the actual number of elements in the List, if that number is less than a threshold value.
Last modified 4mo ago