-
Notifications
You must be signed in to change notification settings - Fork 6
ConcurrentList
Houses functionality to implement thread safe concurrent lists. Utilized in the UDPReceiverMulti class.
public class ConcurrentList<T>
: IList<T>, IDisposable| Access | Type | Name | Description | |
|---|---|---|---|---|
| Private | readonly | List<T> | _list | The list to house entries. |
| Private | readonly | ReaderWriterLockSlim | _lock | The lock to verify the list is not access by multiple threads simultaneously. |
| Public | int | Count | The number of entries contained in the list. | |
| Public | bool | IsReadOnly | Whether or not the list is read only. |
| Access | Name | Description |
|---|---|---|
| Public | ConcurrentList() | Default constructor |
| Public | ConcurrentList(int capacity) | Initializes a concurrent list with the specified capacity. |
| Public | ConcurrentList(IEnumerable<T> items) | Initializes a concurrent list with the specified items. |
| Name | Description |
|---|---|
| ~ConcurrentList() | Default destructor |
| Access | Return | Name | Description | |
|---|---|---|---|---|
| Public | void | Add(T item) | Adds a new entry into the list. | |
| Public | void | Clear() | Clears all entries from the list. | |
| Public | bool | Contains(T item) | Gets whether or not the list contains the given item. | |
| Public | void | CopyTo(T[] array, int arrayIndex) | Copies the list to the given array, starting at the given array index. | |
| Public | void | Dispose() | Public function to release all resources used by the _lock variable. Calls the private Dispose function. | |
| Private | void | Dispose(bool disposing) | Private function to release all resources used by the _lock variable. | |
| Public | IEnumerator<T> | GetEnumerator() | Returns an enumerator that iterates through the list. | |
| IEnumerator | IEnumerable.GetEnumerator() | Returns an enumerator that iterates through the list. | ||
| Public | int | IndexOf(T item) | Gets the index of the given item in the list. | |
| Public | void | Insert(int index, T item) | Inserts the given item into the specified index of the list. | |
| Public | bool | Remove(T item) | Removes the given item from the list. | |
| Public | void | RemoveAt(int index) | Removes the item from the list at the given location. |
private readonly List<T> _listThe list to house entries.
private readonly ReaderWriterLockSlim _lockThe lock to verify the list is not access by multiple threads simultaneously.
public int CountThe numer of entries contained in the list.
public bool IsReadOnlyWhether or not the list is read only.
ConcurrentList()Default constructor.
ConcurrentList
(
int Capacity
)Initializes a concurrent list with the specified capacity.
| Parameter | Description |
|---|---|
| Capacity | The capacity to initialize the list with. |
ConcurrentList
(
IEnumerable<T> items
)Initializes a concurrent list with the specified items.
| Parameter | Description |
|---|---|
| items | The items to intitialize the list with. |
~ConcurrentList()Default destructor.
public void Add
(
T item
)Adds a new entry into the list.
| Parameter | Description |
|---|---|
| item | The item to add to the list. |
public void Clear()Clears all entries from the list.
public bool Contains
(
T item
)Gets whether or not the list contains the given item.
| Parameter | Description |
|---|---|
| item | The item to search for in the list. |
| Returns |
|---|
| Whether or not the item is contained in the list. |
public void CopyTo
(
T[] array,
int arrayIndex
)Copies the list to the given array, starting at the given array index.
| Parameter | Description |
|---|---|
| array | The array to copy the list items to. |
| arrayIndex | The index of the array to begin copying at. |
public void Dispose()Public function to release all resources used by the _lock variable. Calls the private Dispose function.
public void Dispose
(
bool disposing
)Adds a new entry into the list.
| Parameter | Description |
|---|---|
| disposing | Whether or not the common language runtime will call the finalizer for the specified object. |
public IEnumerator<T> GetEnumerator()Returns an enumerator that iterates through the list.
IEnumerator IEnumerable.GetEnumerator()Returns an enumerator that iterates through the list.
public int IndexOf
(
T item
)Gets the index of the given item in the list.
| Parameter | Description |
|---|---|
| item | The item to get the index of in the list. |
| Returns |
|---|
| The location of the item in the list. Returns -1 if not found. |
public void Insert
(
int index,
T item
)Inserts the given item into the specified index of the list.
| Parameter | Description |
|---|---|
| index | The location in the list to insert the item at. |
| item | The item to add to the list. |
public bool Remove
(
T item
)Removes the given item from the list.
| Parameter | Description |
|---|---|
| item | The item to remove from the list. |
| Returns |
|---|
| Whether or not an item was removed from the list. |
public void RemoveAt
(
int index
)Removes the item from the list at the given location.
| Parameter | Description |
|---|---|
| index | The location to remove an item from in the list. |