Class ConcurrentCollector<T>
A collector that allows for concurrent adding of items, as well as non-thread-safe clearing and accessing of the underlying colletion.
public class ConcurrentCollector<T> : IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
T
The element type in the collection.
- Inheritance
-
ConcurrentCollector<T>
- Implements
-
IEnumerable<T>
- Extension Methods
Constructors
ConcurrentCollector(int)
public ConcurrentCollector(int capacity = 16)
Parameters
capacity
int
Properties
Count
Gets the number of elements in the collection.
public int Count { get; }
Property Value
- int
The number of elements in the collection.
this[int]
Gets the element at the specified index in the read-only list.
public T this[int index] { get; set; }
Parameters
index
intThe zero-based index of the element to get.
Property Value
- T
The element at the specified index in the read-only list.
Items
public T[] Items { get; }
Property Value
- T[]
Methods
Add(T)
public int Add(T item)
Parameters
item
T
Returns
AddRange(IReadOnlyList<T>)
public void AddRange(IReadOnlyList<T> collection)
Parameters
collection
IReadOnlyList<T>
Clear(bool)
public void Clear(bool fastClear)
Parameters
fastClear
bool
Close()
Consolidates all added items into a single consecutive array. It is an error to access Items after adding elements, but before closing.
public void Close()
GetEnumerator()
public ConcurrentCollector<T>.Enumerator GetEnumerator()